Fenix content process priority is never lowered when creating new tabs
Categories
(GeckoView Graveyard :: Sandboxing, defect, P1)
Tracking
(firefox-esr91 wontfix, firefox100 wontfix, firefox101 wontfix, firefox102 fixed)
People
(Reporter: agi, Assigned: emilio)
References
Details
(Whiteboard: [geckoview:m102])
Attachments
(1 file, 2 obsolete files)
Christian reported that the browser becomes unsable when opening a lot of new tabs. I looked into it a little bit and it looks like the process priority is never lowered when opening new tabs, this seems to be a bug around SetPriorityHint.
To reproduce:
- Open new tab from the home screen in fenix (e.g. wikipedia.org)
- Tap on Home button on the url bar
- Open a new tab
Expected:
only one content process is high priority
Actual:
observe /proc/<content process id>/oom_score and notice that the score is low for both content processes
| Reporter | ||
Comment 1•3 years ago
•
|
||
OK so the problem is that we're not actually setting mRenderLayers to false ever because of this line: https://searchfox.org/mozilla-central/rev/87ecd21d3ca517f8d90e49b32bf042a754ed8f18/dom/ipc/BrowserParent.cpp#3441-3447 since mIsPreservingLayers is always true for GeckoView.
Emilio, Mike, do you have opinions about letting renderLayers be false even when isPreservingLayers is true? or maybe we should change the name of renderLayers, the way the process manager uses it, it seems to be more like "is this tab visible" rather then "are we actually painting layers for this tab".
| Assignee | ||
Comment 2•3 years ago
|
||
I'm confused, didn't such thing cause the tab previews not to work in the past? I might be misremembering.
| Reporter | ||
Comment 3•3 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #2)
I'm confused, didn't such thing cause the tab previews not to work in the past? I might be misremembering.
I'm sure that's possibile. Perhaps we could make renderLayers read-only and have a separate property that can be read/written to, say, .active such that
renderLayers = active || isPreservingLayers;
?
| Assignee | ||
Comment 4•3 years ago
|
||
But that property already exists and is .docshellIsActive, right?
| Assignee | ||
Comment 5•3 years ago
|
||
What kind of extra work are you seeing when in the background, are we not throttling the refresh driver and so on? Reading this we should be throttling the refresh driver and so on like we do on desktop.
| Reporter | ||
Comment 6•3 years ago
•
|
||
Sorry I think there is a little bit of confusion here. This bug is not about doing too much work when in background, it's just specifically about the priority of background processes being incorrect.
The only content processes that should get high priority are the one that contain the current tab. We have a bug right now where we sometimes don't lower the priority of the background tabs processes on Android.
The process manager uses renderLayers and priorityHint to determine when a tab should be high priority: https://searchfox.org/mozilla-central/source/dom/ipc/BrowserHost.cpp#117-129
The problem is, when priorityHint is set, we try to read renderLayers to see if we should set the process to high priority, but if isPreservingLayers is true, renderLayers always return true, which means that we will never lower the priority of the process (even though we should): https://searchfox.org/mozilla-central/source/dom/ipc/BrowserHost.cpp#144-154
But that property already exists and is .docshellIsActive, right?
I see, so what you're suggesting is that instead of reading renderLayers we read docshellIsActive? is there an easy way in BrowserHost to know when active changes? It would be weird if we used the setter of renderLayers to know when active changes (or read renderLayers in the setter and active in the priorityHint setter).
| Assignee | ||
Comment 7•3 years ago
|
||
| Assignee | ||
Comment 8•3 years ago
|
||
Yes, something like what I attached should do.
Updated•3 years ago
|
Comment 9•3 years ago
|
||
Does this mean we're not running browser_ProcessPriorityManager.js on Android? Or is it not testing the right thing?
| Assignee | ||
Comment 10•3 years ago
|
||
So apparently right now it is only run on windows: https://searchfox.org/mozilla-central/rev/997a56b018662e2940c99bbaf57a6ac9d1aa5422/dom/ipc/tests/browser.ini#12
But anyways I don't think browser tests run on Android (Geckoview doesn't have a TabBrowser and so on).
Comment 11•3 years ago
|
||
Ah, ok. Well, it would be good to have even a basic test, which would have caught this kind of issue.
| Assignee | ||
Comment 12•3 years ago
|
||
I hope we have tests for activeness (bc activeness is reflected in document.visibilityState and so). And my extension to that test should cover this, android basically has https://searchfox.org/mozilla-central/rev/997a56b018662e2940c99bbaf57a6ac9d1aa5422/mobile/android/chrome/geckoview/geckoview.js#86
But yeah, agi do you know where could I extend a test for Android background tabs or so?
| Reporter | ||
Comment 13•3 years ago
|
||
| Reporter | ||
Comment 14•3 years ago
•
|
||
(In reply to Andrew McCreight [:mccr8] from comment #9)
Does this mean we're not running browser_ProcessPriorityManager.js on Android? Or is it not testing the right thing?
The problem was that the test wasn't testing this specific case (preserveLayers = true). But also yes we don't run browser tests on Android.
(In reply to Emilio Cobos Álvarez (:emilio) from comment #12)
I hope we have tests for activeness (bc activeness is reflected in document.visibilityState and so). And my extension to that test should cover this, android basically has https://searchfox.org/mozilla-central/rev/997a56b018662e2940c99bbaf57a6ac9d1aa5422/mobile/android/chrome/geckoview/geckoview.js#86
But yeah, agi do you know where could I extend a test for Android background tabs or so?
We thought we couldn't write one because the priority was always high during tests, turns out it's a quirk of our process priority code which always starts out as FOREGROUND to prevent killing processes too early after creation (before Gecko has the chance to raise the priority)
I attached a patch that has a test that currently fails but should pass after your patch, extensionCurrentTabRaisesPriority.
| Reporter | ||
Updated•3 years ago
|
Comment 15•3 years ago
|
||
Comment 16•3 years ago
|
||
| bugherder | ||
Comment 17•3 years ago
|
||
Agi says we don't need to uplift this fix to Beta 101.
| Reporter | ||
Comment 18•3 years ago
•
|
||
This actually broke priorityHint even further, so I'm gonna ask the sheriffs to revert.
To reproduce in Fenix:
- Open Fenix and load a web page, verify that
/proc/<pid>/oom_scoreis below 100 for thetab:XXprocess (can check the PID withps -A | grep org.mozilla) - Background Fenix ->
oom_scoreshould still be below 100, in my testing it's around 770
reverting the patch fixes this.
I'll separately land a test that will cover this case.
Comment 19•3 years ago
|
||
Backed out changeset 7b715c304c65 (bug 1767346) for breaking Android process prioritization.
Backout link: https://hg.mozilla.org/integration/autoland/rev/e6d2fef65b87d2eeeac54c1c86f28a8236f709e3
Comment 20•3 years ago
|
||
Comment on attachment 9275028 [details]
Bug 1767346 - Add process priority test for Android.
Revision D145476 was moved to bug 1768101. Setting attachment 9275028 [details] to obsolete.
Comment 21•3 years ago
|
||
Backout merged to central: https://hg.mozilla.org/mozilla-central/rev/e6d2fef65b87
Updated•3 years ago
|
| Assignee | ||
Comment 22•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
Comment 23•3 years ago
|
||
Comment 24•3 years ago
|
||
Backed out changeset 7b3a02a659ef (Bug 1767346) for causing geckoview failures.
Backout link
Push with failures <--> gv-junit-fis
Failure Log
| Assignee | ||
Updated•3 years ago
|
Comment 25•3 years ago
|
||
Comment 26•3 years ago
|
||
| bugherder | ||
Comment 27•3 years ago
|
||
Moving content process management bugs to the new GeckoView::Sandboxing component.
Updated•1 year ago
|
Description
•