Closed Bug 1646776 Opened 4 years ago Closed 4 years ago

https://webxr.today fails to reload (because of <link rel=preload> not firing load events when in the stylesheet cache).

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox-esr68 --- unaffected
firefox-esr78 --- unaffected
firefox77 --- unaffected
firefox78 --- unaffected
firefox79 --- fixed

People

(Reporter: rbarker, Assigned: emilio)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression, Whiteboard: [necko-triaged][fxr:p1], [wptsync upstream])

Attachments

(8 files, 1 obsolete file)

STR:

  1. Visit https://webxr.today
  2. Reload the page

Expected
Page is reloaded

Actual:
Page is broken

Reloading the page worked in GV Nightly 79.0.20200615092624 and is broken in 79.0.20200616092900

Has Regression Range: --- → yes
Has STR: --- → yes
Whiteboard: [fxr:p1]

This is a ship blocker for FxR.

Randall, does it reproduce in Desktop by chance?

Flags: needinfo?(rbarker)
Regressed by: 1644424

ni? to take a look at the regression

Not very plausible that this was regressed by my patch, as that pertains to wasm SIMD only, but I'm investigating.

Flags: needinfo?(lhansen)

There's both script and CSS involved, though off-hand it seems a bit more likely to be a regression from my changes. Randal, can you double-check the regression range?

There's a:

<link rel="preload" href="/css/index.css" as="style" onload="this.onload=null;this.rel='stylesheet'">

whose load event is not firing. That smells a lot like something my change could've plausibly caused :)

As far as I can tell, the page remains broken with both wasm SIMD disabled and the optimizing compiler disabled that was affected by that patch, and has no wasm content. So this looks increasingly unlikely to me to be the problem.

Moderately sure this is bug 1599160 then. I'll take a look.

Assignee: nobody → emilio
Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Regressed by: 1599160
No longer regressed by: 1644424

I can run it again. I find the mozregression GUI UI to be confusing.

Flags: needinfo?(emilio)

I think this exposes an existing issue with our preload implementation.

Summary: https://webxr.today fails to reload → https://webxr.today fails to reload (because of <link rel=preload> not firing load events when in the stylesheet cache).
Comment on attachment 9157741 [details] Test-case that shows that this is also an issue for images. Ah, nevermind, this is not true, I was not testing from http, so I was not preloading to begin with. It seems Chrome preloads from `file://` uris. Honza do you know what's up with that? Is that difference tracked anywhere?
Attachment #9157741 - Attachment is obsolete: true
Flags: needinfo?(honzab.moz)

So, the issue is that if we don't ever create a PreloaderBase for a given preload we'll fire an error event for that node... Though when we hit the stylesheet cache we don't create an StreamLoader.

Honza, we could do multiple things to fix this I think...

  • Maybe we don't even need the PreloaderBase machinery for stylesheets, and we can just use the regular css::Loader machinery, which already can take care of firing load / error events for <link rel=stylesheet>... Though that changes the event we fire in the case of bogus @imports, to match what <link rel=stylesheet> does... Perhaps that's not bad?

  • Otherwise, I think the thing that should inherit from PreloaderBase might want to be SheetLoadData, perhaps?

(Or even StyleSheet, but not a fan of bloating them even more)

Component: General → DOM: Networking
Product: GeckoView → Core

This is just cleanup while I was going through this code.

This makes it easy to see why your test is not failing without your
patch, for example ;)

Note that we log only when the URIs differ, which I think is a
reasonable compromise in verbosity.

Depends on D80287

When we hit the stylesheet cache for an existing stylesheet in a
different document:

  • There's no existing preload in the PreloadService (because the sheet
    was loaded in another document).

  • We don't create a PreloaderBase (because we don't trigger a load at
    all).

  • And thus we believe the load has just errored, which is wrong...

Fix it by properly passing through the "already complete" status from
PreloadStyle.

Note that there's still another issue, which is that we'd still hit this
broken path if two stylesheets with the same URI are loading in
different documents and the CSS loader coalesces them.

For that, I think we'd have to make SheetLoadData the thing that
actually implements PreloaderBase. This is kind of an obscure case, and
SheetLoadData has a pretty complex lifetime already (keeps alive a whole
lot of stuff), so I'd prefer to do this in a separate bug.

Depends on D80288

Ok, so... Sent a necessary fix that fixes this. I'll spin off the PreloaderBase change, if Honza agrees, to another bug.

Flags: needinfo?(honzab.moz)
Flags: needinfo?(emilio)

This shouldn't have any behavior change, but it makes the code make a
bit more sense. Rather than counting inline stylesheets like a pending
load, we won't (but note that any @import inside it will).

The SheetLoadData::mURL it's supposed to be the url of the stylesheet,
so for StyleSheet::Replace it should be null.

Depends on D80289

So as to make sense in a world where we can coalesce loads across
documents. The per-load object is the SheetLoadData, so this way we
guarantee that we fire the right events in presence of the load
coalescing that the SharedStyleSheetCache does.

Depends on D80379

Severity: -- → S3
Priority: -- → P2
Whiteboard: [fxr:p1] → [necko-triaged][fxr:p1]
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6bcac6d68384 Clean up HTMLLinkElement::CheckPreloadAttrs. r=smaug https://hg.mozilla.org/integration/autoland/rev/0be160e4f5ae Add some logging for sheet cache misses for the same URI. r=heycam
Keywords: leave-open
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5855c8067f8d Make sure to fire load rather than error events for preload links that hit the CSS cache. r=mayhemer
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/24291 for changes under testing/web-platform/tests
Whiteboard: [necko-triaged][fxr:p1] → [necko-triaged][fxr:p1], [wptsync upstream]
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e847c2e2c84e Don't set an URL for pending constructable stylesheet parses. r=heycam https://hg.mozilla.org/integration/autoland/rev/be056dc9e0f1 Move the preloader for stylesheets to SheetLoadData rather than StreamLoader. r=mayhemer
Keywords: leave-open
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: