Closed Bug 1067755 Opened 10 years ago Closed 9 years ago

When resizing browser at Nightly firstrun page, several copies of "###!!! ASSERTION: old rule tree still referenced: 'Not Reached', file $SRCDIR/layout/style/nsStyleSet.cpp, line 2076"

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox38 --- fixed

People

(Reporter: dholbert, Assigned: heycam)

References

Details

(Keywords: assertion)

Attachments

(2 files)

STR:
 1. Visit Nightly firstrun page in a debug build:
 https://www.mozilla.org/en-US/firefox/nightly/firstrun/

 2. Resize your browser window's width to be as small as you can, and then make it normal-sized again.

ACTUAL RESULTS:
Several copies of this assertion are spammed when the page snaps across a media-query boundary (at around 800 pixels wide):
{
###!!! ASSERTION: old rule tree still referenced: 'Not Reached', file $SRCDIR/layout/style/nsStyleSet.cpp, line 2076
}

See also bug 1060194, filed on this same assertion in Firefox OS. (There, it "keeps showing without doing anything" -- may or may not be the same underlying bug as what's happening here at the firstrun page.)
Sorry, I actually get two separate assertions.  When my browser window crosses the ~800px threshold (and the layout snaps to a skinnier design), I first get two copies of this assertion
{
###!!! ASSERTION: style context has old rule node: 'n == mRuleTree', file $SRCDIR/layout/style/nsStyleSet.cpp, line 247
}
...and *then* I get 2 copies of the "old rule tree still referenced" NS_NOTREACHED from comment 0.

Both of these assertions were added in bug 475128 (mozilla-central changeset 3b2f69cc7004); hence, adding dependency on that bug. (not to imply that this started with that bug's landing, but just that it's related and the problem wouldn't have been detectable without that bug's commit)
Depends on: 475128
I've debugged what's going on here; more details after a meeting.
I think this is probably a regression from bug 950526, although I haven't verified this.  (I was originally expecting it to be a regression from bug 931668, but I don't think that's the case.)

The underlying problem here is that we have an nsTransformedTextRun that's holding on (in its mStyles) to a style context.  We then do a restyle that rebuilds the rule tree, which is supposed to get rid of all style contexts that refer to the old rule tree and replace them with ones that point to the new rule tree.  We assert at the end of that restyle that there are no style contexts referencing the old rule tree, and this assertion fails because the nsTransformedTextRun is still holding them.
Blocks: 950526
(In reply to David Baron [:dbaron] (UTC-7) (needinfo? for questions) from comment #3)
> I think this is probably a regression from bug 950526, although I haven't
> verified this.  (I was originally expecting it to be a regression from bug
> 931668, but I don't think that's the case.)

It's at least a regression in the sense that adding the ClearTextRuns() call back to nsTextFrame::DidSetStyleContext makes this assertion go away.  (I'm not sure that there wasn't a more recent change involved as well.)

Ideally we should find a way for nsTransformedTextRun to either:
 (1) not hold style contexts, but instead hold the information it needs (doesn't look too hard except for MathML!), or
 (2) update the style context pointers in the nsTransformedTextRun when needed.
The assertions I needed to add to debug this are in bug 1075082.
John, I want to do (1) from comment 4.  I'm thinking to replace the array of refcounted nsStyleContext pointers on transformed text runs with pointers to new objects that just encapsulated the required style from those contexts.

This simplest approach is probably to have a single new struct, nsTransformedCharStyle, which has members for all possible style data needed by the transformers for a given character, regardless of which transforming text run factories we use.  This wouldn't be very generic (unlike the current setup that allows a chain of transforming factories).

Alternatively, we could do something like have nsTransformedCharStyle be an object with a table of transformer-specific styles.  We would have BuildTextRunsScanner::BuildTextRunForFrames call into the factory chain to build up this array of nsTransformedCharStyle objects with the right transformer-specific styles.  In this setup we should probably just stick the current values required by the case transforming factory -- mTextTransform and mLanguage -- on nsTransformedCharStyle itself, and leave the table just for the MathML stuff.

Do you have a preference?
Flags: needinfo?(jdaggett)
Attached patch patchSplinter Review
This is approach (a).
The "simplest approach", that is (I thought I lettered the two approaches).
(In reply to Cameron McCormack (:heycam) from comment #7)

> This simplest approach is probably to have a single new struct,
> nsTransformedCharStyle, which has members for all possible style data needed
> by the transformers for a given character, regardless of which transforming
> text run factories we use.  This wouldn't be very generic (unlike the
> current setup that allows a chain of transforming factories).

This seems fine. I would run it by roc also.
Flags: needinfo?(jdaggett)
roc is OK with this approach too.
Attachment #8557853 - Attachment description: WIP v0.1 → patch
Attachment #8557853 - Flags: review?(jdaggett)
Assignee: nobody → cam
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: x86_64 → All
Comment on attachment 8557853 [details] [diff] [review]
patch

Review of attachment 8557853 [details] [diff] [review]:
-----------------------------------------------------------------

Assuming the rvalue reference usage is correct, looks good.
Attachment #8557853 - Flags: review?(jdaggett) → review+
sorry had to back this out for static analysis bustage like https://treeherder.mozilla.org/logviewer.html#?job_id=6453305&repo=mozilla-inbound
Flags: needinfo?(cam)
Thanks, I was just missing an explicit.

https://hg.mozilla.org/integration/mozilla-inbound/rev/87b7034309e2
Flags: needinfo?(cam)
https://hg.mozilla.org/mozilla-central/rev/87b7034309e2
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Depends on: 1133243
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: