WPF and CefSharp: sluggish performance

前端 未结 2 500
野趣味
野趣味 2021-01-21 12:28

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 an

相关标签:
2条回答
  • 2021-01-21 13:01

    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.

    0 讨论(0)
  • 2021-01-21 13:16

    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);
    
    0 讨论(0)
提交回复
热议问题