I have been suffering recently from a browser crash in IE6 on some
machines in the estate that I am deploying a GWT application to. I
have found a solution to the problem and thought that I would share it
here so that others can benefit from the (painful) investigation I
have been through.
Firstly the browser crash was determined to be related to an old
version of the JSCRIPT.DLL (IE's JavaScript interpreter) library
5.6.0.8820 as described here:
http://www.telerik.com/support/kb/article/b454K-tge-b454T-ceh-b454c-ceh.aspx
Upgrading to 5.6.0.8831 from this MS bulletin fixes the problem:
http://www.microsoft.com/technet/security/bulletin/ms06-023.mspx
The MS upgrade is the obvious solution however in my case it was not
possible to upgrade all machines in the estate or even to determine
the number of machines with the problem. As a result I had to debug
GWT and find out where the code was that triggered this JSCRIPT.DLL
flaw.
After debugging I found that the problem was caused by a GWT-RPC call;
the call succeeds but IE crashes after the load when it does some sort
of clean up. The root cause of the problem exists in the
HTTPRequestImpl class within the asyncGetImpl and asyncPostImpl
methods.
Each of these methods implement the standard Ajax onreadystatechange
callback as:
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
xmlHttp.onreadystatechange =
@com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc;
handler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/
lang/String;)(xmlHttp.responseText || "");
}
};
I found that the IE6 crash goes away if you comment out the setting of
the onreadystatechange callback to nullFunc, i.e.:
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
//xmlHttp.onreadystatechange =
@com.google.gwt.user.client.impl.HTTPRequestImpl::nullFunc;
handler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/
lang/String;)(xmlHttp.responseText || "");
}
};
It seems that the JSCRIPT.DLL flaw must be somehow related to
reassigning the callback while executing the function... who knows...
another IE flaw.
I patched the gwt-user.jar with these lines commented out, recompiled,
and the browser did not crash when performing my GWT-RPC calls,
woohoo!
I don't know the consequences of commenting out the setting of
onreadystatechange to a null function. Perhaps the GWT team can
comment and suggest whether this is necessary, does the readystate ==
4 event happen many times?
If so could the code be changed to do something like below and become
"compatible" with this IE flaw:
var handlerCalled = false;
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (!handlerCalled) {
handlerCalled = true;
handler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/
lang/String;)(xmlHttp.responseText || "");
}
}
};