WebView 中的插件对象被破坏?
这是我的情况:
我编写了一个简单的网络浏览器。一旦我了解了概念并弄清楚如何在特定选项卡上执行操作,选项卡式浏览就很容易开始工作。它运行良好,并且在大多数情况下都非常可靠。
然而,有一个问题一直困扰着我,我无法找出其原因。
假设我打开一个新选项卡并导航到 YouTube。我点击一个视频,Flash 播放器就会加载。视频播放并且一切正常。我现在创建另一个新选项卡并导航到某个网站。 YouTube 播放器的音频完全停止。
当我切换回 YouTube 选项卡时,页面仍然会原样存在,只是播放器必须完全重新加载,就像我刚刚重新加载页面一样。这似乎也适用于其他插件类型。
这是什么原因造成的?
垃圾收集未启用,据我所知,我正在正确创建网络视图。我是否在整个过程中错过了一些愚蠢而简单的小事情?
Here's my situation:
I've written a simple web browser. Tabbed browsing was easy enough to get working once I wrapped my head around the concepts and figured how to perform operations on specific tabs. It works well and is pretty reliable under most circumstances.
A problem has plagued me, however, and I cannot figure out its cause.
Let's say I open a new tab and navigate to YouTube. I click on a video and the flash player loads. The video plays and all works fine. I now create another new tab and navigate to some site. The audio from the youtube player stops completely.
When I switch back to the youtube tab, the page will all still be there just as it was except the player has to reload completely, as if I had just reloaded the page. This seems to apply to other plugin types as well.
What's causing this?
Garbage collection is not enabled and as far as I know I'm creating the web views properly. Is there some silly, simple little thing that I missed somewhere along the line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WebView 上的
- (void)setHostWindow:(NSWindow *)hostWindow
方法可能就是您正在寻找的。每当封闭窗口的样式掩码发生更改时,我都会在 WebView 重新加载中遇到 Flash 相同的问题。包装对
setStyleMask
的调用解决了该问题,如下所示:该方法的文档并不出色,但它确实明确指出内部有一个 WebView NSTabView 作为用例之一:
The
- (void)setHostWindow:(NSWindow *)hostWindow
method on WebView is probably what you're looking for.I had the same problem with the flash in a WebView reloading whenever the syle mask of the enclosing window was changed. Wrapping the call to
setStyleMask
fixed the problem, as follows:The documentation for the method isn't stellar, but it does explicitly state a having a WebView inside a NSTabView as one of the use cases:
我遇到了类似的问题,但有一个带有 webView 的窗口已关闭并恢复。不幸的是@mlwelles 的解决方案并没有单独解决问题。
然而,解决的办法是在关闭之前从窗口中删除 webView(正确的“时机”很重要)。我想出的是这样的:
I had a similar problem but with a window with a webView that is closed and restored. Unfortunately the solution by @mlwelles did not solve the problem alone.
What did solve however is removing the webView from the window before it closes (proper "timing" is important). What I came up with is something like this: