JDK-5070050 : Calling JavaScript to Applet to another Applet to other JavaScript hangs IE
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-06-30
  • Updated: 2005-01-21
  • Resolved: 2004-09-25
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 06/30/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java Hotspot (TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
A call from JavaScript (say an action into a form) to an applet, which then calls a second applet (getting it via the AppletContext), which then calls any JavaScript function (via JSObject.getWindow(this).call )  causes iexplore.exe to hang, consuming 99% cpu time forever.

This happens even when the final JS function that is being called is something as trivial as "alert".

This is a problem for us (we are building an intelligent tutoring system we intend to deploy to 1st year undergrads, that uses multiple applets interoperating, and updating a message area on the page via JavaScript).  At present, this will hang IE every time.

Using IE with JRE 1.4.2, the attached test case works, so this appears to be a problem with the new plugin.  (Unfortunately, our system will need 1.5 for various reasons, so using 1.4.2 is not an option)



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A webpage with a button on it.  This button uses JavaScript to call a public method on an applet.  This first applet calls a public method on a second applet on the same page and in the same applet context etc.  The second applet calls another JavaScript function on the page (eg. alert).  The browser will hang.

Note, if you just call JS -> applet -> JS, that's ok.  It is JS -> applet -> another applet -> JS that fails.

Java code and HTML to reproduce this are provided in the Source Code form field.  The same applet and HTML are online at http://www.cl.cam.ac.uk/~whb21/research/circuitTutor/interaction/testing/JS_applet_applet_JS.html

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JavaScript should be executed.  (In the test case in the Source Code field, pressing the button should cause an alert box to pop up saying "the alert")
ACTUAL -
Internet Explorer hangs.  According to Task Manager, iexplore.exe remains using 99% cpu time permanently.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The following applet code, and the HTML page that follows it.  Press the submit button, and it hangs.  ( this is online at http://www.cl.cam.ac.uk/~whb21/research/circuitTutor/interaction/testing/JS_applet_applet_JS.html )

---

import java.applet.Applet;
/*
 * Created on 29-Jun-2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import netscape.javascript.*;

/**
 * This test applet is to test JS to applet to applet to JS calls,
 * which appear to cause an infinite loop in Internet Explorer.
 *
 * @author William Billingsley
 *
 */
public class Forwarder extends Applet {

	public void doAlert() {
		String forwardTo = this.getParameter("forwardTo");
		if (forwardTo != null && !forwardTo.equals("")) {
			Forwarder f = (Forwarder)this.getAppletContext().getApplet(forwardTo);
			System.out.println("forwarding to " + forwardTo);
			f.doAlert();
		} else {
			Object[] o = { "the alert" };
			System.out.println("doing alert");
			JSObject.getWindow(this).call("alert", o);
		}
	}
}

---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
    Document   : forward_test
    Created on : 14 June 2004
    Author     : Will Billingsley
    Description:
		Tests a JS call into an applet, calling an applet, calling a JS function
-->

<html>
    <head>
    <meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1252" />
	<title>JS to applet to applet to JS test page</title>
	<meta name="AUTHOR" content="William Billingsley" />
	<meta name="CHANGEDBY" content="William Billingsley" />
    </head>
    <body onload="JSIA_start();">
	    <script type="text/javascript" src="jsia.js"></script>
		
	<h1>JS to applet to applet to JS test page</h1>
	
	<applet code="Forwarder" name="f1" id="f1"
		style="height: 1px; width: 1px; position: absolute; top: 0px;"
		version="1.5.0"
		MAYSCRIPT
	>
		<param name="forwardTo" value="f2" />
	</applet>

	<applet code="Forwarder"
		name="f2" id="f2"
		style="height: 1px; width: 1px; position: absolute; top: 0px;"
		version="1.5.0"
		MAYSCRIPT
	>
	</applet>

<form action="javascript: { document.getElementById('f1').doAlert(); }">
	<input type="submit" />
</form>

</body>
</html>

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Works in Mozilla or Opera.  But getting this working in IE is a requirement for us.
(Incident Review ID: 281925) 
======================================================================

Comments
EVALUATION When one applet is making JS->Java call, JS call from another applet is not allowed in 1.4.2 and 1.5, we will try to address this in mustang ###@###.### 2004-07-13 This is the same as 5077565 whose fix is available in J2SE 1.4.2_07, 5.0u1, and the upcoming Mustang. ###@###.### 2005-1-21 18:49:32 GMT
13-07-2004