New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 785046 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

changing document.title causes layout thrashing (recalc styles. layout)

Reported by t...@coinbase.com, Nov 14 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Steps to reproduce the problem:
1. change the document.title frequently
2. use chrome dev tools to profile layout thrashing
3. 

What is the expected behavior?
Changing the document title should not cause layout thrashing

What went wrong?
I'm building a real-time application that frequently updates the document.title. my users are accustom to this behavior. sometimes the title is updating as frequently as every ~20 ms. Using chrome dev tools, I've noticed that setting document.title causes layout thrashing.

I don't know the details, but I don't think this should be required for a simple string change.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 61.0.3163.100  Channel: n/a
OS Version: OS X 10.12.6
Flash Version:
 
Cc: krajshree@chromium.org
Components: Blink>Layout
Labels: Needs-Feedback Needs-Milestone
tim@ - Thanks for filing the issue...!!

Could you please provide a sample test file to test the issue from TE-end.
This will help us in triaging the issue further.

Thanks...!!

Comment 2 by t...@coinbase.com, Nov 15 2017

Sure thing. I've uploaded an index.html where you can profile the issue yourself. As well as a screenshot showing the profiling.
index.html
179 bytes View Download
Screen Shot 2017-11-15 at 1.58.25 PM.png
158 KB View Download
Project Member

Comment 3 by sheriffbot@chromium.org, Nov 15 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "krajshree@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Needs-Feedback
RecalcStyle is required because the <title> element may have a visible display value. But layout should not happen unless such a display value is in fact set.

Could you upload a trace file using the instructions at https://www.chromium.org/developers/how-tos/submitting-a-performance-bug ? Thanks!

Comment 5 by t...@coinbase.com, Nov 15 2017

Uploaded. Thanks for looking into this.
trace_performance_test.json.gz
1.2 MB Download
Project Member

Comment 6 by sheriffbot@chromium.org, Nov 15 2017

Cc: cbiesinger@google.com
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "cbiesinger@google.com" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: -cbiesinger@google.com cbiesin...@chromium.org
Components: -Blink>Layout Blink>CSS
Status: Untriaged (was: Unconfirmed)
OK, looking at that trace--

We call Document::recalcStyle which I think is unavoidable because changing the title could affect style

But we also call Document::rebuildLayoutTree from Document::updateStyle and I don't know why we do that? Why is the NeedsReattachLayoutTree flag set in this case?

UpdateLayerTree is expected because that's always there when we update the lifeycle state. Not sure whether LayoutView::commitPendingSelection is expected but I guess so (?) and anyway that's super-quick

PrePaint is unconditional


So the thing I am mostly wondering about is why style recalc sets NeedsReattachLayoutTree here. Over to the style team


setTitle() replaces the text node, which means we detach the existing text node, removes the node and insert a new text node. Inserting the new text node marks the tree for RebuildLayoutTree() as part of style recalc because all new nodes are created with kNeedsReattachStyleChange. This is normally required to properly attach inserted nodes. I don't think that should be strictly necessary when inserting nodes into parents which are display:none.

Comment 9 by nainar@chromium.org, Nov 16 2017

Status: Available (was: Untriaged)
Labels: Update-Quarterly Performance
Labels: ApproachableBug Code-RecalcStyle
Labels: -Update-Quarterly
Labels: -Performance Performance-Loading Performance-Browser
Project Member

Comment 14 by sheriffbot@chromium.org, Jan 18 (5 days ago)

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 15 by e...@chromium.org, Jan 21 (2 days ago)

Labels: -Pri-2 Pri-3
Status: Available (was: Untriaged)

Sign in to add a comment