将 Delphi TWebBrowser 控件中的 Flash Player 移动到后台线程?
我有一个带有 TWebBrowser 组件的 Delphi 6 Pro 程序,该组件加载嵌入 Cool Iris Wall 的网页。 Cool Iris wall 是一个 SWF 对象,这意味着运行时,执行发生在 Adobe Flash 播放器(我认为是 ActiveX 或类似对象)内。我遇到的问题是,有时当 Wall 从网络加载图片/视频时,主 UI 线程上的 CPU 会受到很大影响。我知道 TWebBrowser 将其大部分操作转移到后台线程以保持主 UI 线程正常运行,但 Adobe Flash Player 正在做的事情发生在主 UI 线程上,这给我的程序带来了很大的麻烦。有没有办法将 Adobe Flash Player 移至后台线程?
[更新 - 12/7/2010] - 经过马拉松式的探测和调试会话后,发现问题与 Cool Iris Wall 的 Flickr 代理有关。您可以通过两种主要方式与 Wall 交互: 1) 您向它们传递特殊的 Flickr api 协议 URL,让它们为您与 Flickr 对话,例如“api://www.flickr.com/?search=puppy”加载墙上贴着 Flickr 关键词搜索小狗的结果。这种方法的优点是,他们会为您完成查询 Flickr 和构建墙的内容所需的所有工作。 2) 您自己构建一个包含照片流项目数据的 RSS 媒体源,并将其提供给 Wall。
我使用的是技巧#1。 #1 的问题是,当他们的服务器无法为您构建 Flickr feed 时(无论出于何种未知原因),他们的主机 SWF 会给 CPU 带来沉重的负载,从而干扰主 UI 线程的操作。我将整个代码库转换为直接使用 Flickr API,并使用第二种技术自己创建提要,问题就消失了。
——罗施勒
I have a Delphi 6 Pro program with a TWebBrowser component that loads a web page that embeds a Cool Iris Wall. The Cool Iris wall is an SWF object which means that when running, the execution happens inside the Adobe Flash player, an ActiveX or similar object I believe. The problem I am having is that sometimes when the Wall is loading pictures/videos from the web, it takes a big hit on the CPU on the main UI thread. I know that TWebBrowser moves most of its operations on to a background thread to keep the main UI thread happy, but something the Adobe Flash Player is doing is happening on the main UI thread and its causing my program much grief. Is there a way to move the Adobe Flash Player on to a background thread?
[UPDATE - 12/7/2010] - After a marathon probing and debugging session it turns out that the problem had to do with the Cool Iris Wall's Flickr proxy. You can interface with the Wall in two main ways: 1) You pass them special Flickr api protocol URLs and let them talk to Flickr for you, for example "api://www.flickr.com/?search=puppy" loads the Wall with the results of a Flickr keyword search for puppy. The advantage to this approach is that they do all the work for you necessary to make the query to Flickr and build the Wall's contents. 2) You build an RSS media feed yourself containing the photo stream item data and feed it to the Wall.
I was using technique #1. The problem is with #1 is that when their servers have trouble building the Flickr feed for you (for whatever unknown reason), their host SWF puts a heavy load on the CPU interfering with the main UI thread's operation. I converted my entire code base to work directly with the Flickr API and create the feed myself using the second technique and the problem vanished.
-- roschler
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法控制网络浏览器如何管理其线程。如果您不希望网络浏览器干扰主线程,那么一开始就不要在主线程中运行网络浏览器。
You have no control over how the webbrowser manages its threading. If you do not want the webbrowser interfering with the main thread, then don't run the webbrowser in the main thread to begin with.