7 Replies Latest reply: Jun 9, 2011 8:29 AM by user10101058 RSS

    Applets that take more than 10-20s for init() are killed by Plugin2

    user12866708
      Hi,

      We've an applet which takes quite a long time in init() (5-20s depending on the cpu speed and network connection), to load tons of classes, sync state with server and so on.

      However with plugin2 the applet is killed if it takes more than 10-20s in init(), any idea whats going on here?
      By killed I mean its simply not loaded, and if the java-console was open it automatically closes.
      Is that intentional? How can this problem be worked arround?

      Thank you in advance, Clemens Eisserer
        • 1. Re: Applets that take more than 10-20s for init() are killed by Plugin2
          793415
          I doubt your assessment of the problem. Do you have an URL where we can test it ourselves?

          BTW - one 'hackish' way around a long <tt>init()</tt> is to move most of the code to <tt>start()</tt>, but only run it according to a <tt>boolean</tt> flag named something like <tt>runOnce</tt>.
          • 2. Re: Applets that take more than 10-20s for init() are killed by Plugin2
            user12866708
            Hi,
            Andrew Thompson wrote:
            I doubt your assessment of the problem. Do you have an URL where we can test it ourselves?
            Sure: http://fbl.sfc-ried.at/HtmlApplet.html
            Code of the Applet is attached.

            Works perfectly with the old Plugin as well as the open-source plugin supplied with Fedora-14, but the new Plugin terminates the loading process somewhere in between (even the open java console is closed.

            It also demonstrates another bug, where Html-components aren't displayed when navigation was used: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7032814
            Andrew Thompson wrote:
            BTW - one 'hackish' way around a long init() is to move most of the code to start(), but only run it according to a boolean flag named something like runOnce.
            Wasn't the new plugin ment to solve all those hacks ;)
            public class HtmlApplet extends Applet {
                public void init() {
                 setLayout(new BorderLayout());
                 add(new JLabel("Label with plain text works always"), BorderLayout.NORTH);
                 
                 JLabel label = new JLabel("<html><body><FONT COLOR=\"#0000ff\">  blablabalbla </FONT></body></html>");
                 System.out.println(label.getPreferredSize());
                 
                 Object o = label.getClientProperty("html");
                 System.out.println(o);
                 System.out.println(o.getClass());
                 
                 add(label, BorderLayout.CENTER);
                 
                 try {
                     Thread.sleep(20000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
                }
            }
            Edited by: user12866708 on 14.04.2011 13:32
            • 4. Re: Applets that take more than 10-20s for init() are killed by Plugin2
              793415
              I did not experience the exact problem you described re the plugin2 (a) bail-out. However you might approach that by pursuing the strategy I outlined earlier, in addition to lazy loading of application resources using the abilities provided via. Java Web Start (after all, we're dealing with the plugin2, which can embed JWS applets, so use all the resources available).

              As to the problem with HTML not rendering on applet refresh, try the work-around shown on the end of bug ID: 7001786.

              a) Sure the plugin2 was intended to iron out a lot of problems, and did just that, while also introducing one or two new problems ("all known bugs have been fixed, replaced by unknown bugs"). After all, we are referring to the ever quirky and difficult applets - expect the unexpected.
              • 5. Re: Applets that take more than 10-20s for init() are killed by Plugin2
                user12866708
                Ok, I see the problem in production on machines running windows right now - however only with FireFox, with Google Chrome everything works as expected.

                I'll file a bug about that.
                • 6. Re: Applets that take more than 10-20s for init() are killed by Plugin2
                  user12866708
                  According to mozilla this behaviour is intentional, a plugin shouldn't block the input thread for such a long time:

                  https://bugzilla.mozilla.org/show_bug.cgi?id=653920
                  • 7. Re: Applets that take more than 10-20s for init() are killed by Plugin2
                    user10101058
                    Just curious: would it make sense to use a SwingWorker or an equivalent approach in init()?