Closed Bug 404332 Opened 17 years ago Closed 13 years ago

LiveConnect/DOM multithreading issue on Mac

Categories

(Core Graveyard :: Java: Live Connect, defect)

1.8 Branch
PowerPC
macOS
defect
Not set
major

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: josephm, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
Build Identifier: Firefox 2.0.0.9 for mac

The problem is that JSObject used in liveconnect stops working in Firefox on
MAC if it does not get called from JavaScript directly.

The sample below illustrates this problem.

There is an applet that have "test1()" method being called from JavaScript.
"testJSObject()" method prints results of toString() method of JSObject.

If "testJSObject()" gets called from "test1()" method directly then
"toString()" returns a valid non-null value.

If "testJSObject()" gets called from another thread then "toString()"
returns null value starting from some point.

Moreover, "toString()" does not work if "testJSObject()" is called using
javax.swing.SwingUtilities.invokeAndWait or invokeLater methods
on AWT event dispatching thread that in fact is the same as thread where
"test1()" is called.

As a result, the Common DOM API based on JSObject does not work either.

This happens to all versions of Firefox under MAC. Firefox on Windows,
Safari on MAC and IE works fine.


I have the following enviroment:
============================================================================
==============
MAC OS 10.4.9
Firefox 2.0.0.9
Java Plug-in 1.5.0
JRE 1.5.0_07

Here is Java console log for the sample below:
============================================================================
==============
THREAD: AWT-EventQueue-6 JSObject: [object HTMLDocument]
THREAD: AWT-EventQueue-6 JSObject: [object HTMLDocument]
THREAD: Thread-8 JSObject: [object HTMLDocument]
THREAD: Thread-8 JSObject: [object HTMLDocument]
THREAD: AWT-EventQueue-6 JSObject: [object HTMLDocument]
THREAD: Thread-8 JSObject: null
THREAD: Thread-8 JSObject: null
THREAD: Thread-8 JSObject: null
THREAD: Thread-8 JSObject: null
THREAD: Thread-8 JSObject: null


Here is the sample:
============================================================================
==============
import netscape.javascript.*;

public class test extends JApplet
{
    public void testJSObject()
    {
        JSObject win = JSObject.getWindow(this);
        if (win == null)
        {
            System.err.println("Unable to obtain Window object");
        }
        else
        {
            JSObject doc = (JSObject)win.getMember("document");
            if (doc == null)
            {
                System.err.println("Unable to obtain Document object");
            }
            else
            {
                System.err.println("THREAD: " +
Thread.currentThread().getName() + " JSObject: " + doc);
            }
        }
    }

    public void test1()
    {
        testJSObject();
        testJSObject();

        Thread t = new Thread()
        {
            public void run()
            {
                testJSObject();
                testJSObject();
                testJSObject();
                try
                {
                    Thread.sleep(100);
                    testJSObject();
                    testJSObject();
                }
                catch (Exception ex)
                {
                }
                testJSObject();
                testJSObject();
            }
        };

        t.start();

        try
        {
            Thread.sleep(100);
        }
        catch (Exception ex)
        {
        }
        testJSObject();
    }
}


Reproducible: Always

Steps to Reproduce:
use the minimal use case above
Actual Results:  
above


have dom objects available
(In reply to comment #0)
> This happens to all versions of Firefox under MAC. Firefox on Windows,
> Safari on MAC and IE works fine.

When you say "all version of Firefox" have you tested Firefox 3 beta 1? If not, can you please check it?
Component: General → Java: Live Connect
Product: Firefox → Core
QA Contact: general → live-connect
Version: unspecified → 1.8 Branch
Tried it with FF 3 beta 1. Still doesn't work.
Product: Core → Core Graveyard
Firefox code moved from custom Liveconnect code to the NPAPI/NPRuntime bridge a while back. Mass-closing the bugs in the liveconnect component which are likely invalid. If you believe that this bug is still relevant to modern versions of Firefox, please reopen it and move it the "Core" product, component "Plug-Ins".
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.