Closed Bug 369556 Opened 19 years ago Closed 8 years ago

Bad NPObject as private data! errors accessing NPRuntime scriptable object in onpageshow

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: wbardwel, Unassigned)

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060211 Fedora/1.0.7-1.3.fc3.legacy Firefox/1.0.7 Build Identifier: Gecko/20070108 Minefield/3.0a2pre I have a plugin which uses NPRuntime APIs to provide a scriptable object. If I browse to a page with an OBJECT tag handled by my plugin, and the JavaScript on thepage uses the scriptable object, then browse to a different page, then hit the back button, the JavaScript tries to access the scriptable object in the onpageshow event, but a "Bad NPObject as private data!" error shows up in the log. If I then click on things on the page that also use the scriptable object, they work fine. So it is like the fix for [Bug 309044] doesn't happen soon enough, and so during the pageshow event there is still old versions of the scriptable object (from the first time the page was shown) hanging around, but a moment later everything is fine and a new scriptable object is created (as would be expected.) Reproducible: Always Steps to Reproduce: 1. 2. 3.
So, my lame work around was to change: <body onload="onLoad();" onpageshow="if (event.persisted) onLoad();"> to <body onload="onLoad();" onpageshow="if (event.persisted) setTimeout('onLoad()', 1);"> Where onLoad() gets the plugin's scriptable object and sets a property on it. But for that to work says to me that it is not a bug in the plugin.
I see this on Linux with another plugin, see bug 438332.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.4) Gecko/20100413 Firefox/3.6.4 Please update if you are able to still reproduce with the latest nightly build ftp://ftp.mozilla.org/pub/firefox/nightly/latest-trunk/
Whiteboard: [closeme 2010-05-05]
I still see this bug exactly as described above in rv:1.9.3a5pre Gecko/20100420 Minefield/3.7a5pre on Windows 7.
William, if you could attach a testcase or give a page that shows the problem, that would be great.
Whiteboard: [closeme 2010-05-05]
Sure, install the Curl RTE from http://www.curl.com/ Then put the following content in files as named below in the same directory. Load m.html and hit the link, and then hit the back button and look at the error console.: m.html: <html> <head> <title>Javascript sample</title> <script type="text/javascript"> function onLoad() { var shape = document.getElementById("shape"); shape.applet_invoke_ready_callback = function() { if (!shape.applet_invoke_ready) alert("not ready."); }; }; </script> </head> <body onload="onLoad()" onpageshow="if (event.persisted) onLoad();"> <object id="shape" type="text/vnd.curl" data="m.curl" width=200 height=200></object> <p><a href="http://www.mozilla.com/">Click to browse away, then hit browser back to see error in Error Console.</a></p> </body> </html> m.curl: {curl 6.0, 7.0 applet} Hi.
Thanks, William. I'm not sure, but these kinds of problems might be something that has to be fixed by the plugin itself.
Why would it be the plugins fault if it works as long as you do it a few fractions of a second later? Plus, as far as I can tell all that the plugin is doing in this case is: NPObject *callback = NPVARIANT_TO_OBJECT(*value); NPN_RetainObject(callback); and some normal C code that doesn't interact with the browser.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.