问题描述
更新 2020 年,我链接了我的文章,其中我比较了在基本 Windows 桌面应用程序中托管 HTML WebView 的不同方法的内存占用:
Updated for 2020, I've linked my article where I compare the memory footprints of different approaches to hosting HTML WebView in a basic Windows Desktop application:
基于 Internet Explorer 的 WPF WebBrowser 控件存在一些键盘和焦点问题 和 内存泄漏问题.作为这些问题的替代解决方案,我们正在考虑在基于 HTML 编辑的 WPF/C# 项目中托管 Chromium 而不是 WebBrowser 控件的可用选项.类似的问题之前已经询问.我已经阅读了答案并进行了自己的研究,但我希望从那些在生产质量项目中实际使用以下任何选项的人那里获得更多反馈:
Internet Explorer-based WPF WebBrowser control suffers from some keyboard and focus issues and memory leak issues. As an alternative solution to these problems, we're considering available options for hosting Chromium instead of WebBrowser control in our WPF/C# project based around HTML editing. Similar questions have been asked here previously. I've read the answers and done my own research, but I hope to obtain some more feedback from people who have actually used any of the following options in production-quality projects:
它看起来很合适,但我不喜欢这个项目不是开源的,并且不容易获得完整的源代码.此外,这对我们的项目来说可能是一种矫枉过正,因为离屏渲染并不是我们真正依赖的东西.
It looks very appropriate, but I don't like the fact the project is not open-source and the full source is not easily available. Also, it might be an overkill for our project, as off-screen rendering is not something we really depend on.
Chromium 嵌入式框架 (CEF) 和 CEF 的.NET 绑定
这可能是目前可用的最佳选择.该项目似乎很活跃,目前与 Chrome v27 同步.CEF3 使用 Chrome 多进程架构.看起来 Adobe 也在给它一些认可.
This is probably the best option currently available. The project seems to be alive and active, being currently in sync with Chrome v27. CEF3 uses Chrome multi-process architecture. It also looks like Adobe is giving it some endorsement.
虽然它的最初目的是成为 IE 和 Firefox 的 HTML5 插件,但它实际上也可以作为独立的 ActiveX 控件工作,所以我可以将它包装起来以与 WPF 一起使用.它公开了一个足够的API,用于与内部网页(onmessage, addEventListener/removeEventListener, postMessage
).我知道 Google 将停止使用 Chrome Frame,但我假设源将保留在 Chromium 存储库中.随着我们的进行,使用最新的 Chromium 代码更新它应该不难,我们将完全控制它.
While the original purpose of it was to be an HTML5 plugin for IE and Firefox, it actually works as standalone ActiveX control too, so I could wrap it for use with WPF. It exposes a sufficient API for interaction with the inner web page (onmessage, addEventListener/removeEventListener, postMessage
).I'm aware Google is to discontinue Chrome Frame, but I assume the sources will remain in Chromium repository. It should not be difficult to update it with the latest Chromium code as we go, and we would have full control over this.
不完全基于 Chromium 并且不使用 V8 引擎,因此它不是一个真正的选择.
Not exactly Chromium-based and doesn't use V8 engine, so it is not really an option.
还有其他我可能忽略的选项吗?
Is there any other option I might have overlooked?
如果有人分享她/他对现实生活中的生产质量 WPF 项目的上述任何选项的经验,我将不胜感激.您有任何集成、许可或部署方面的影响吗?谢谢.
我还要感谢 artlung 通过提供慷慨的赏金提议来推动这个问题.
I'd also like to thank artlung for giving this question a boost by providing a generous bounty offer.
推荐答案
您已经列出了最著名的嵌入 Chromium 的解决方案(CEF、Chrome Frame、Awesomium).没有更多重要的项目了.
You've already listed the most notable solutions for embedding Chromium (CEF, Chrome Frame, Awesomium). There aren't any more projects that matter.
还有 Berkelium 项目(参见 Berkelium Sharp 和 Berkelium Managed),但它嵌入了旧版本的 Chromium.
There is still the Berkelium project (see Berkelium Sharp and Berkelium Managed), but it emebeds an old version of Chromium.
CEF 是您最好的选择 - 它完全开源并且经常更新.这是允许您嵌入最新版本的 Chromium 的唯一选项.现在 Per Lundberg 正在积极致力于将 CEF 3 移植到 CefSharp,这是未来的最佳选择.还有 Xilium.CefGlue,但这个为 CEF 提供了低级 API,它绑定到 CEF 的 C API.另一方面,CefSharp 绑定到 CEF 的 C++ API.
CEF is your best bet - it's fully open source and frequently updated. It's the only option that allows you to embed the latest version of Chromium. Now that Per Lundberg is actively working on porting CEF 3 to CefSharp, this is the best option for the future. There is also Xilium.CefGlue, but this one provides a low level API for CEF, it binds to the C API of CEF. CefSharp on the other hand binds to the C++ API of CEF.
Adobe 不是唯一使用 CEF 的主要参与者,请在 CEF 维基百科上查看使用 CEF 的其他著名应用程序页.
Adobe is not the only major player using CEF, see other notable applications using CEF on the CEF wikipedia page.
更新 Chrome Frame 毫无意义,因为该项目已退休.
Updating Chrome Frame is pointless since the project has been retired.
这篇关于使用 WPF/C# 嵌入 Chromium 而不是 IE WebBrowser 控件的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!