Closed Bug 1956486 Opened 10 months ago Closed 9 months ago

Teach SharedStyleSheetCache (or so) to share inline styles

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

(Blocks 1 open bug, Regressed 2 open bugs)

Details

Attachments

(5 files)

See bug 1928800 for something that would benefit for this (but in general maybe we can do it regardless).

Tricky thing is that the base URI is different for different pages, so we need to check for that, or for the sheet not having relative URIs...

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)

So I think we should do this because bug 1928800 and co look a lot better with this.

I found a few legit bugs that needed fixing are are easy to fix. I found one which is just rather annoying to fix tho, and it's (mostly) pre-existing.

The test is security/manager/ssl/tests/mochitest/mixedcontent/test_cssBefore1.html (well, and test_cssContent1.html, but basically the same). It tests that the mixed content flag show before and after navigation.

The issue is that now the sheet is cached, which means that we don't do the second image request on navigation. This is expected, but that doesn't update the UI state. The issue is already present there if you use a <link rel=stylesheet> rather than an inline stylesheet...

Tom, Freddy, how much do we care about mixed-content warnings nowadays? Should I dig into how to potentially fix this? It's.. not easy, because we somewhat aggressively cache these requests. I can of course do something hacky like "if there are http uris, don't put the sheet in the cache", but that's just lame.

Flags: needinfo?(tschuster)
Flags: needinfo?(fbraun)
Flags: needinfo?(emilio)
Depends on: 1957489
Depends on: 1957490

I think with the work on HTTPS-First and Only we care about the mixed content blocker a lot less. If it's already broken for external stylesheets and blocking performance work I wouldn't bother.

Flags: needinfo?(tschuster)

Thanks.

Flags: needinfo?(fbraun)

Network override needs this already for <link>, the test was using
@import to bypass the usual caching.

browser_resources_css_messages.js needs to clear the cache as well now
that reloading might not reparse the stylesheet.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

As per the comments in the bug, this is already broken for <link
rel=stylesheet>. The issue is that we don't re-trigger the image request
now, as we cache the whole stylesheet.

An alternative would be to use a CSS variable or so to bypass the style
resource caching, lmk if you want me to do that instead.

Without this tests like layout/reftests/svg/as-image/context-fill-*.html
fail, because they test both pref-on and pref-off on the same
stylesheet.

Two tweaks:

  • Use variables for tests that rely on background images triggering a
    load that had otherwise been cached already.
    printpreview_images_sw.html use serviceworkers, and
    visited_image_loading_frame.html uses a server script to watch the
    loads.

  • Add a null-check for test_rules_out_of_sheets. Now we hit this early
    return in appendRule1. The no-sheet case was what this test was
    intending to hit anyways, so it was just by chance it didn't before
    (because the sheet was kept alive by Loader::mInlineSheets, but with
    the new cache we shallow-clone it).

Attachment #9474732 - Attachment description: WIP: Bug 1956486 - Teach SharedStyleSheetCache to share inline styles. → Bug 1956486 - Teach SharedStyleSheetCache to share inline styles. r=#style,#layout
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3a5f93fe4f7f Fix some devtools tests with inline stylesheet caching. r=devtools-reviewers,jdescottes
Keywords: leave-open
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5220e96009bb Make reftest harness clear stylesheet cache on pref changes. r=layout-reviewers,tnikkel
See Also: → 1961455
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9a66f0a0cfa9 Tweak a few tests to work regardless of whether inline stylesheets are cached. r=jwatt
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2d1fa8be32fd Teach SharedStyleSheetCache to share inline styles. r=jwatt https://hg.mozilla.org/integration/autoland/rev/8042121f2dce Annotate some mixed content tests as failing after navigation. r=tschuster
Regressions: 1963135
Regressions: 1963139
Regressions: 1963212
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
No longer regressions: 1963135
Regressions: 1964592

1.5%-2% improvement on tp5o suite (much more noticeable on Linux):

17% on ifeng.com
14% on https://www.uol.com.br/
12.2% on homeway.com.cn

Target Milestone: --- → 140 Branch

Lead to a 4KB improvement on a image-memory subtet on AWSY

QA Whiteboard: [qa-triage-done-c141/b140]
Regressions: 1978217
Regressions: 1978555
Depends on: 1982344
No longer depends on: 1982344
Regressions: 1982344
Regressions: 1986332
Regressions: 1988195
Regressions: 2007841
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: