Closed Bug 445714 Opened 16 years ago Closed 16 years ago

Firefox 3: Synchronous XmlHttpRequest is not really synchronous. (co-routine)

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 333198

People

(Reporter: ingokoch, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9) Gecko/2008052906 Firefox/3.0

Our web frontend framework uses a class loading mechanism
for its controls to decrease initial loading time.
Only if you hover over a control its corresponding javascript class
will be loaded (if it has not yet been loaded) from the server and an object will be created of it.
Our controls also inherit each other so it is necessary to recursively load
super classes from the server one after another.
This is done with a synchronous XMLHttpRequest which guaranteed us that user interaction
does not get lost while fetching the classes from the server. This means
that user interactions (browser events) would be processed AFTER this fetch cycle completes.

Firefox 3.0 has changed the behaviour of synchronous XMLHttpRequests completely.
A new mechanism called co-routine support (see bugzilla https://bugzilla.mozilla.org/show_bug.cgi?id=425988)
should have fixed a bug reported here https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=403535.
Unfortunately this new "feature" has not been documented yet.

The problem consisted of long running synchronous XMLHttpRequest causing to hang FF completely not letting
you select other tabs and so on until the response returned.
But the solution in FF3 does not fit the problem at all: a synchronous XMLHttpRequest can now be suspended
in favor of processing browser events which occur in the meantime.

This behaviour causes our class loading mechanism to fail under circumstances:

1. Classes would be loaded multiple times with XHR, since events occuring while the browser is fetching classes
cause the classloader to load the class again since the previous request has not returned and evaled the class yet.

2. The order of class loading (which is crucial to our inheritance chain) is no longer guaranteed.

3. If you reuse the XMLHttpRequest object, running request would be cancelled in favor of a more recent request.

To make a long story short: Synchronous XmlHttpRequests are no longer synchronous in FF3.

Reproducible: Always

Steps to Reproduce:
1. Open the URL mentioned above (and open the error console)
2. move the mouse very quickly over the red rectangle
(3. reload page to try again)

Actual Results:  
You can see that method1.js will be loaded multiple times.
If you move the mouse quick enough a JS error appears since the order
of XHRs is no longer guaranteed.

Expected Results:  
The page should load method1.js form the server one time and then load method2.js. Afterwards method1 should be executed which relies on method2.
Dup of bug 333198?  See bug 190313 for background and bug 326273 for the patch that likely changed the behavior.

Sync XHR is evil, IMO.  Don't use it :)
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: