Fenix leaks 7MB (heap-unclassified) every time the browser app is foregrounded
Categories
(GeckoView :: General, defect, P1)
Tracking
(Performance Impact:high, firefox-esr68 wontfix, firefox-esr78 wontfix, firefox78 wontfix, firefox79+ verified, firefox80+ verified, firefox81+ verified)
People
(Reporter: mstange, Assigned: mstange)
References
Details
(Keywords: perf:resource-use, Whiteboard: [geckoview:m81][fxr])
Attachments
(1 file)
|
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
RyanVM
:
approval-mozilla-release+
|
Details | Review |
From bug 1625499 comment 8 and 9:
(In reply to Kevin Brosnan [:kbrosnan] from bug 1625499 comment #8)
hwinnemoe Fenix #11284
I did some measurements via
about:memoryusing the following STR:
- Cold startup Fenix, no Addons activated
- Switch to PBM
- Open
about:memory- Press Measure and copy the log
- Repeatedly switch between other apps and Fenix, e.g. switching 20 times between Settings and Fenix, thus switching to Fenix 10 times
- Press Measure and copy the log
- Use Close private tabs to close the single tab
- Open
about:memoryagain- Press Measure and copy the log
Here are the logs for
- STR Step 4: 11284 STR Step 4.txt
- STR Step 6: 11284 STR Step 6.txt
- STR Step 9: 11284 STR Step 9.txt
(In reply to Henrik Winnemöller from bug 1625499 comment #9)
I did some follow-up investigations with multiple tabs on this issue based on my findings in Fenix #11284. The used Nightly version was Nightly 200723 06:01 (Build #22050610). The device was a Sony Xperia Z2, Android 6.0.1, without active WR.
STR Variant 1 - Single tab for comparison
- Cold startup the browser on a fresh profile
- Open
about:memory- Press Measure and note down the heap-unclassified memory
- Repeatedly switch between the browser and another app, thus opening up the browser 10 times
- Repeat steps 3 and 4.
Results for STR Variant 1 - Single tab for comparison
heap-unclassified after switching to the browser app for ...
10 times - 087.77 MiB
20 times - 165.02 MiB
30 times - 235.79 MiBSTR Variant 2 - Multiple tabs
- Cold startup the browser on a fresh profile
- Open two tabs for
about:memory- Switch to the first tab.
- Press Measure and note down the heap-unclassified memory
- Repeatedly switch between the browser and another app, thus opening up the browser 10 times
- Press Measure and note down the heap-unclassified memory
- Switch to the second tab.
- Repeat Steps 5 and 6.
- Switch to the first tab.
- Repeat Steps 5 and 6.
- Switch to the second tab.
- Repeat Steps 5 and 6.
- Switch to the first tab.
- Repeat Steps 5 and 6.
- Switch to the first tab.
- Repeat Steps 5 and 6.
- Switch to the second tab.
- Repeat Steps 5 and 6.
Results for STR Variant 2 - Multiple tabs
heap-unclassified after switching to the browser app for ... (Note: numbers are cumulative switches)
10 times on 1. tab - 087.97 MiB
10 times on 2. tab - 159.00 MiB
20 times on 1. tab - 236.55 MiB
20 times on 2. tab - 306.90 MiB
30 times on 1. tab - 370.16 MiB
30 times on 2. tab - 440.54 MiBThis seems to grow unrelated to the number of tabs. Note: Nightly users might not see this in this extent since they normally get daily updates. But a Beta or Production user will most likely experience this when using the browser for several days. It would be interesting to look at telemetry for how often users open up the browser (by switching to it or unlocking the screen) to judge the severity of this issue.
| Assignee | ||
Comment 1•5 years ago
|
||
This sounds rather serious. Switching apps is something that happens quite a lot of times over the course of a day, and mobile devices are very memory-constrained.
| Assignee | ||
Updated•5 years ago
|
Comment 2•5 years ago
|
||
I tried to reproduce this issue in GeckoView Example 81.0a1, Build ID 20200727203201 via this link: No heap-unclassified memory growth is shown after repeatedly foregrounding the app.
| Assignee | ||
Comment 3•5 years ago
|
||
Thanks! That indicates that Fenix is implicated here somehow; but about:memory only tracks Gecko memory usage, so it must be something Fenix triggers inside Gecko.
Comment 4•5 years ago
|
||
My wild guess is that this is related to screenshots, I think we take one every time we show a page. Maybe related to Bug 1647797 ?
Updated•5 years ago
|
Comment 5•5 years ago
•
|
||
Assuming that ScreenshotBuilder.capture() uses RGBA_8888, which I infer from this line, I can perform the following calculations: The device I used for the investigations in Comment 0 has a visible viewport in Fenix of 1080 by 1704 pixels. Thus, a RGBA_8888 uncompressed capture takes 7.02 MiB per capture, which seems to be the near the mean heap-unclassified memory growth per foregrounding action. Testing against devices with different resolutions could be helpful here to verify if the heap is actually filled with capture data.
In addition, my device takes about the same amount of time to present the tab in Fenix after foregrounding it as it takes to take a fullscreen capture.
| Assignee | ||
Comment 6•5 years ago
|
||
I think I found the bug: FlipScreenPixels creates and leaks a ScopedMap object which has a strong reference to the surface.
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 7•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
| Assignee | ||
Comment 8•5 years ago
|
||
I've confirmed that this patch fixes the issue as originally reported. heap-unclassified stayed at 24MB even after many iterations of app switching, whereas without the fix it was increasing by 7MB every time.
| Assignee | ||
Updated•5 years ago
|
Comment 10•5 years ago
|
||
Backed out as requested by mstange.
Backout link: https://hg.mozilla.org/integration/autoland/rev/00da6f158726e9842eb6d2f0b52af48bed72061b
| Assignee | ||
Comment 11•5 years ago
|
||
There was a lint failure - "Unused import - java.nio.ByteBuffer". I'm fixing that and waiting for a try push before relanding.
Comment 12•5 years ago
|
||
Comment 13•5 years ago
|
||
| bugherder | ||
Comment 14•5 years ago
•
|
||
Verified as fixed in Fenix Nightly 200803 06:07 (Build #22160612).
Bad: Nightly 200730 06:21 (Build #22120630)
Good: Nightly 200803 06:07 (Build #22160612)
Updated•5 years ago
|
Updated•5 years ago
|
| Assignee | ||
Comment 15•5 years ago
|
||
Comment on attachment 9167177 [details]
Bug 1655580 - Stop leaking surfaces that were captured with RequestScreenPixels. r=agi
Beta/Release Uplift Approval Request
- User impact if declined: Large memory leak in Fenix, causing the app to be terminated more frequently than necessary
- Is this code covered by automated tests?: No
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Medium
- Why is the change risky/not risky? (and alternatives if risky): Low-to-medium, I'd say. Low because it's a small straightforward fix, medium because it's in a part of the code base that I'm not very familiar with so I might have made mistakes.
- String changes made/needed:
| Assignee | ||
Updated•5 years ago
|
Comment 16•5 years ago
|
||
Comment on attachment 9167177 [details]
Bug 1655580 - Stop leaking surfaces that were captured with RequestScreenPixels. r=agi
fix memory leak in geckoview, approved for 80.0b4
Comment 17•5 years ago
|
||
| bugherder uplift | ||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 18•5 years ago
•
|
||
Verified as fixed in Beta 80.0.0-beta.4 (Build #2015756489).
Bad: Beta 80.0.0-beta.3
Good: Beta 80.0.0-beta.4
Updated•5 years ago
|
Comment 20•5 years ago
|
||
Comment on attachment 9167177 [details]
Bug 1655580 - Stop leaking surfaces that were captured with RequestScreenPixels. r=agi
Approved for Fenix 79.0.5.
Comment 21•5 years ago
|
||
| bugherder uplift | ||
Comment 23•5 years ago
|
||
Verified as fixed in Fenix 79.0.5 (Build #2015758617)
Bad: Fenix 79.0.4
Good: Fenix 79.0.5
Updated•5 years ago
|
Updated•3 years ago
|
Description
•