Closed Bug 854093 Opened 13 years ago Closed 1 year ago

Indeterminate progress bar causes too much display list building in Thunderbird

Categories

(Core :: Web Painting, defect, P3)

All
Unspecified
defect

Tracking

()

RESOLVED DUPLICATE of bug 1971648

People

(Reporter: mounir, Unassigned)

References

(Blocks 2 open bugs, )

Details

(Keywords: perf, Whiteboard: [battery][tpi:+])

STR: 1. Get a flat CPU usage; 2. Open $URL; Expected result: CPU usage stays relatively as flat. Actualy result: Bump in CPU usage. I wrote that code a long time ago so I'm not sure if that's new or not but this is pretty terrible :(
In firefox 19, with Clearlooks, I get about 21% of 1 cpu, when adding up Firefox, X, and kwin usage.
Cant repro on Win7
I use Fedora 17 (Gnome 3) and Firefox takes 85-95% of CPU time when the $URL page is visible.
Blocks: 1301997
Blocks: 791535
Blocks: 367431
Priority: -- → P4
Whiteboard: tpi:+
(In reply to Mounir Lamouri (:mounir) from comment #0) > STR: > 1. Get a flat CPU usage; > 2. Open $URL; > > Expected result: > CPU usage stays relatively as flat. > > Actualy result: > Bump in CPU usage. > > I wrote that code a long time ago so I'm not sure if that's new or not but > this is pretty terrible :( bug 602964 means problem happens with non-deterministic progress. Do you still see this problem?
Flags: needinfo?(mounir)
I don't run Fedora/Gnome 3 anymore. With my current configuration (still GTK), I don't see the bug. Happy for you to WONTFIX it given that it's no longer reproducible.
Flags: needinfo?(mounir)
I can't reproduce this using Thunderbird on Ubuntu 16.04
Blocks: 562977
Severity: normal → major
Keywords: perf
Whiteboard: tpi:+ → [battery][tpi:+]

I can reproduce it in Thunderbird, and have a workaround by getting rid of progress bar and throbber, see bug 562977 comment 60

Hey Mounir,
Can you still reproduce this or should we close it?

Flags: needinfo?(mounir)

Regardless of whether Niklas responds, this is still widely reported for current versions of Thunderbird. ref bug 562977 and friends.
It's quite a problem for Linux users.

Do we need a different implementation of progress bar?

Flags: needinfo?(stransky)

How is progressmeter implemented, just like <progress>? Do you have a profile? If time is spent in gtk drawing it would be a different thing than comment 0. The code goes through QueueAnimatedContentForRefresh which in fact just uses a timer to animate, which is a bit unfortunate: https://searchfox.org/mozilla-central/rev/8b46752d1e583b2f817c451f93ba515fb865554d/widget/nsNativeTheme.cpp#456

Flags: needinfo?(stransky) → needinfo?(vseerror)

Geoff, can you anwser part of comment 11?

Walt, can you create a performance profile?

Flags: needinfo?(wls220spring)
Flags: needinfo?(vseerror)
Flags: needinfo?(geoff)

(In reply to Wayne Mery (:wsmwk) from comment #12)

Walt, can you create a performance profile?

What is $URL, and how do I open it, or do I just run Thunderbird and check for mail?

Thunderbird and do anything that causes the status bar to churn. Even better if you find something where the status bar just won't stop - - possibilities include Bug 1098069, and password prompts.Unfortunately I don't have a foolproof method.
profiler.firefox.com

Going where no WaltS48 has gone before, and following the instructions at Profiling Thunderbird Performance.

This is what I got using the latest Thunderbird 91.5.0 from Fedora on Fedora 35 Workstation.

https://share.firefox.dev/36LAOJT

Hope it helps.

Flags: needinfo?(wls220spring)
Flags: needinfo?(geoff)

Redirect a needinfo that is pending on an inactive user to the triage owner.
:stransky, since the bug has high severity and recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(mounir) → needinfo?(stransky)
Flags: needinfo?(stransky)

In the process of migrating remaining bugs to the new severity system, the severity for this bug cannot be automatically determined. Please retriage this bug using the new severity system.

Severity: major → --
See Also: → 1830641
Blocks: 1918961

There's something mad about the HTML progress widget that causes it to repaint just about everything. I created a pair of <div>s in the same location as the status bar progress meter, styled them to look identical, and created these performance profiles: https://share.firefox.dev/3PFjLvS

I've also noticed there's much less activity if the message list has only a few messages in it. This shouldn't affect it.

I don't think is unique to GTK. I see similar high CPU usage on Mac, but not on Windows.

At the moment I'm considering just replacing the status bar <progress> with a custom element, as it seems to be the only one where this is a major problem.

Emilio, hopefully my profile in comment 18 offers something worth investigating. I think this bug has become more painful since we updated the UI in 115. It's definitely present in a lot of the performance profiles I see.

Component: Widget: Gtk → Widget
Flags: needinfo?(emilio)
OS: Linux → Unspecified

So... That only shows a lot of display list building time. It also no longer seems to use the native animation, so this is no longer a widget problem afaict.

This is using a background-position animation. An opacity or transform animation would be faster, and that'd be my recommendation. But still it seems like retained display lists should do better, we seem to be rebuilding a whole lot of stuff, unnecessarily...

So TLDR: On your end, I'd look into using transform to implement that animation rather than a background-position animation. Seems it should be doable by moving the radius to the <progress> element?

On our end, it seems retained display lists should do better to avoid rebuilding the whole thing. Tim, do you know how to go about debugging that?

But anyways both problems seem to be unrelated to the original issue which was about the native progress bar.

Flags: needinfo?(emilio) → needinfo?(tnikkel)

(In reply to Geoff Lankow (:darktrojan) from comment #18)

There's something mad about the HTML progress widget that causes it to repaint just about everything. I created a pair of <div>s in the same location as the status bar progress meter, styled them to look identical, and created these performance profiles: https://share.firefox.dev/3PFjLvS

I've also noticed there's much less activity if the message list has only a few messages in it. This shouldn't affect it.

This is in Thunderbird? Is it easy to create a testcase that reproduces the problem in Firefox too?

From the profile it doesn't look like we are throwing away the display list and rebuilding the full thing again, so that would mean we are expanding the rect to rebuild to probably the whole window based on the frames marked modified. Enabling CRR_DEBUG here
https://searchfox.org/mozilla-central/rev/86c208f86f35d53dc824f18f8e540fe5b0663870/layout/painting/RetainedDisplayListBuilder.cpp#869
will give a lot of output and might explain why things are expanding so much.

Actually the profile linked from that comment now is one that uses transform. I replaced the earlier one. That was silly in hindsight. The transform version does perform a bit better than the background-position version.

I've just started fresh and moved the background animation up to the main progress element. There's no improvement.

But anyways both problems seem to be unrelated to the original issue which was about the native progress bar.

Yeah. AIUI the current style on the widget was implemented to avoid this very issue, but actually it's made it worse in my testing. Maybe it was an improvement at the time. The native widget still isn't great performance though. https://share.firefox.dev/4jdNqtV

(In reply to Timothy Nikkel (:tnikkel) from comment #22)

This is in Thunderbird? Is it easy to create a testcase that reproduces the problem in Firefox too?

Yeah, this in Thunderbird. I think this bug's always been about Thunderbird, if not it got hijacked around comment 4.

From the profile it doesn't look like we are throwing away the display list and rebuilding the full thing again, so that would mean we are expanding the rect to rebuild to probably the whole window based on the frames marked modified. Enabling CRR_DEBUG here
https://searchfox.org/mozilla-central/rev/86c208f86f35d53dc824f18f8e540fe5b0663870/layout/painting/RetainedDisplayListBuilder.cpp#869
will give a lot of output and might explain why things are expanding so much.

I'll see what I can find out.

With the progress meter in indeterminate mode, these lines were printed over and over again. I assume that's once every time it painted.

Processing frame 7054c84e8238 with agr 7054cab9f020
currentFrame: 7054c84e8238 (placeholder=0), aOverflow: 0 0 8000 240
Adding area to root draw area: 36378 61650 8000 240
Setting 7054cab9f020 as root stacking context AGR
Computing rebuild regions for 1 frames:
Considering OOFs for 7054c84e8238
Considering OOFs for 7054c84e8180
Considering OOFs for 7054c84e80c0
Considering OOFs for 7054c84df8c0
Considering OOFs for 7054c84df800
Considering OOFs for 7054c84df740
Considering OOFs for 7054c8459438
Considering OOFs for 7054cab9f268
Considering OOFs for 7054cab9f1a8
Considering OOFs for 7054cab9f0d0
Considering OOFs for 7054cab9f020

The same thing is logged with all of our CSS removed, except the overflow and draw areas are different. (Assuming that's x, y, width, height that makes sense as the widget is taller with the CSS gone.)

currentFrame: 798cea24e238 (placeholder=0), aOverflow: 0 0 8000 800
Adding area to root draw area: 36378 30170 8000 800

That seems reasonable, the rects seem like we are invalidating the correct area. To be sure you could check modifiedDirty at this line https://searchfox.org/mozilla-central/rev/b19c379ba7b6d4f25af090a66cec3facf8153ee3/layout/painting/RetainedDisplayListBuilder.cpp#1626 to make sure it is also small. The rect is in appunits, depending on your screen divide by 60 or 30 to get pixels usually.

It might take a long time to build the display list because the structure of the window is complicated.

If the progress bar can be animated using something that can be animated off main thread that would avoid the display list builds.

(In reply to Timothy Nikkel (:tnikkel) from comment #26)

That seems reasonable, the rects seem like we are invalidating the correct area. To be sure you could check modifiedDirty at this line https://searchfox.org/mozilla-central/rev/b19c379ba7b6d4f25af090a66cec3facf8153ee3/layout/painting/RetainedDisplayListBuilder.cpp#1626 to make sure it is also small. The rect is in appunits, depending on your screen divide by 60 or 30 to get pixels usually.

The dirty rectangle is the right size.

It might take a long time to build the display list because the structure of the window is complicated.

Yes, it definitely takes longer when there's a lot of messages in the message list vs an empty list.

If the progress bar can be animated using something that can be animated off main thread that would avoid the display list builds.

That's the thing, I recreated effectively the same thing using two divs, and it does avoid the builds. What's weird about the progress element that it's animated on the main thread? Is it because it used to be a native widget?

Severity: -- → S4
Severity: S4 → S3
Priority: P4 → P3

If the repaint area is correct but display list building still descends into the table of messages, it's worth finding out why that happens. Does the table's visual overflow rect intersect the dirty rect?

Just as an experiment you could try to add contain:paint to the table area.

Component: Widget → Web Painting
Summary: Indeterminate progress bar takes entire CPU → Indeterminate progress bar causes too much display list building in Thunderbird

Going to consider this a duplicate of Bug 1971648 - Add contain: strict to pane elements to reduce layout complexity, and avoid performance impact from animation in status bar - with status bar enabled this should be fixed in 141.0, and to be fixed in esr 140.3.1.

Version 142.0 has additional performance fixes, which will also be in esr 140.3.1.

Status: NEW → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1971648
Flags: needinfo?(tnikkel)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.