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?
The
- (void)setHostWindow:(NSWindow *)hostWindowmethod 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
setStyleMaskfixed 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: