Closed Bug 1714846 Opened 3 years ago Closed 2 years ago

High CPU consumption when downloading multiple .mp4 files

Categories

(Firefox :: Downloads Panel, defect)

Firefox 89
Desktop
macOS
defect

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox89 --- wontfix
firefox90 --- wontfix
firefox91 --- wontfix
firefox95 --- wontfix
firefox96 --- wontfix
firefox97 --- fixed

People

(Reporter: u682798, Assigned: Gijs)

References

Details

(Whiteboard: [fxperf:p2])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0

Steps to reproduce:

  1. Open Firefox
  2. Download 5 or more .mp4 files at the same time

Actual results:

The CPU value goes up and the fans increase their RPM.

Expected results:

The CPU stays at normal values and the fans do not increase their RPM.

Component: Untriaged → General
OS: Unspecified → macOS
Hardware: Unspecified → x86_64

Hi,

I checked some mp4 multiple downloads and i was able to replicate on MacOs 10.15 using :
Firefox 90.0b4 affected
Firefox Release 89 affected
Firefox Nightly 91.0a1 affected

Windows10 and Ubuntu are not affected.

Used this site to download multiple mp4s
filesamples.com/formats/mp4

cpu jumps to 100%

Severity: -- → S3
Status: UNCONFIRMED → NEW
Component: General → File Handling
Ever confirmed: true
Hardware: x86_64 → Desktop

Could you please attach a log from the about:support page?

Component: File Handling → Audio/Video
Flags: needinfo?(zwvm67717)
Product: Firefox → Core

I'm sorry, before moving the bug, could you confirm you are downloading the mp4s and not previewing them in the browser?

Component: Audio/Video → Downloads Panel
Product: Core → Firefox

(In reply to Marco Bonardo [:mak] from comment #3)

I'm sorry, before moving the bug, could you confirm you are downloading the mp4s and not previewing them in the browser?

Yes, I download the MP4 files but I do not see them in the browser preview.

Attached file about:support
(In reply to Marco Bonardo [:mak] from comment #2)
> Could you please attach a log from the about:support page?

(In reply to Marco Bonardo [:mak] from comment #2)

Could you please attach a log from the about:support page?

I have attached the data present in the about:support page.

Flags: needinfo?(zwvm67717)
Whiteboard: [fxperf]
Whiteboard: [fxperf] → [fxperf:p2]

The log doesn't show anything particularly problematic, a see a few privacy options and clear on shutdown flipped on, but those are unlikely to cause problems with downloads.
There's also dns prefetch disabled, but again I'd expect that to just affect starting of the download. Just to be overzealous, I'd probably sugges to try a new profile and see if the problem happens there too. See https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles

What would be very useful here, is a performance profile when the bug happens. Could you please go to https://profiler.firefox.com/ and, following the instructions, start profiling before starting the downloads, and stop profiling after the problem happened. It should generate a profile link that you can add to the bug report and analyzing it we could find what is consuming cpu time.

Flags: needinfo?(zwvm67717)

(In reply to Marco Bonardo [:mak] from comment #7)

The log doesn't show anything particularly problematic, a see a few privacy options and clear on shutdown flipped on, but those are unlikely to cause problems with downloads.
There's also dns prefetch disabled, but again I'd expect that to just affect starting of the download. Just to be overzealous, I'd probably sugges to try a new profile and see if the problem happens there too. See https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles

What would be very useful here, is a performance profile when the bug happens. Could you please go to https://profiler.firefox.com/ and, following the instructions, start profiling before starting the downloads, and stop profiling after the problem happened. It should generate a profile link that you can add to the bug report and analyzing it we could find what is consuming cpu time.

Creating a new profile does not solve the issue.
Please Pablo, I do not have much time these days, since you were able to reproduce could you include some more details?

Flags: needinfo?(zwvm67717) → needinfo?(pablo.muir)

Hello
this was captured with profiler

https://share.firefox.dev/3rj104s

altho on latest nightly i had to open more mp4 files since the cpu usage was not getting into 100% like some weeks ago when i tested it.
regards

Flags: needinfo?(pablo.muir)

(In reply to Pablo from comment #9)

Hello
this was captured with profiler

https://share.firefox.dev/3rj104s

altho on latest nightly i had to open more mp4 files since the cpu usage was not getting into 100% like some weeks ago when i tested it.
regards

Hey Emilio, would you be able to have a look at this? It looks like we end up doing a style and paint pass every few ms, and I don't really understand why that is happening. There is code at https://searchfox.org/mozilla-central/rev/523ac2e17550f1f1da16aacdc6ac647af8b35508/browser/components/downloads/content/indicator.js#485-489 that would set a CSS variable repeatedly, but as far as I can tell the check at the start of that block (to see if aValue is different from the previous completion percentage) is working, so we shouldn't be changing the values that go into the conic gradient used for the progress display. What's more, the downloads from filesamples.com do not send a Content-Length so we can't even compute a completion percentage, so we never update the display anyway (bug 1717946). So I don't understand what is triggering the restyles/repaints that appear in the profile. Perhaps/hopefully it is more obvious to you?

Flags: needinfo?(emilio)

(In reply to :Gijs (he/him) from comment #10)

(In reply to Pablo from comment #9)

https://share.firefox.dev/3rj104s
It looks like we end up doing a style and paint pass every few ms, and I don't really understand why that is happening.

The "RefreshDriverTick" markers (happening at 60Hz) show "Tick reasons: HasObservers (DocumentTimeline animations [Style])", and we have "CSS animation - downloadProgressSlideX" markers. The "SetNeedStyleFlush" markers have "nsRefreshDriver::Tick" as the first frame of the stack, so I would say that there's nothing else that invalidates; it's just that we are playing the downloadProgressSlideX CSS animation.

(But I'm still interested in seeing if emilio can find other relevant information from the profile)

Yep, that's it, it's a CSS animation. We don't run background-position animations on the compositor. Perhaps we can tweak that code to be a transform animation of sorts?

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #12)

Yep, that's it, it's a CSS animation. We don't run background-position animations on the compositor. Perhaps we can tweak that code to be a transform animation of sorts?

Shouldn't the animation not be running while the panel is not visible?

Flags: needinfo?(emilio)

(In reply to :Gijs (he/him) from comment #13)

Shouldn't the animation not be running while the panel is not visible?

That reminds me bug 1693176.

Yep... That was a pain to get landed last time, but we should probably try again or something.

I think we should have a bug on file to update the panel progress animations. These didn't make the MR1 scope, but we do have a new design for them, and can ensure that implementation animates on the compositor. I don't have the bug # handy...

I rebased bug 1693176 and try looked good so will try to reland it.

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(emilio)
Resolution: --- → DUPLICATE

(In reply to Sam Foster [:sfoster] (he/him) from comment #16)

I think we should have a bug on file to update the panel progress animations. These didn't make the MR1 scope, but we do have a new design for them, and can ensure that implementation animates on the compositor. I don't have the bug # handy...

bug 1699530 ? If not, we should ensure something is on file given this is duped. :-)

Flags: needinfo?(sfoster)

(In reply to :Gijs (he/him) from comment #18)

bug 1699530 ? If not, we should ensure something is on file given this is duped. :-)

Yes that's the one. Its a bit thin on detail, but specs exist. I'm not sure if that's the MR1.1 team or the downloads panel folks though, which might be why its falling between the cracks right now.

Flags: needinfo?(sfoster)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #17)

I rebased bug 1693176 and try looked good so will try to reland it.

*** This bug has been marked as a duplicate of bug 1693176 ***

Emilio, bug 1693176 is fixed now, but I still see the downloadProgressSlideX CSS animation and the refresh driver ticks happening at 60Hz during the entire duration of a download, even though the animation is in an hidden panel.

Example profile on a recent Windows build (I also saw this on Mac) : https://share.firefox.dev/3mfUTvE
The steps to reproduce were just to start profiling, then starting the download of a massive file (so that it doesn't finish quickly), eg. http://test-debit.free.fr/10485760.rnd and closing any download panel.

In the profile, I notice that when the panel is open we paint at 60Hz (even though nothing changes on screen), and when the panel is closed we have the refresh driver ticks, but no restyle.

Flags: needinfo?(emilio)
See Also: → 1731420

Ouch, that's because of how shadow dom styling works, this declaration has more priority than the style attribute.

Let's see: https://treeherder.mozilla.org/#/jobs?repo=try&revision=84c0b349e6fdf32349d8050de8919a39442c3230

Status: RESOLVED → REOPENED
Flags: needinfo?(emilio)
Resolution: DUPLICATE → ---

(In reply to Emilio Cobos Álvarez (:emilio) from comment #21)

Ouch, that's because of how shadow dom styling works, this declaration has more priority than the style attribute.

Let's see: https://treeherder.mozilla.org/#/jobs?repo=try&revision=84c0b349e6fdf32349d8050de8919a39442c3230

Did this help / work? (I can't really tell from the trypush...) And should we move this bug to layout?

Flags: needinfo?(emilio)

Yeah, that helps but causes some test failures that I don't have time to investigate... It's definitely not a layout bug... I'd say it's either a Toolkit bug, or XUL (if it needs extra platform support to fix the tests).

Flags: needinfo?(emilio)
See Also: → 1736311
See Also: → 1737881

(In reply to Emilio Cobos Álvarez (:emilio) from comment #23)

Yeah, that helps but causes some test failures that I don't have time to investigate... It's definitely not a layout bug... I'd say it's either a Toolkit bug, or XUL (if it needs extra platform support to fix the tests).

It looks like the webextension panel tests are failing. If I had to guess, they probably fail because they rely on being able to load content in a <browser> inside a panel, and measure how big it is and have logic that resizes the browser and/or panel based on that. I expect that with the panel "really" display: none, the <browser> probably doesn't load any content? Rob, is there a way to exempt webextension panels from Emilio's patch, and/or do you know if there's some other way we could land this performance optimization without breaking webextensions?

Flags: needinfo?(rob)
See Also: → 1742797

(In reply to Emilio Cobos Álvarez (:emilio) from comment #21)

Ouch, that's because of how shadow dom styling works, this declaration has more priority than the style attribute.

Does this mean that bug 1693176 didn't work? Or did it only work in some cases?

It didn't work, the patch in comment 21 makes it work and causes some failures.

Blocks: 1742797

In response to comment 25: Looks like the <browser> elements inside the <panel> are not properly initialized when the <panel> is hidden with display:none. In the browser action case, there are even two nested <panel> elements (see tempPanel and panel (ViewPopup) mentioned below).

If I add logic to prevent these from being hidden, then the try push becomes somewhat green. There are some oranges, but when I ran them locally on macOS (artifact release build), the tests passed:
https://treeherder.mozilla.org/jobs?repo=try&revision=482f2d093f9b059fac08b975578b7977fabbe981

Patch: https://hg.mozilla.org/try/rev/edf23562741a7766e76b0c115b01351dfa99de3d

The main modifications that I did was making removing display:none for three specific elements:

Side note: the logic at https://searchfox.org/mozilla-central/rev/ead7da2d9c5400bc7034ff3f06a030531bd7e5b9/toolkit/content/widgets/panel.js#62-69 can be simplified. The if (!this.arrowPanel)-branch can be removed, as the resulting shadow tree is identical these days (in the past it was different).

Flags: needinfo?(rob)
Assignee: nobody → gijskruitbosch+bugs
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6e298bdd0dd8
Really hide panels on hide, r=robwu,emilio
Flags: needinfo?(gijskruitbosch+bugs)
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/8e5e86466731
Really hide panels on hide, r=robwu,emilio
Status: REOPENED → RESOLVED
Closed: 3 years ago2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch

Will this get a beta uplift as well for 96?

Regressions: 1745348

(In reply to Arthur K. [He/Him] from comment #34)

Will this get a beta uplift as well for 96?

Given 1 backout + relanding and now mysterious regressions, I don't think so.

Regressions: 1745398
Regressions: 1745503
Regressions: 1745551
See Also: 1742797
Regressions: 1747609
Flags: qe-verify+
Depends on: 1693176

I'm still seeing the high CPU usage when downloading, for example, an ISO from the VLSC. The OS >does< seem more responsive than before this fix but it seems, in my case, the fix hasn't quite crossed the finish line. Can anyone else confirm? I am testing with 97.0b8 x64.

If it's of any use, I uploaded a perf profile demonstrating the behavior here: https://share.firefox.dev/3IGlmw5

Arthur K. , I encountered the same behavior as you when running on 97.0b8 x64. It seems that the CPU usage is lighter than in the affected builds but still significant for this fix.

(In reply to Oana Ardelean from comment #38)

Arthur K. , I encountered the same behavior as you when running on 97.0b8 x64. It seems that the CPU usage is lighter than in the affected builds but still significant for this fix.

I think the remainder of what needs to happen here is tracked in bug 1742797.

(In reply to :Gijs (he/him) from comment #39)

(In reply to Oana Ardelean from comment #38)

Arthur K. , I encountered the same behavior as you when running on 97.0b8 x64. It seems that the CPU usage is lighter than in the affected builds but still significant for this fix.

I think the remainder of what needs to happen here is tracked in bug 1742797.

Thanks for the heads up Gijs.

(In reply to :Gijs (he/him) from comment #39)

(In reply to Oana Ardelean from comment #38)

Arthur K. , I encountered the same behavior as you when running on 97.0b8 x64. It seems that the CPU usage is lighter than in the affected builds but still significant for this fix.

I think the remainder of what needs to happen here is tracked in bug 1742797.

I just commented in bug 1742797 that it seems to have gotten worse in 100.0b. Just following up here as well.

This high CPU util is still present in 102 and 103b.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: