The plugin located at /Developer/Examples/WebKit/NetscapeMoviePlugIn in Tiger works with safari, but in Firefox it crashes when javascript code tries to use scriptable methods or properties. I use the the sample html page on the latest Firefox release (1.0.6). I found in the plugin source that browser->retainobject() is not called when a scriptable method returns a NPObject, which is not conform to the mozilla implementation of the NSAPI. (Calling this function seems to fix the problem, but probably causes memory leaks in Safari.) I suppose the object lifecycle managment implemented in WebKit follows the CoreFoundation conventions, ie a getter doesn't increment the reference counter of a returned object. It would be better to follow mozilla conventions (which is the same as XPCOM and COM) : objects have their ref counts incremented before being returned by a scriptable function. In this case the caller has the responsibility to release the ref count of a returned object when it doesn't use it anymore.
RealPlayer has
Since we know that the RealPlayer plug-in works with both Safari and Firefox, and uses the scripting API, we know it's possible. Lets figure out what's up.
Same as <rdar://problem/4211707> npapi ref count behavior differs with Mozilla, it seems.
Tim Omernick says that this is *not* the same as <rdar://problem/4211707>.
The WebKit examples are not part of the open-source project, so this bug belongs in Radar rather than here in the open source bugzilla. (However we'd like to see that change in the future.)
Created attachment 7059 [details] here's a patch that should fix the problem
My patch fixes the problem complained about here, as well as fixing many other small style issues and mistakes in the example. The biggest mistake was that there was a lot of function pointer casting.
I think it doesn't completely fix the problem even if NetscapeMoviePlugIn is now OK. Now NetscapeMoviePlugIn has probably memory leaks in Safari. Something must be changed in WebKit itself. But in this case, I don't how compatibility with existing WebKit plugins could be maintained...
(In reply to comment #8) > I think it doesn't completely fix the problem even if NetscapeMoviePlugIn is > now OK. Now NetscapeMoviePlugIn has probably memory leaks in Safari. > > Something must be changed in WebKit itself. > But in this case, I don't how compatibility with existing WebKit plugins could > be maintained... Yes, that's right. I believe Tim has worked the details out. Tim, can you comment here or in another bug or something?
<rdar://problem/4481553>
Tim says there are still problems with this.
Comment on attachment 7059 [details] here's a patch that should fix the problem Clearing review flag on this old patch, since it didn't solve the whole problem.
The plug-in needs to be changed to return a retained NPObject from NPP_GetValue(). We also need to change WebKit to expect a retained object back from NPP_GetValue() so that our retain/release rules match other browsers. I have a patch to fix this, and will be landing it shortly.
Fixed in OpenSource revision 16086, Internal revision 10181.
Comment on attachment 7059 [details] here's a patch that should fix the problem This is not the patch we landed. See diffs in OpenSource revision 16086, Internal revision 10181.