Closed Bug 1940828 Opened 8 months ago Closed 6 months ago

Firing a non-asynchronous XMLHttpRequest in an asynchronous script causes parsing to hang

Categories

(Core :: DOM: Networking, defect, P2)

Firefox 133
defect

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: wbiggs1, Assigned: hsivonen)

References

Details

(Whiteboard: [necko-triaged])

Attachments

(3 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0

Steps to reproduce:

Have a large HTML file that loads in a script asynchronously.

In that script, make an XHR request synchronously (passing in false for the async argument). It does not matter if that XHR request succeeds or not.

I created a minimum reproducible example: https://github.com/w-biggs/firefox-bug/

The HTML is larger than it really needs to be to reproduce the issue, but it's large enough that it reproduces it very consistently. Much smaller-sized pages will still have this issue sporadically.

Actual results:

The page stops being parsed before the end of the HTML, causing part of the HTML to never get rendered, and Firefox keeps the page in a "loading" state indefinitely. (It will very occasionally parse the whole file before the XHR request fires; doing a hard refresh or disabling cache makes that less likely in my experience.)

This happens despite the fact that the XHR request has completed successfully. (In the network tab, the XHR request shows as completed.)

Expected results:

The page completes parsing, all HTML is rendered, and it doesn't act as if page is still loading indefinitely. This is what happens in other browsers (Chrome, Safari)

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Networking' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Networking
Product: Firefox → Core

I tried to do a binary search to find which version of Firefox is the earliest to have this issue but it seems to have existed at least as far back as version 58 (the earliest version that doesn't render as a completely transparent window on my Mac). I'll try later on a Windows machine to see if I can narrow it down any further.

See Also: → 1938290

I've put my MRE up on Github Pages so it's easier to test: https://w-biggs.github.io/github-pages/firefox-bug/

Mozregression on Windows narrows the introduction down to a build between the 2023-01-11 and 2023-01-12 builds. I am able to reproduce some version of the issue on Mac as far back as version 58 but it seems to only occur after a hard refresh, so it may be unrelated.

See Also: → 1940997

Based on the description and mozregression output this seems to be a duplicate of bug 1899786.
Randell, this test case seems rather simple. Would you like to include it in bug 1899786?

Status: UNCONFIRMED → RESOLVED
Closed: 8 months ago
Duplicate of bug: 1899786
Flags: needinfo?(rjesup)
Resolution: --- → DUPLICATE

The test case is comparable to https://bugzilla.mozilla.org/show_bug.cgi?id=1899786#c16 : start a sync XHR request before a document load completes.

In the STR I provided before, compression was a requirement for reproduction. It is not clear from this description whether the PoC also involved compression.

The response for https://w-biggs.github.io/github-pages/firefox-bug/ does have content-encoding: gzip
Interestingly, I'm having trouble reproducing from a local copy with npx http-server . -p 8123 -g

I seem to be getting the same behavior regardless of whether a gzip page is being served. Here it is with gzip enabled...

...and here it is with gzip disabled. (The difference in how far the parsing gets before it stops is pretty much due to random chance.)

If decompression isn't involved, then it's probably not the same.

Status: RESOLVED → REOPENED
No longer duplicate of bug: 1899786
Ever confirmed: true
Resolution: DUPLICATE → ---
Flags: needinfo?(rjesup)

The severity field is not set for this bug.
:edgul, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(edgul)

Bug 1899786 has been resolved. Can you still reproduce the problem (without compression)?

Flags: needinfo?(wbiggs1)
Flags: needinfo?(edgul)

I'm still seeing this issue with the latest Firefox Nightly (137.0a1) with or without compression.

Flags: needinfo?(wbiggs1)

This is a duplicate of bug 1938290, right?

(In reply to Henri Sivonen (:hsivonen) from comment #14)

This is a duplicate of bug 1938290, right?

I suppose this could be left open for the XML case, if I fix only the HTML case in bug 1938290.

Attachment #9465400 - Attachment description: WIP: Bug 1940828 - Make XML parsing not hang when an async script uses sync XHR. → Bug 1940828 - Make XML parsing not hang when an async script uses sync XHR.
Assignee: nobody → hsivonen
Severity: -- → S3
Status: REOPENED → ASSIGNED
Priority: -- → P2
Whiteboard: [necko-triaged]
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e8e2e6ead697 Make XML parsing not hang when an async script uses sync XHR. r=peterv,smaug,jesup
Status: ASSIGNED → RESOLVED
Closed: 8 months ago6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: