firefox hangs for applets using JSObject.getWindow, strace shows EAGAIN repeatedly

Bug #331962 reported by Tim Abell
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
firefox-3.0 (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

Binary package hint: firefox

http://www.emapsite.com/ has a system called plans ahead which I am partly responsible for.
It uses a java applet to display mapping, and interacts with javascript on the surrounding page.
You have to log in to see the page, but it's a free registration.

Currently on my machine firefox hangs when launching plans ahead, leaving one of my cpus at 100%.
I get a grey box where the applet would be, and firefox stops rendering completely (dragging another window over firefox leaves a trail that never gets cleared up).

I was on jre 1.6.0_10, I tried updating to jre 1.6.0_12-b04 (the latest from sun), but didn't help.

It always used to worked with no issues on my ubuntu / firebox, and we haven't altered the applet for some time. I'm guessing what has changed is an update to firefox, though I'm not sure how long this has been happening.

I can attach the netbeans debugger to the java process (once I'd figured out how to do it), and the java threads all seem to be running without error. I think, but I'm not sure that the applet's init() method is stuck on a line that reads:
win = JSObject.getWindow(this);
which as I understand it is obtaining a reference for communication with firefox's javascript engine (liveconnect?).

Attaching strace with -p to the firefox process rapid and repeated output of exactly the following:
strace -p 18213
read(97, 0xbff2ae8c, 4) = -1 EAGAIN (Resource temporarily unavailable)
read(97, 0xbff2ae8c, 4) = -1 EAGAIN (Resource temporarily unavailable)
etc...

I'm not really sure what to make of this at the moment.
I'm guessing it's an obscure bug in ubuntu's build of firefox.

version info:
ff v3.0.6 - Installed: 3.0.6+nobinonly-0ubuntu0.8.10.1
Linux emap-eve-pctim 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux
Ubuntu 8.10
java jdk/jre 1.6.0_12-b04
LSB Version: core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:desktop-3.1-ia32:desktop-3.1-noarch:desktop-3.2-ia32:desktop-3.2-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:graphics-3.1-ia32:graphics-3.1-noarch:graphics-3.2-ia32:graphics-3.2-noarch:languages-3.2-ia32:languages-3.2-noarch:multimedia-3.2-ia32:multimedia-3.2-noarch:printing-3.2-ia32:printing-3.2-noarch:qt4-3.1-ia32:qt4-3.1-noarch

Revision history for this message
Micah Gersten (micahg) wrote :

Thank you for reporting this to Ubuntu. You reported this a while ago and we were wondering if you were still having an issue. Have you tried with the latest Firefox 3 and JRE? Which versions are you currently running?

affects: firefox (Ubuntu) → firefox-3.0 (Ubuntu)
Changed in firefox-3.0 (Ubuntu):
status: New → Incomplete
Revision history for this message
Tim Abell (tim-abell) wrote :

yep still happening.
just installed Java(TM) Plug-in 1.6.0_14-b08 direct from sun

$ apt-cache policy firefox
firefox:
  Installed: 3.0.11+build2+nobinonly-0ubuntu0.9.04.1
  Candidate: 3.0.11+build2+nobinonly-0ubuntu0.9.04.1
  Version table:
 *** 3.0.11+build2+nobinonly-0ubuntu0.9.04.1 0
        500 http://gb.archive.ubuntu.com jaunty-updates/main Packages
        500 http://security.ubuntu.com jaunty-security/main Packages
        100 /var/lib/dpkg/status
     3.0.8+nobinonly-0ubuntu3 0
        500 http://gb.archive.ubuntu.com jaunty/main Packages

Revision history for this message
Micah Gersten (micahg) wrote :

Thank you. Would it be possible to uninstall the version from Sun and test with the version in the Jaunty repos?

Revision history for this message
Tim Abell (tim-abell) wrote :

i switched to Java(TM) Plug-in 1.6.0_13-b03 provided by...
$ apt-cache policy sun-java6-bin
sun-java6-bin:
  Installed: 6-13-1
  Candidate: 6-13-1
  Version table:
 *** 6-13-1 0
        500 http://gb.archive.ubuntu.com jaunty/multiverse Packages
        100 /var/lib/dpkg/status

I also moved my ~/.mozilla folder out of the way to get a clean session, and tried disabling all other plugins except the java one.

I don't know if it matters but the numbers emitted by strace vary each time I launch firefox get stuck and try again, eg:
read(79, 0xbfaa2920, 4) = -1 EAGAIN (Resource temporarily unavailable)
read(79, 0xbfaa2920, 4) = -1 EAGAIN (Resource temporarily unavailable)
or
read(65, 0xbfa87b60, 4) = -1 EAGAIN (Resource temporarily unavailable)
read(65, 0xbfa87b60, 4) = -1 EAGAIN (Resource temporarily unavailable)

I did attach gdb to firefox to try and get more info, but haven't got very far yet.
ps -A | grep firefox
gdb --pid 9812

Revision history for this message
Tim Abell (tim-abell) wrote :
Revision history for this message
willsteel (michael-willigens) wrote :

Hey guys, I found a solution.

First of all,
I had exactly the same issue on >some< of my machines. Even though i dont use ubuntu everywhere, so this is a general problem. If a machine did so, it did so all the time and it was 100% reproduceable. If a mchine did not it never ever happened. It does not even matter which firefox or JRE was installed.

So this got really annoying to me because I am currently developing a website which makes extensive use of Java-Javascript communication. More randomly I tried running JSObject.getWindow or window.call(...) in a seperate Thread. This means not Firefox JREs main Thread which calls JApplet.init() and JApllet.start() etc. This is a ugly hack but working solution in my case.

So however you dont have to make any call to JSObject in a seperate Thread and you dont even have to implement something like a event queue for this. You just have to MAKE SURE the initial calls to JSObject class are NOT done from JREs MAIN THEREAD which invikes init() and start(). So it could look like that (free written, dont copy and paste):

<...imports...>
public class MyApplet extends JApplet{

   JSObject window = null;

   public void init(){
      // we do our init stuff here but i recomment to do first getWindow in start function.
      // looks lees painful for other buggy browser implementations. however,
      // it also can be done here.
   }

   public void start(){
      final MyApplet instance = this;
      new Thread(){
         public void run(){
            window = JSObject.getWindow(instance);
            window.call("some initial call here, if needed");
         }
      }.start();
   }

}

I hope this helps. Interestingly this problems occoured on many machines and OS independently, the community has not figured out that bug yet. This thread here is the only helpful i found on the net.

regards,
michael

Revision history for this message
Tim Abell (tim-abell) wrote :

Thanks for your code willsteel, much appreciated, I haven't had a chance to try it yet.

Just for reference I get the same issue on my latest rebuild of my machine, this time under SuSe

cat /etc/issue
Welcome to openSUSE 11.1 - Kernel \r (\l).

uname -a
Linux chad 2.6.27.29-0.1-pae #1 SMP 2009-08-15 17:53:59 +0200 i686 i686 i386 GNU/Linux

Tim Abell (tim-abell)
summary: - firefox hangs for emapsite applet, strace shows EAGAIN repeatedly
+ firefox hangs for applets using JSObject.getWindow, strace shows EAGAIN
+ repeatedly
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for firefox-3.0 (Ubuntu) because there has been no activity for 60 days.]

Changed in firefox-3.0 (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.