Closed Bug 962967 Opened 10 years ago Closed 3 years ago

Be more aggressive about zombifying tabs

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: mfinkle, Unassigned)

References

Details

As seen in https://areweslimyet.com/mobile, tabs can hold onto a good bit of memory. We have mechanisms to help reduce the active tab count and reclaim some memory. One way is through tab zombification:

In response to a "memory-pressure" + "heap-minimize" notification, walk through all tabs and zombify all but the selected one.
http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/MemoryObserver.js#21

Note that we also try to force a tab expiration on "memory-pressure" + "heap-minimize", but that seems silly if we are just going to zombify *all* non-selected tabs anyway:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#8259

When do we fire "memory-pressure" + "heap-minimize"? Only when going into the background it seems. This is kinda strange in that it means we will always zombify all unselected tabs when switching apps:
http://mxr.mozilla.org/mozilla-central/source/widget/android/nsAppShell.cpp#318

But it's strange that we don't use the same signature when Android sends us a low memory event:
http://mxr.mozilla.org/mozilla-central/source/widget/android/nsAppShell.cpp#573

Since the data value is "low-memory" we don't zombify tabs.

Thoughts:
1. Look at removing the tab expiration handler for "memory-pressure" since we already handle it in MemoryObserver.
2. Include "low-memory" in addition to "heap-minimize" conditions
3. Send "memory-pressure" sooner than MEMORY_PRESSURE_MEDIUM. Why wait until it's too late? Maybe we should track free memory on our own.
4. A variation on #1 and #2: Use "low-memory" for zombifying all unselected tabs and use "heap-minimize" for forcing a tab expiration check.

I'm not exactly sure what conclusions we can draw from the telemetry:
http://telemetry.mozilla.org/#release/26/FENNEC_TAB_ZOMBIFIED/saved_session/Fennec
See my thoughts in Bug 962963 Comment 1.
OS: Linux → Android
Hardware: x86_64 → All
Kats pointed out that I had misread two critical pieces of code:
1. We are zombifying if != "heap-minimize", which means we are already zombifying on "low-memory"
2. Tab expiration also watches for != "heap-minimize", but it only enables tab expiration. It does not start tab expiration immediately.

So, we don't need to worry about #1, #2 and therefore, #4 in this bug. We can focus on #3 which is finding ways to more aggressively fire "memory-pressure" + "low-memory".

Note, Kats brought up a good point about "heap-minimize". It's not supposed to be destructive, which is why we != "heap-minimize" before any sort of tab zombification/expiration.
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.