stylo: stop updating the stylist during PresShell destruction

RESOLVED FIXED

Status

()

Core
CSS Parsing and Computation
P3
normal
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: heycam, Assigned: u459114)

Tracking

(Blocks: 2 bugs)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

a year ago
I noticed that when the PresShell for a document is being destroyed, we end up doing wasted work in re-building selector maps in response to the pref style sheet being removed.

    #0  DynamicAtom::AddRef (this=0x7f5ba9554670) at /z/moz/d/xpcom/ds/nsAtomTable.cpp:454
    #1  0x00007f5bd6963864 in Gecko_AddRefAtom (aAtom=0x7f5ba9554670) at /z/moz/d/layout/style/ServoBindings.cpp:743
    #2  0x00007f5bda2ef06c in style::gecko_string_cache::{{impl}}::from (ptr=0x7f5ba9554670) at /z/moz/d/servo/components/style/gecko_string_cache/mod.rs:293
    #3  0x00007f5bda3515a8 in style::gecko_string_cache::{{impl}}::clone (self=<optimized out>) at /z/moz/d/servo/components/style/gecko_string_cache/mod.rs:218
    #4  style::stylist::SelectorMap::get_id_name (rule=0x7ffc9f016b30) at /z/moz/d/servo/components/style/stylist.rs:1086
    #5  0x00007f5bda351131 in style::stylist::SelectorMap::insert (self=0x7f5bbc2a5440, rule=...) at /z/moz/d/servo/components/style/stylist.rs:1061
    #6  0x00007f5bda34c536 in style::stylist::{{impl}}::add_stylesheet::{{closure}} (rule=0x7f5ba267c380) at /z/moz/d/servo/components/style/stylist.rs:250
    #7  0x00007f5bda356429 in style::stylesheets::effective_rules<closure> (rules=..., device=0x7f5bbc3a5c50, f=0x7ffc9f017310) at /z/moz/d/servo/components/style/stylesheets.rs:748
    #8  0x00007f5bda3560f7 in style::stylesheets::Stylesheet::effective_rules<closure> (self=0x7f5ba97c4130, device=0x7f5bbc3a5c50, f=...) at /z/moz/d/servo/components/style/stylesheets.rs:725
    #9  0x00007f5bda34c197 in style::stylist::Stylist::add_stylesheet (self=0x7f5bbc2a5410, stylesheet=0x7f5ba97c4130) at /z/moz/d/servo/components/style/stylist.rs:236
    #10 0x00007f5bda34b633 in style::stylist::Stylist::update (self=0x7f5bbc2a5410, doc_stylesheets=..., ua_stylesheets=..., stylesheets_changed=true) at /z/moz/d/servo/components/style/stylist.rs:204
    #11 0x00007f5bda30b46f in style::gecko::data::PerDocumentStyleDataImpl::flush_stylesheets (self=0x7f5bab2b8ec8) at /z/moz/d/servo/components/style/gecko/data.rs:99
    #12 0x00007f5bd9ed4398 in geckoservo::glue::Servo_StyleSet_RemoveStyleSheet (raw_data=0x7f5bab2b8ec0, raw_sheet=0x7f5bc1996630, flush=true) at /z/moz/d/servo/ports/geckolib/glue.rs:478
    #13 0x00007f5bd698726b in mozilla::ServoStyleSet::RemoveStyleSheet (this=0x7f5ba708b500, aType=mozilla::SheetType::User, aSheet=0x7f5bc1d852c0) at /z/moz/d/layout/style/ServoStyleSet.cpp:461
    #14 0x00007f5bd44ad487 in mozilla::StyleSetHandle::Ptr::RemoveStyleSheet (this=0x7f5bbbf58018, aType=mozilla::SheetType::User, aSheet=0x7f5bc1d852c0) at /z/moz/d/obj/dist/include/mozilla/StyleSetHandleInlines.h:160
    #15 0x00007f5bd6b519d7 in mozilla::PresShell::RemovePreferenceStyles (this=0x7f5bbbf58000) at /z/moz/d/layout/base/PresShell.cpp:1510
    #16 0x00007f5bd6b4fc70 in mozilla::PresShell::Destroy (this=0x7f5bbbf58000) at /z/moz/d/layout/base/PresShell.cpp:1294
    #17 0x00007f5bd6bd634d in nsDocumentViewer::DestroyPresShell (this=0x7f5bb1b0ebd0) at /z/moz/d/layout/base/nsDocumentViewer.cpp:4574
    #18 0x00007f5bd6bd280f in nsDocumentViewer::Hide (this=0x7f5bb1b0ebd0) at /z/moz/d/layout/base/nsDocumentViewer.cpp:2180
    #19 0x00007f5bd83875c3 in nsDocShell::SetVisibility (this=0x7f5ba974f000, aVisibility=false) at /z/moz/d/docshell/base/nsDocShell.cpp:6513
    #20 0x00007f5bd44945ad in nsFrameLoader::Hide (this=0x7f5ba98d43d0) at /z/moz/d/dom/base/nsFrameLoader.cpp:1295
    #21 0x00007f5bd6de3eef in nsHideViewer::Run (this=0x7f5ba268e8d0) at /z/moz/d/layout/generic/nsSubDocumentFrame.cpp:928
    #22 0x00007f5bd41efb2c in nsContentUtils::RemoveScriptBlocker () at /z/moz/d/dom/base/nsContentUtils.cpp:5264
    #23 0x00007f5bd3b7c719 in nsAutoScriptBlocker::~nsAutoScriptBlocker (this=0x7ffc9f0181a8) at /z/moz/d/dom/base/nsContentUtils.h:2938
    #24 0x00007f5bd6bd636e in nsDocumentViewer::DestroyPresShell (this=0x7f5bad063a10) at /z/moz/d/layout/base/nsDocumentViewer.cpp:4576
    #25 0x00007f5bd6bd280f in nsDocumentViewer::Hide (this=0x7f5bad063a10) at /z/moz/d/layout/base/nsDocumentViewer.cpp:2180
    #26 0x00007f5bd83875c3 in nsDocShell::SetVisibility (this=0x7f5bbc5b2800, aVisibility=false) at /z/moz/d/docshell/base/nsDocShell.cpp:6513
    #27 0x00007f5bd44945ad in nsFrameLoader::Hide (this=0x7f5bbbfa2f50) at /z/moz/d/dom/base/nsFrameLoader.cpp:1295
    #28 0x00007f5bd6de3eef in nsHideViewer::Run (this=0x7f5ba19700b0) at /z/moz/d/layout/generic/nsSubDocumentFrame.cpp:928
    #29 0x00007f5bd41efb2c in nsContentUtils::RemoveScriptBlocker () at /z/moz/d/dom/base/nsContentUtils.cpp:5264
    #30 0x00007f5bd3b7c719 in nsAutoScriptBlocker::~nsAutoScriptBlocker (this=0x7ffc9f0184a8) at /z/moz/d/dom/base/nsContentUtils.h:2938
    #31 0x00007f5bd6bd636e in nsDocumentViewer::DestroyPresShell (this=0x7f5bc4b76b40) at /z/moz/d/layout/base/nsDocumentViewer.cpp:4576
    #32 0x00007f5bd6bcf2a8 in nsDocumentViewer::Destroy (this=0x7f5bc4b76b40) at /z/moz/d/layout/base/nsDocumentViewer.cpp:1708
    #33 0x00007f5bd836502f in nsDocShell::Destroy (this=0x7f5bb24e3800) at /z/moz/d/docshell/base/nsDocShell.cpp:5868
    #34 0x00007f5bd83f49be in nsXULWindow::Destroy (this=0x7f5bb243f9d0) at /z/moz/d/xpfe/appshell/nsXULWindow.cpp:501
    ...
Priority: -- → P3
(Assignee)

Updated

a year ago
Assignee: nobody → cku
(Assignee)

Comment 1

a year ago
Find a way to supress stylist updat while PresShell is destroying.
Just checking - bz, is this still unfixed after bug 1361843?
Flags: needinfo?(bzbarsky)
I think it's pretty much fixed.  We're still clearing the stylist, before we then go to destroy it, so there might be a tiny amount of wasted work there, maybe.  But we're not going to do the rebuild unless someone asks for styles after the pref stylesheet is removed, which they better not!
Status: NEW → RESOLVED
Last Resolved: a year ago
Depends on: 1361843
Flags: needinfo?(bzbarsky)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.