Open
Bug 907564
Opened 12 years ago
Updated 3 years ago
CSS sheet preloading shouldn't trigger sheet cloning
Categories
(Core :: CSS Parsing and Computation, defect)
Core
CSS Parsing and Computation
Tracking
()
NEW
People
(Reporter: dbaron, Unassigned)
References
Details
(Keywords: memory-footprint, perf)
The way we currently do preloading of CSS style sheets can easily trigger the sheet cloning codepath when use of that codepath (and the extra time and memory) is logically unnecessary.
Basicaly, CSS style sheets (nsCSSStyleSheet) implement copy-on-write cloning, so that we can clone a sheet and have two logical sheets pointing at the same inner until one or the other is mutated or its OM is accessed in a way that might lead to a harder-to-detect mutation (we call EnsureUniqueInner at various points).
We use cloning for style sheet preloading (bug 457810). That is, when we kick off "optimistic" style sheet loads from lookahead in the HTML parser (because sometimes, due to scripts, we have markup but we can't yet construct the elements for that markup that would kick off the load in the normal way until the scripts load and run), we use the same multiple-stylesheet-loading management to deal with loading the same style sheet URL twice for the preload and the normal load. This means that if we touch the CSSOM prior to dropping the preload copy (which is pretty easy because it seems to require a **cycle collection** to get rid of that preload copy) we end up paying the extra cost of duplicating the entire sheet.
We should fix this either (preferably, since it seems more likely to be reliable) so that the preloading mechanism transfers ownership of an nsCSSStyleSheet object or so that it ensures the duplicate nsCSSStyleSheet (with a shared inner) gets *destroyed* much sooner.
Comment 1•12 years ago
|
||
So what we would need here is, I think, to add API to the CSSLoader to do explicit preloads, to store those preloads in a separate hashtable (possibly in addition to the existing loading/complete tables) and then to somehow steal the sheet (and update its owner element, etc) from the preload...
| Reporter | ||
Comment 2•11 years ago
|
||
This bug was filed as a result of discussion in bug 893308, fwiw.
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•