Closed Bug 1618547 Opened 4 years ago Closed 3 years ago

Make process priority manager adjust priorities when frames are in the foreground, as opposed to tabs

Categories

(Core :: DOM: Content Processes, task, P1)

task

Tracking

()

RESOLVED FIXED
90 Branch
Fission Milestone M7a
Tracking Status
firefox90 --- fixed

People

(Reporter: mconley, Assigned: mccr8)

References

(Blocks 1 open bug)

Details

(Whiteboard: fission-perf)

Attachments

(1 file)

The process priority manager is very tab-centric, and will downgrade the OS process priority of subframes if they don't have an associated top-level frame in the foreground.

We should make it so that the process priority manager cares about which frames are in the foreground, rather than which tabs.

Fission Milestone: --- → ?

M6 because we should make sure the process priority manager is not making things worse for Fission before we enable Fission for Nightly users.

P3 because not urgent.

Fission Milestone: ? → M6
Priority: -- → P3

Tracking for Fission M7 Beta or later unless we know this bug is causing priority problems.

Fission Milestone: M6 → M7

Randell will find out what's left to do here.

Flags: needinfo?(rjesup)

The setup around the priority manager seems a bit odd right now. It doesn't look like we'll ever interact with this value or the priority manager except through frontend JS either calling browser.deprioritize() on the old browser, or setting browser.renderLayers. Neither of these appears to ever be called on non-toplevel BrowsingContext instances.

I think that getting a passible implementation of this working may be as simple as iterating over the tree of BrowserParent instances in ProcessPriorityManagerIMpl::TabActivityChanged, and performing the logic for each of these frames, rather than only the toplevel one.

This may also eventually want some integration with Fission BFCache in order to make sure we deprioritize processes for tabs in the cache, but given we don't have an implementation of that, we can probably do it later.

Whiteboard: fission-perf
Assignee: nobody → pbone
Status: NEW → ASSIGNED
Flags: needinfo?(rjesup)

Load balancing from pbone to mccr8. Thanks Andrew for picking this one up for M7.

Assignee: pbone → continuation

Priority P1 for Fission M7

Severity: normal → N/A
Priority: P3 → P1
See Also: → 1698661
See Also: → 1698677

We'll fix this in M7a.

Fission Milestone: M7 → M7a

We were talking about this just yesterday. In the context of Fission this needs to be addressed or we might have some really odd behavior.

See Also: → 1699730

(In reply to Gabriele Svelto [:gsvelto] from comment #8)

We were talking about this just yesterday. In the context of Fission this needs to be addressed or we might have some really odd behavior.

I've been working on it. There's just a lot going on here.

Cool, let me know if you need any help.

Depends on: 1704545

With Fission, there can be multiple BrowserParents in a single tab, so
this patch moves the tracking of active tabs onto the top BrowsingContext
in a tab. If the priority of a top BC is changed, then the activity
of all of the BPs of the BCs in the tree are all adjusted.

In addition, if a BrowserParent is being newly created, and it is
in an active BC tree, then the priority manager is told to mark the
BP as active. This is needed for the case of an out-of-process iframe
being loaded into a foreground tab.

A prior patch fixed the case of a BrowserParent being deprioritized.

Here's my WIP patch. I think it deals with all of the scenarios I've thought of, but I need to confirm that by writing more tests.

Basic test scenarios:

  • When tab with iframes starts getting painted, all processes become active. (BrowserHost::SetRenderLayers)
  • When a tab with iframes moves into the background, all processes become inactive. (BrowserHost::Deprioritize)
  • BrowserParent::Deactivated() causes the browser parent to get deactivated (bug 1704545, part 3)
  • When an active CBC navigates, the new CBC is active. (CanonicalBrowsingContext::ReplacedBy())
  • When a BrowserParent is loaded into an active BC tree, it becomes active. (BrowserParent::BrowserParent)

The first two are covered by a modified version of an existing test, but I still need to do the others.

Locally, I have modified the priority manager's testing framework to look at the entire BC tree and not just the browser.

I think the third and fifth scenarios can be tested by navigating an iframe in a foreground tab, with unique origins. With Fission, the original iframe's process should get deprioritized. With and without Fission, the new iframe's process should be prioritized.

I think the fourth scenario can be tested by navigating the top level frame in a way that will require a BC change. I think that won't engage the tab switching logic, so it will rely on CanonicalBrowsingContext::ReplacedBy() and BrowserParent::BrowserParent dealing with the load correctly.

I've been writing tests. My patch here has a bug that BrowserHost::SetRenderLayers was always prioritizing, but it should be passing in aRenderLayers instead of true.

I think my patch is ready for review. There are two failures (a leak while running accessible/tests/browser/e10s/browser_treeupdate_removal.js
and an assertion failure while running toolkit/components/pdfjs/test/browser_pdfjs_saveas.js) but we apparently don't run debug Fission BC tests on Windows, so I'm going to assume those are just existing issues.

Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f45996fe15b2
Support Fission in the process priority manager. r=kmag,gsvelto

Hmm, that's strange. I pushed to try before, and tested locally before I landed, but maybe I did something wrong while addressing review comments that my local testing didn't catch.

I've had a chance to dig into this a bit more. Funnily enough, the failures in browser_ProcessPriorityManager.js appear to have been broken by bug 1693250, which landed immediately before my patch, and was backed out soon after. I confirmed this locally by backing out that other patch while keeping my own. So I guess I'll just reland.

Flags: needinfo?(continuation)
Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/07c8392cb04d
Support Fission in the process priority manager. r=kmag,gsvelto
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Regressions: 1709931
No longer regressions: 1709931
See Also: → 1715502
Regressions: 1715502
See Also: 1715502
Regressions: 1715311
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: