WPF and CefSharp: sluggish performance

[亡魂溺海] 提交于 2019-12-04 04:46:21

问题


I have successfully made a personal mini browser app in c# winforms. Because I want some more fancy effects, I was considering to make a WPF app. So I tried the wiki tutorial and set up a simple WPF form with a browser, but noticed it has sluggish performance. It's even noticeable when selecting text in very simple webpage, or just when scrolling the page. Is there anything that can be done? If not, I guess it will be just winforms then, since that one behaves and performs well.

edit: my specs: http://users.telenet.be/dropbox/specs.html


回答1:


WPF version of cefsharp uses different model of rendering than WinForms. In WPF it basically copies each frame into bitmap and you might imagine how slow it can become. This is especially noticeable on high-resolution screens. There are some options to improve that perfomance (see here for example), but in my experience (I tried all that options) non of them really helps to match WinForms. To run cefsharp smoothly in my WPF project I actually had to use WinForms version of cefsharp and host it inside WindowsFormsHost - this helps with perfomance problems but has it's caveats of course (for example you cannot partially hide WinForms hosted control behind WPF controls - it will always be rendered on top of everything). Still for now I consider this the only viable option, because high-resolution screens are now quite widespead.




回答2:


This will disable WebGL, look at the source to determine which flags best suite your requirements. "grMain" is a Grid in Wpf

CefSettings s = new CefSettings();
s.SetOffScreenRenderingBestPerformanceArgs();
Cef.Initialize(s);
ChromiumWebBrowser wbMain = new ChromiumWebBrowser();
grMain.Children.Add(wbMain);


来源:https://stackoverflow.com/questions/42549349/wpf-and-cefsharp-sluggish-performance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!