Closed Bug 1770947 Opened 3 years ago Closed 3 years ago

Closing Picture-in-Picture (PiP) window doesn't set tab's priority to background tab

Categories

(Toolkit :: Picture-in-Picture, defect, P3)

defect

Tracking

()

VERIFIED FIXED
107 Branch
Tracking Status
firefox107 --- verified

People

(Reporter: whimboo, Assigned: florian)

References

(Blocks 1 open bug)

Details

(Keywords: perf:resource-use, power)

Attachments

(1 file)

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0 ID:20220515214519

When I'm watching some videos on AirMozilla and using the PiP (picture in picture) mode, I can see a huge CPU load (50% main process) for the Panopto tab. As given by Smaug and Florian this happens because we treat the tab as forground tab.

But when I close the PiP player window the CPU load stays high for some minutes before dropping to normal values again.

Here a recorded profile when I closed the PiP window and left the profiler running some more seconds: https://share.firefox.dev/39QRa59

As told by Florian the priority of the tab is actually set to background so it's not clear why we are rendering still with 120Hz.

Henrik, fwiw, can you please attach your about:support to this so Glenn has more information?

Severity: -- → S3

This is actually a Picture-in-Picture bug. So with the PiP window open we keep the tab's priority (even when in background) as foreground. But when closing the window (with the tab still in background) doesn't adjust the priority to background and keeps it running with foreground priority instead. Only when you select the tab, and deselect the background priority is correctly set.

Here the steps:

  1. Open a tab with AirMozilla and select a video
  2. Start video and move it to a PiP window
  3. Open another tab in the foreground
  4. Inspect the CPU load of Firefox which is high for the main process (~50%) due to some CSS animation on the page
  5. Close the PiP window
  6. Inspect the CPU load again and notice that there is no change
  7. Select the AirMozilla tab
  8. Select the other tab
  9. Inspect the CPU load once again and notice that the load has been dropped (~5%)

A profile with these steps you can find here: https://share.firefox.dev/3LFDZBj

Severity: S3 → --
Component: Graphics: WebRender → Picture-in-Picture
Product: Core → Toolkit
Summary: CSS animations keep running at 120Hz on AirMozilla (Panopto.com) tab even when in background → Closing Picture-in-Picture (PiP) window doesn't set tab's priority to background tab

The CSS animation related power issue I filed as bug 1771078.

See Also: → 1771078
Severity: -- → S4
Priority: -- → P3

This is indeed easy to reproduce. I captured a profile following the steps in comment 2: https://share.firefox.dev/3RBNdSi

The profiles (both mine and the one from comment 2) confirm that the tab priority is correctly set to background (see https://share.firefox.dev/3SBGGZ4) when the PiP window is closed. On the compositor track however, we only clear the animations at step #8 (of the steps in comment 2), https://share.firefox.dev/3ybGuHK

Assignee: nobody → florian
Status: NEW → ASSIGNED

So it turns out the priority of the content process was correctly set to "background", but that was a side effect of stopping the media playback; the browser's docshell was not set to inactive. Here is a profile with the patch included: https://share.firefox.dev/3e8U3RF

Pushed by fqueze@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/eb24e8b340dd mark the associated browser inactive after closing a picture and picture window, r=mconley.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
QA Whiteboard: [qa-107b-p2]

Verified as fixed in our latest 107 build.

I was able to reproduce this issue using the steps from Comment 2, This issue is verified as fixed.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: