Closed Bug 116357 Opened 24 years ago Closed 24 years ago

Old school plug-ins need the ability to be cached

Categories

(Core Graveyard :: Plug-ins, defect)

x86
Windows 2000
defect
Not set
major

Tracking

(Not tracked)

VERIFIED FIXED
mozilla1.0

People

(Reporter: TaylorToddK, Assigned: serhunt)

Details

(Keywords: topembed+, Whiteboard: [ADT2])

Attachments

(1 file, 1 obsolete file)

Since old school plug-ins can access XPCOM functionality, old school plug-ins need the ability to be cached or prolong their lifetime until they have completed cleanup. The plug-in may have registered a listener with an channel. Due to asynchronous behaviour of a channel, a plug-in cannot guarantee all references to its objects are released when the plug-in's destroy and shutdown methods are called. Since NPAPI plug-in are unloaded from memory, this would result in the channel holding an invalid listener memory address and crashing in subsequent calls.
Keywords: topembed
Andrei, isn't that what nsPluginInstanceVariable_DoCacheBool in NPP_GetValue was for? Maybe it has regressed?
nominating nsbeta1
Keywords: mozilla1.0, nsbeta1
Keywords: topembedtopembed+
Nominating nsbeta1+ per ADT triage.
Keywords: nsbeta1nsbeta1+
Target Milestone: --- → mozilla1.0
For some reason Mozilla does not want to attach a file, so I am cut'n'pasting the patch. This patch removes a check for being 'old school' before unloading the plugin but rather only relies on the plugin response. Please review.
Index: nsPluginHostImpl.cpp =================================================================== RCS file: /cvsroot/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp,v retrieving revision 1.366 diff -u -w -r1.366 nsPluginHostImpl.cpp --- nsPluginHostImpl.cpp 16 Mar 2002 15:58:54 -0000 1.366 +++ nsPluginHostImpl.cpp 17 Mar 2002 16:07:46 -0000 @@ -5712,6 +5712,15 @@ return rv; } +static BOOL IsCachedPlugin(nsIPluginInstance * aInstance) +{ + PRBool doCache = PR_FALSE; + aInstance->GetValue(nsPluginInstanceVariable_DoCacheBool, (void *) &doCache); + + // I have to write it this ugly way because due to interference between + // nsplugindefs.h and npapi.h value 5 may be used for java class either + return (doCache == PR_TRUE); +} //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP @@ -5727,15 +5736,10 @@ plugin->setStopped(PR_TRUE); // be sure we set the "stop" bit // if the plugin does not want to be 'cached' just remove it - PRBool doCache = PR_TRUE; - aInstance->GetValue(nsPluginInstanceVariable_DoCacheBool, (void *) &doCache); - - // we also do that for 4x plugin, shall we? Let's see if it is - PRBool oldSchool = PR_TRUE; - if(plugin->mPluginTag) - oldSchool = plugin->mPluginTag->mFlags & NS_PLUGIN_FLAG_OLDSCHOOL ? PR_TRUE : PR_FALSE; - - if (!doCache || oldSchool) + // we should also keep in mind that some new 4x plugins may use XPCOM + // services and thus may want to be cached too. We assume that they + // don't in many cases but do not check for being old school explicitely + if (!IsCachedPlugin(aInstance)) { PRLibrary * library = nsnull; if(plugin->mPluginTag)
Whiteboard: patch in comment #5
I was also looking at this last night and noticed the descrepency in variables. I don't think we should be calling into the plugin with a wrong variables and twice no less (once in nsObjectFrame::Destroy). With this mix-up, a plugin may tell us the wrong thing. So, in this patch, I created a new variable, NPPVpluginKeepLibraryInMemory, that the plugin can set with a NPP_SetValue and prevent us from calling in with wrong variables. Works similar to how the plugin tells us it's transparent and we can leave the the misnamed variables behind.
Whiteboard: patch in comment #5
Adding a new value for NPPvariable is a good idea. However, I am not sure that we want to do it similar to the case of transparancy. We promoted doCacheBool for quite a time and can break whatever plugins already using this mechanism. Java comes to mind at once.
Attached patch patch v.3 (obsolete) — Splinter Review
Andrei, your patch doesn't catch the "extra" calls to NPP_GetValue in nsObjectFrame::Destory for variable NPPVjavaClass aka DoCacheBool and CallSetWindowAfterDestroyBool. We call multiple times. Wasn't this caching only done for XPCOM plugins? Have we ever cached 4.x-style plugins? nsplugindefs.h isn't even part of the NPAPI SDK. These variables have gotten really screwed up and I don't think we should attempt to use them interchangably anymore. My patch doesn't change anything for XPCOM plugins such as Java. They will continue to use nsPluginInstanceVariable_DoCacheBool and it will function just like before. :) With 4.x plugins, however, we will no longer make calls for PPVjavaClass and NPPVpluginWindowSize (nsPluginInstanceVariable_CallSetWindowAfterDestroyBool) which are meaningless and may trigger unwanted side-effects. Instead, I just remapped an exsisting XPCOM nsPluginInstanceVariable to a newly invent NPPV one. Also, since this is new with 4.x plugins, why not save us a call into the plugin and have it call us to set the value? I think that's cleaner and matches the way Patrick recently implemented javascriptPushCallerBool. Fixing the bad calls to NPPVpluginWindowSize may one day lead to implementing the feature.
Is not Java plugin supposed to respond to this GetValue call? This was my only concern so far. Otherwise I agree with what you are saying.
Peter, I was under impression that Java is not an XPCOM plugin in full sense. Otherwise, there would be no need for DoCacheBool. If my memory does not mislead me this variable was 'invented' specifically for the Java plugin. In your patch you remove this GetValue call to plugin. Please correct me if I am wrong. In all other aspects I agree: we should not promote nsplugindefs.h anymore, and given all this is brand new the mechanism similar to setting transparancy makes perfect sense.
1. Don't change anything in the nsplugindefs.h file, it's effectively frozen and deprecated. We don't want to add anything new here. 2. Java plugins are XPCOM plugins in the sense that they have a longer lifetime than a given web page, since we can use Java in LiveConnect, and create new threads that outlive the web page that spawned them.
adding adt2 nomination in status whiteboard.
Whiteboard: [ADT2]
Comment on attachment 74619 [details] [diff] [review] another possible patch? (creating NPPVpluginKeepLibraryInMemory) After detailed discussion with Peter, I agree that this approach would address our problem and will not cause any problems with Java plugin. r=av
Attachment #74619 - Flags: review+
Comment on attachment 74619 [details] [diff] [review] another possible patch? (creating NPPVpluginKeepLibraryInMemory) sr=beard
Attachment #74619 - Flags: superreview+
Attachment #74645 - Attachment is obsolete: true
asa wrote in e-mail response to my approval request: >How well has this been tested? What kinds of risk is this patch? This has been tested to make sure all major plugins work as expected. The risk is minimal, this fix adds a possibility for a plugin to use the new behaviour, if plugin remains silent there will be no effect at all. As plugin manufacturers are not aware of this possibility yet, there are no plugins using this feature on the market. So no changes are expected for the existing plugins.
Comment on attachment 74619 [details] [diff] [review] another possible patch? (creating NPPVpluginKeepLibraryInMemory) a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #74619 - Flags: approval+
Checked in, thanks, Peter.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Shrirang, I don't think it can be verified any way other than just making sure the code is in. There are no yet plugins using this feature.
Actually, can the NPAPI tester plugin be used to verify this? It might be kinda tricky.
It should be updated by the way to be able to set those new variables. After that... Any utilities showing dlls in memory?
verif patch is in.
Status: RESOLVED → VERIFIED
I think I'll come with a way to verify the behaviour soon. It will be good for bug 133651 too.
See bug 133651, comments #9 and #10 for steps to reproduce and verify.
Tested with steps mentioned in bug 133651, Thanks, Andrei !
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: