Closed Bug 1858421 Opened 2 years ago Closed 2 years ago

Pages with text-wrap:balance would cause Firefox to hang

Categories

(Core :: Layout: Text and Fonts, defect)

Desktop
Linux
defect

Tracking

()

VERIFIED FIXED
120 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox118 --- unaffected
firefox119 --- unaffected
firefox120 --- verified

People

(Reporter: pascalc, Assigned: jfkthame)

References

Details

Attachments

(2 files)

Reported to our Nightly twitter account.
https://twitter.com/GoceMitevski/status/1712035895858069837

Seems very buggy at the moment with plenty of rendering issues in v120.0a1. :-/
LinuxMint 21.2 Cinnamon with Linux 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 13:12:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux. A website that uses text-wrap causes a CPU spike and renders very slowly. When scrolling page is partly shown as gray blocks.
The page rendering is never entirely completed and it appears that the browser runs into some kind of infinite loop. Closing the browser is extremely slow. AMD Ryzen 7 5800X 8-Core Processor, GeForce RTX 3060 Ti

It would be helpful to have a specific example of a page where this is a problem.

(In reply to Jonathan Kew [:jfkthame] from comment #1)

It would be helpful to have a specific example of a page where this is a problem.

Sure. Try navigating to https://www.contestwatchers.com/. The initial page is looking good. Then, click on any of the cards to open an individual contest. Immediately after switching to a contest page, performance degrades and rendering issues sporadically appear as you scroll through the pages. The more you switch to different contests the more the performance degrades. Closing the browser keeps its process stuck in memory until it is forcefully killed.

The website works fine in other browsers that support text-wrap: balance.

I hope this helps.

I can repro the above, and the profiler indicates massive reflows. So yeah, likely related to text-wrap.

Severity: -- → S2

Yep, repros for me as well. Probably the trial-reflow loop fails to terminate; I'll look into it. Thanks for the report!

(For now, you can disable the feature by setting layout.css.text-wrap-balance.enabled to false in about:config, to avoid hanging on those pages, or others that may be similarly affected.)

(In reply to Jonathan Kew [:jfkthame] from comment #4)

Yep, repros for me as well. Probably the trial-reflow loop fails to terminate; I'll look into it. Thanks for the report!

(For now, you can disable the feature by setting layout.css.text-wrap-balance.enabled to false in about:config, to avoid hanging on those pages, or others that may be similarly affected.)

Thanks!

(In reply to Jonathan Kew [:jfkthame] from comment #4)

I'll look into it.

[--> Assigning to reflect reality & take this off of the "unassigned high-severity bugs" list.]

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

This seems to be triggered by the fact that those pages set text-wrap: balance way out on the main body, and it is then inherited into all the various child blocks (and eventually the blocks that actually contain lines of text).

Attempting to do "balancing" on the outer blocks that themselves have many levels of block descendants (rather than lines of text) doesn't make much sense, but all the trial reflows of those outer blocks will cause repeated reflows of their children.... which have also inherited the balance setting, and so do their own trials....

A simple fix here is to disable balancing for blocks that themselves have block children, so we'll only apply this behavior to blocks that actually contain lines that can potentially be re-wrapped for better balance.

(I haven't got a nice minimized testcase here yet, but confirmed locally that with the patch, the contestwatchers.com pages no longer hang when attempting to load.)

Attachment #9358037 - Attachment description: Bug 1858421 - Add crashtest derived from the reporter's site. r=#layout → Bug 1858421 - Add crashtest for text-wrap:balance with many nested blocks. r=#layout
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9e1a2dd337b8 Don't attempt text-wrap:balance if there are block line-boxes. r=emilio https://hg.mozilla.org/integration/autoland/rev/d3c6163a42b6 Add crashtest for text-wrap:balance with many nested blocks. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/42509 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1858937
Flags: qe-verify+

I've reproduced this issue using 120.0a1 (2023-10-11) on Windows10 x64 following the STR from Comment 2.
Verified as fixed in the latest Nightly 121.0a1 (2023-10-31) and Firefox 120.0b4 versions on Windows10 x64, macOS 11 ARM and Ubuntu 22.04 where the issue no longer persists.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Regressions: 1941797
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: