wpf 使用 WebBrowser 控件时 IE 11 WebGL 性能变慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25051072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IE 11 WebGL performance slow when using WebBrowser control
提问by Matthew Amato
I'm trying to embed Cesium in a WebBrowser control inside of a WinForms or WPF application (using IE 11). As a test I'm using this link:
我正在尝试将 Cesium 嵌入 WinForms 或 WPF 应用程序(使用 IE 11)内的 WebBrowser 控件中。作为测试,我正在使用此链接:
http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html?stats=true
http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html?stats=true
It "works" but is much much slower than using IE 11 directly. In IE 11, everything runs at 60fps; in a simple WPF or WinForms app with the WebBrowser control it runs at 4-6 fps. I've been unable to track down the cause of the problem. This is with a blank Form or WPF Panel with the WebBrowser control set to fill the entire pane. There's no transparency or other issues that I can imagine. I've noticed that going to the above link inside of the Visual Studio embedded browser has the same effect. Does WebBrowser control not JIT JavaScript? Is it a WebGL issue? Is there a way I can debug this to figure out what's going on? Any help would be greatly appreciated.
它“有效”,但比直接使用 IE 11 慢得多。在 IE 11 中,一切都以 60fps 的速度运行;在带有 WebBrowser 控件的简单 WPF 或 WinForms 应用程序中,它以 4-6 fps 的速度运行。我一直无法找到问题的原因。这是一个空白的表单或 WPF 面板,其中 WebBrowser 控件设置为填充整个窗格。没有我可以想象的透明度或其他问题。我注意到转到 Visual Studio 嵌入式浏览器中的上述链接具有相同的效果。WebBrowser 控制不是 JIT JavaScript?这是 WebGL 问题吗?有没有办法可以调试它以弄清楚发生了什么?任何帮助将不胜感激。
回答by Luigi Belli
Take a look at this article:
看看这篇文章:
As it turns out, the embedded browser uses the IE7 rendering engine by default, even if a newer version of IE is installed. Also, GPU rendering is switched off, so the browser uses software rendering only.
This was fixed by setting the following feature control registry keys:
- FEATURE_BROWSER_EMULATION – set to the desired version of the IE rendering engine
- FEATURE_GPU_RENDERING – set to 1 to enable GPU rendering.
These keys can be set under HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER for a specific program (executable name), which uses the embedded browser. HKCU is preferred since the program won't need administrator privileges to write to HKCU.
So when I set FEATURE_BROWSER_EMULATION to 10000 (for IE10) and set FEATURE_GPU_RENDERING to 1, the performance improved to ~850 fishies @ 60 fps. Still not as good as standalone IE with its 1000+ fishies, but quite an improvement!
事实证明,嵌入式浏览器默认使用 IE7 渲染引擎,即使安装了较新版本的 IE。此外,GPU 渲染已关闭,因此浏览器仅使用软件渲染。
这是通过设置以下功能控制注册表项来解决的:
- FEATURE_BROWSER_EMULATION – 设置为所需的 IE 渲染引擎版本
- FEATURE_GPU_RENDERING – 设置为 1 以启用 GPU 渲染。
对于使用嵌入式浏览器的特定程序(可执行名称),可以在 HKEY_LOCAL_MACHINE 或 HKEY_CURRENT_USER 下设置这些键。HKCU 是首选,因为该程序不需要管理员权限即可写入 HKCU。
因此,当我将 FEATURE_BROWSER_EMULATION 设置为 10000(对于 IE10)并将 FEATURE_GPU_RENDERING 设置为 1 时,性能提高到 ~850 鱼 @ 60 fps。仍然不如具有 1000 多个鱼的独立 IE 好,但相当大的改进!
回答by Alex Prachuablarb
You'll need to change these two reg keys to make it work for all users
您需要更改这两个 reg 键以使其适用于所有用户
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
For a single user just use
对于单个用户只需使用
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
Adding the DWORD make sure you set the value to 11999 and not 11001 as the link below says, and it should set it to IE 11 standards mode. Although it comments that using an invalid value will set it to the latest, so setting it to 99999 will probably work for the next versions.
添加 DWORD 确保将值设置为 11999 而不是 11001,如下面的链接所述,并且应将其设置为 IE 11 标准模式。尽管它评论说使用无效值会将其设置为最新,但将其设置为 99999 可能适用于下一个版本。
http://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version
http://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version

