Skip to main content

Cached JSObjects are invalidated automatically.

12 replies [Last post]
jasuha1
Offline
Joined: 2007-12-27
Points: 0

Using new Java plugin, when an applet is destroyed, all the cached JSObject references on other applets are automatically invalidated? Although not a blocker, this is an interesting bug.

This happens on IE and Firefox 3.0 Beta 2

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kbr
Offline
Joined: 2003-06-16
Points: 0

I believe you're running into intended behavior. In the new Java Plug-In, each JSObject reference which is exposed from the browser is associated with the applet which requested it. The top-level association is made between the applet and the JSObject corresponding to its window. Any further JSObjects returned from calls against the window object are also associated with that applet. When that applet is destroyed, all of the associated JSObject references are destroyed.

This means that you may not pass JSObjects between multiple applets on the same page.

We haven't seen any real world content so far which breaks with this new implicit behavior. To be honest, I'm not sure it's possible to correctly implement any other behavior. If you have a real world application that breaks, please email me at kbr at dev.java.net.

jasuha1
Offline
Joined: 2007-12-27
Points: 0

kbr, we are going to put a live demo of our product in this week which is a complex liveconnect based platform. You will be able to debug your new plugin against it easily.

The problem is not about passing JSObjects between applets. Lets say I have three iframes and a single applet in each of these iframes. If I cache JSObject on all three applets, destroying one applet makes all JSObject references invalid which are not interrelated at all.

I believe this is again an iframe related problem. Iframes have their own window and context, and an Applet inside an iframe should not be affected by applets in other iframes. I had a hardtime spotting this bug, because it was not logical to me to see our cached unique JSObject references getting trashed automagically.

The iframe window and context handling portions of the new plugin may be revisisted.

Message was edited by: jasuha1

Message was edited by: jasuha1

kbr
Offline
Joined: 2003-06-16
Points: 0

Thanks for the concise test case, which I received via email. This is definitely a bug in the new plug-in and I've filed 6647070 to track it. This bug should be visible on the Sun Bug Database within a day or two. I plan to investigate this immediately and hope that we will have a fix in the forthcoming 6u10 build 11. I'll try to keep this thread updated with progress.

kbr
Offline
Joined: 2003-06-16
Points: 0

I've tracked down the root cause of the JSObject invalidation bug in the new plug-in and it was a staggering bug where a comment in the code said one thing and the code did exactly the opposite. Frankly I'm amazed we got this far in our testing without running into this. Thanks again for the excellent test case. This will be fixed in 6u10 build 11.

The issue with eval("top.helloWorld()") not working in FF 3 is a browser bug and I will contact Mozilla.org about it. Unfortunately I don't think there's any workaround we can do in the new plug-in for this problem.

jasuha1
Offline
Joined: 2007-12-27
Points: 0

I am glad to hear all these. The eval("top.helloWorld()") is working fine with FF 3 with the old plug-in. Is it related to new Mozilla interface you use?

kbr
Offline
Joined: 2003-06-16
Points: 0

Yes. In the new plug-in we have switched from the archaic OJI to the vastly simpler and more modern NPRuntime interface for implementing the Java/JavaScript bridge. There is probably some restriction in how the NPRuntime works that needs to be relaxed for compatibility. I'll distill this into a smaller test case and file a bug with Mozilla.org tomorrow.

kbr
Offline
Joined: 2003-06-16
Points: 0

FYI, the Mozilla bug can be viewed at https://bugzilla.mozilla.org/show_bug.cgi?id=410853 . It is possible to do an application-level workaround for this problem. Please see this bug report and the attached test case, in particular the Java source code, for the workaround. Unfortunately a workaround in the Java Plug-In is not possible; the bug needs to be fixed on the browser side.

The fix for Sun bug 6647070 has been checked in and again will be in 6u10 build 11.

Thanks again for the test case and please post on this forum if you see further problems, or feel free to email me as well.

jasuha1
Offline
Joined: 2007-12-27
Points: 0

Thanks for the update. FYI

Error: uncaught exception: [Exception... "Security Manager vetoed action"
nsresult: "0x80570027 (NS_ERROR_XPC_SECURITY_MANAGER_VETO)" location: "JS frame

is not related to that bug. It was because of a bug in our own code. We get the same error message as you do which is "top.helloWorld is not a function".

I will definetely let you know any blocker bugs.

kbr
Offline
Joined: 2003-06-16
Points: 0

Thanks for following up. I updated the description of the Mozilla bug 410853.

jasuha1
Offline
Joined: 2007-12-27
Points: 0

Is 6u10 build 11 the next beta build? The fix will catch the Firefox 3.0 final release right?

thanks

kbr
Offline
Joined: 2003-06-16
Points: 0

No, the next build (due out in a couple of days) is 6u10 build 10. Build 11 will be out close to the end of the month.

I saw an update to the Mozilla bug yesterday with a proposed patch so I assume it will be present in the FF 3 final build. Add yourself to the CC: list of that bug on Bugzilla to watch for updates. You'll then be able to pick them up from the FF 3 nightly builds: http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/ .

kbr
Offline
Joined: 2003-06-16
Points: 0

FYI, Mozilla bug 410853 has been fixed in FF 3, and I've verified the fix. It would be good if you could download the current FF 3 nightly build and make sure the issues are fixed in your application.

https://bugzilla.mozilla.org/show_bug.cgi?id=410853
http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/