Loading lots of text in a narrow textarea is very slow
Categories
(Core :: Layout: Block and Inline, defect)
Tracking
()
People
(Reporter: smontagu, Unassigned)
References
(Depends on 1 open bug)
Details
(Keywords: perf)
Attachments
(2 files)
Comment 1•13 years ago
|
||
Reporter | ||
Comment 2•13 years ago
|
||
Comment 3•13 years ago
|
||
Reporter | ||
Comment 4•13 years ago
|
||
Updated•13 years ago
|
Comment 6•13 years ago
|
||
Comment 8•13 years ago
|
||
Comment 9•13 years ago
|
||
Comment 10•13 years ago
|
||
Comment 11•13 years ago
|
||
Comment 12•13 years ago
|
||
Comment 13•7 years ago
|
||
Updated•2 years ago
|
Comment 14•3 months ago
|
||
Nightly openiing the testcase: https://share.firefox.dev/4cHGKQ6 (8.4s)
Nightly resizing the textbox to make it narrow: https://share.firefox.dev/3T2DWWZ (infinite time)
Chrome opening the testcase: 4.4s
Comment 15•3 months ago
|
||
Curious..... I see much better performance than that in my Nightly on macOS. Here's a profile of opening the testcase and then dragging the corner of the textbox around to resize it (including making it very narrow): https://share.firefox.dev/471iMht
The initial reflow is around 2.6s, but after that reflows are generally in the 100-120ms range, and it feels pretty responsive. I wonder why your profiles are so different.
Comment 16•3 months ago
•
|
||
I retested, and I sometimes get "good" profiles where the resizes are pretty smooth. And sometimes I get "bad" profiles where the resizes take a looooong time. No idea why there would be this dual behaviour.
Good: https://share.firefox.dev/3Xh3li0
Bad: https://share.firefox.dev/3YWGcCN (loooong time)
Edit: In this profile, it was initially very smooth. But then it became very slow.
https://share.firefox.dev/3z26Qzv
This may be that if you continue to resize without letting go of the resize handle, it will be fast. But if you release the handle (and myabe switch tabs) and then retry, the reflows are slow? Almost like doing an action inadvertently flushes away some cache.
Comment 17•3 months ago
|
||
That's really strange.
I tried it on my Win10 machine too: the initial reflow was 3.3s, and subsequent reflows while resizing the textarea are in the hundred-millisecond range (occasionally as high as 200ms, but generally less).
So I'm puzzled why you're sometimes seeing that "infinite time" case when resizing the textbox; so far, I haven't been able to reproduce that.
In all the profiles, though, it's clear that accessing nsTextFrame::LastInFlow()
is much too costly. Maybe we can do something about that.
Comment 18•3 months ago
|
||
Another example where it started as fast, but then became very slow: https://share.firefox.dev/4fWZ9va
Comment 19•3 months ago
|
||
Comment 20•3 months ago
|
||
I think it has to do something with change of focus. If you resize it quickly and then alt+tab to another window, or maybe Ctrl+tab to another tab, then it seems to get stuck when you return to the demo tab.
Similarly, if your resize is stuck, switching to another tab or window and then switching back again seems to fix it.
Profile where I did all of that and with graphics preset logging: https://share.firefox.dev/3YYeXI2
Comment 21•3 months ago
•
|
||
(In reply to Mayank Bansal from comment #14)
Chrome opening the testcase: 4.4s
(For completeness: Chrome also janks for ~4 seconds when I resize the textbox to make it as narrow as possible.)
(In reply to Jonathan Kew [:jfkthame] from comment #15)
Curious..... I see much better performance than that in my Nightly on macOS. [...] and it feels pretty responsive. I wonder why your profiles are so different.
I think to trigger badness, you need to release your mouse button when the textarea is skinny. While you're dragging, I think we use interruptible reflow which makes it remain responsive as you keep dragging it (so we might start an expensive reflow, but we bail out as you resize the textarea to be wider). But when you release your mouse button, we do a non-interruptible reflow, which is extremely slow for a skinny textarea.
Comment 22•3 months ago
|
||
Maybe try opening the browser and another program like notepad side-by-side.
Click on the notepad then quickly resize the testcase. Then quickly click on the notepad again. Rinse and repeat.
If you do manage to get your resize stuck, click on the notepad and then click back to the browser. It should immediately get "unstuck".
Profile: https://share.firefox.dev/3XdmbXg
Comment 23•3 months ago
•
|
||
Here's a profile I just captured to demonstrate this being responsive in part of the profile and also hanging in another part of the profile:
https://share.firefox.dev/3Axh8YO
In this profile:
- For the first half, I shrink+grow the textarea (as skinny as possible and then back to wide again), releasing my mousebutton when it's wide.
- For the last half, I shrink the textarea, releasing my mousebutton when it's skinny.
- There's a final
PresShell::DoFlushPendingNotifications Layout
operation (when I release my mousebutton) at the end of each of these resize operations; it's only 216ms long when I leave the textarea in a wide state, vs. it's 16s long when I leave the textarea in a skinny state. (Note that I didn't quite make it as skinny as possible; it would be worse if I did that.) - All the other reflows are
PresShell::DoFlushPendingNotifications InterruptibleLayout
to keep things responsive during my drag operation. (So they might be theoretically slow reflows, but we're able to bail out of them.)
Comment 24•3 months ago
|
||
Thanks for the added profiling details; given this, I see comparable results locally as well.
I wondered if we might be able to improve this by some kind of caching to accelerate nsTextFrame::LastInFlow()
, which shows up as very hot in the profiles. But so far, no useful progress. :(
Description
•