JDK-5044757 : LiveConnect issue hangs Internet Explorer
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-05-10
  • Updated: 2004-05-25
  • Resolved: 2004-05-18
Related Reports
Duplicate :  
Description
Name: gm110360			Date: 05/10/2004


FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

and

java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

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

A DESCRIPTION OF THE PROBLEM :
Internet Explorer hangs when relatively complex Java/JavaScript communication is taking place. The issue begins with Java calling a JavaScript function, passing a reference to a Java object. The JavaScript function calls a method on the Java object. The Java method then calls another JavaScript function. This JavaScript function then updates an HTML element.

This functionality works until an alert box is opened. If the process described above occurs whilst the alert box is open the browser becomes non-responsive, and the alert cannot be dismissed.

This problem appears to have been introduced in versions 1.4.2_04 and 1.5.0-beta. It was not an issue in 1.4.2_03, or any versions prior to this (back to 1.4.1_01).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Load the web page (HTML provided).

2. Wait for the page to finish loading - this will be indicated by the "Loading..." text being replaced by "JSFunction called: 0".

3. Press the "Open Alert" button, then leave the page for a few seconds (enough time for the next update to have been sent into JavaScript).

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The updates should keep being processed by the client and displayed on screen whilst the alert box is visible.

Furthermore, the end user can dismiss the alert box at anytime by pressing the OK button, or clicking the X to close it.
ACTUAL -
The updates stop being displayed.

The alert box cannot be dismissed. Any attempt to do so results in the browser becoming non-responsive and the CPU jumps up to 100%.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Java code:

import java.applet.Applet;

import netscape.javascript.JSObject;

public class DeadLockApplet extends Applet
{
	public void start()
	{
		new Thread() {
			public void run()
			{
				final Counter counter = new Counter();
				boolean exit = false;
				while (!exit)
				{
					// call the JavaScript function JSFunctionCall every 2 seconds
					try
					{
						Thread.sleep(2000);
						JSObject.getWindow(DeadLockApplet.this).call("JSWrapper", new Object[] { counter });
					}
					catch (InterruptedException e)
					{
						exit = true;
					}
				}
			}
		}.run();
	}
	
	public class Counter
	{
		private int count = 0;
		
		public void updateCount()
		{
			JSObject.getWindow(DeadLockApplet.this).call("JSFunctionCall", new Object[] { new Integer(count++) });
		}
	}
}



Web page code:

<html>

<head>
	<title>Sun VM Issue</title>
	
	<script language="JavaScript">
	function JSFunctionCall(nCount)
	{
		var oCounter = document.getElementById("spnCounter");
		if (oCounter != null)
		{
			oCounter.innerText = "JSFunctionCall called: " + nCount;
		}
	}

	function JSWrapper(oCounter)
	{
		oCounter.updateCount();
	}
	</script>
</head>

<body>
	<span id="spnCounter">Loading...</span>
   
	<br><br><br>
	
	<input type="button" onclick="alert('Alert!\n\nLeave this open for a few seconds and the browser will hang.');" value="Open Alert">
	
	<br><br><br>

	<applet mayscript codebase="." code="DeadLockApplet.class"></applet>
</body>

</html>
---------- END SOURCE ----------
(Incident Review ID: 260033) 
======================================================================