WPF和CefSharp:表现不佳 [英] WPF and CefSharp: sluggish performance

查看:763
本文介绍了WPF和CefSharp:表现不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功使用c#winforms开发了一个个人迷你浏览器应用程序。
因为我想要更多奇特的效果,所以我正在考虑制作WPF应用程序。因此,我尝试了Wiki教程,并使用浏览器设置了一个简单的WPF表单,但发现它的性能不佳。在非常简单的网页中选择文本或滚动页面时,甚至会引起注意。有什么可以做的吗?如果不是这样的话,我想那将只是winforms,因为那会表现得很好。

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.

编辑:我的规格: http://users.telenet.be/dropbox/specs.html

推荐答案

WPF版本的cefsharp使用的渲染模型与WinForms不同。在WPF中,它基本上将每个帧复制到位图中,您可能会想象它会变得多么慢。这在高分辨率屏幕上尤其明显。有一些方法可以改善这种性能(例如,请参见此处),但是在我的文章中经验(我尝试过所有这些选项)都不会对匹配WinForms有所帮助。为了在WPF项目中顺利运行cefsharp,我实际上不得不使用WinForms版本的cefsharp并将其托管在 WindowsFormsHost 中-这有助于解决性能问题,但当然有一些警告(例如,您不能将WinForms托管控件部分隐藏在WPF控件后面-始终将其呈现在所有控件之上)。到目前为止,我仍然认为这是唯一可行的选择,因为高分辨率屏幕现在已经相当广泛。

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.

这篇关于WPF和CefSharp:表现不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆