Using LiveConnect to call document.writeln from a Java applet causes a hang

RESOLVED INCOMPLETE

Status

Core Graveyard
Java: Live Connect
RESOLVED INCOMPLETE
11 years ago
6 years ago

People

(Reporter: heycam, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20070508 Iceweasel/2.0.0.4 (Debian-2.0.0.4-1)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a5pre) Gecko/20070522 Minefield/3.0a5pre

If I write a simple applet that calls document.writeln using JSObject, the browser will hang.

This is my applet code:

import javax.swing.JApplet;
import netscape.javascript.JSObject;

public class A extends JApplet {
    public void start() {
        JSObject window = JSObject.getWindow(this);
        JSObject document = (JSObject) window.getMember("document");
        document.call("writeln", new Object[] { "hello there" });
    }
}


Reproducible: Always

Steps to Reproduce:
1. Open http://mcc.id.au/temp/2007/LiveConnectDocumentWriteln/a.html .

Actual Results:  
Browser hangs.

Expected Results:  
Instead of hanging, the text "hello there" should replace the current document.
Component: General → Java: Live Connect
Product: Firefox → Core
QA Contact: general → live-connect
Version: unspecified → Trunk

Updated

11 years ago
Keywords: qawanted

Comment 1

11 years ago
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a7pre) Gecko/2007071605 Minefield/3.0a7pre

I'm testing on Windows XP, but this is what I experienced: the first time I loaded the page I got a really hard hang. My whole system froze and I couldn't even move my mouse. The page did finally load, though, and "hello there" was written. On subsequent page loads I didn't hang at all. After I restarted Firefox and tried again, I didn't hang either, so I think this may have just been the JVM loading.

However, I did experience a "hang" in the sense that the page never finished loading after "hello there" was written. The throbber kept going and the Stop button wasn't deactivated.

Do you hang every time you load the page or just on the first load? Also, what exactly do you mean by "hang"?
Keywords: qawanted
Hi Adam.

By "hang" I mean Firefox stopped responding (toolbar buttons don't "raise" when the mouse is moved over them, nothing responds to clicks, the window doesn't repaint etc.).  I've had the page open for about 10 minutes now and it is still hung.

I've attached the output of pressing Ctrl+\ at the terminal (dump of Java threads running), though it's maybe not useful.  You can see that the "thread applet-A.class" thread is stuck in one of Sun's LiveConnect classes, but it could well be that it has called back into Mozilla code.  What's the easiest way for me to get a stack trace of Mozilla code?
Created attachment 272573 [details]
Java thread dump while Mozilla is hung.
After having another look at that Java thread dump, I see that the "main" thread is doing plugin closing stuff, presumably because the document.write has removed the applet from the document.  Might there be a deadlock somewhere?

Comment 5

11 years ago
You could attach gdb to the hung process, but you won't get a useful stack unless you're using a debug build or a system-built version with a debug package.
Created attachment 272607 [details]
gdb backtrace while Mozilla is hung.

This is the gdb backtrace after I did a 'cvs up' and recompiled with debugging info.  It seems a SIGSEGV happens while in the Sun's Java plugin code.

Updated

8 years ago
Component: Java: Live Connect → Java: Live Connect
Product: Core → Core Graveyard

Comment 7

6 years ago
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
Last Resolved: 6 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.