Bug 1450787 Comment 5 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Thanks for pointing this out :gregp.

**TL;DR**
I believe we must enable that pref as we are already notifying observers of `memory-pressure`, and it looks like it is a no-op (except on gfx layer) unless we enable it. 

--
As far as I can tell, Android is trying to notify the observers of `memory-pressure` topic under these conditions:
1- [When Android OS sends a memory pressure callback](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/MemoryController.java#47-73)
2- [When process is sent to the background](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentChild.cpp#2782-2798) - this was a recent pref-ed off change to test pressure levels based on another pref, ni'ing Olli as I believe we need `javascript.options.gc_on_memory_pressure` enabled to see this change's impact. Please correct me if I'm wrong. 
3- [When ContentParent receives it](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentParent.cpp#4039) and [ContentChild forwards the message](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentChild.cpp#2511) to the code running in the content process

As in the scope of this ticket, due to the pref being disabled on Android, [this if check](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/base/nsJSEnvironment.cpp#289) will never be satisfied and all these three cases will have no impact. 

There's also [some handling going on in the Graphics end](https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla6layers22MemoryPressureListener16OnMemoryPressureENS0_20MemoryPressureReasonE&redirect=false) which I believe should already be working on Android as well. (cc'ing Jaime in case I'm wrong.)

I could not spot any reference to zombifying a tab as Fennec was doing, but I believe what we are doing [when we receive a memory pressure callback from the Android OS](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt#576) on Fenix is doing smth similar: it [suspends tabs](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/TrimMemoryMiddleware.kt#54-56) which [unlinks the engine session from the tabs and then closes those sessions]( https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/SuspendMiddleware.kt#49-58) that at the end [releases the memory](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#1815-1835) held on Java and native layers. "Unzombifying" corresponds to tab reloading and restoring the engine session.
Thanks for pointing this out :gregp.

**TL;DR**
I believe we must enable that pref as we are already notifying observers of `memory-pressure`, and it looks like it is a no-op (except on gfx layer) unless we enable it. 

--
As far as I can tell, Android is trying to notify the observers of `memory-pressure` topic under these conditions:
1- [When Android OS sends a memory pressure callback](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/MemoryController.java#47-73)
2- [When process is sent to the background](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentChild.cpp#2782-2798) - this was a recent pref-ed off change to test pressure levels based on another pref, ni'ing Olli as I believe we need `javascript.options.gc_on_memory_pressure` enabled to see this change's impact. Please correct me if I'm wrong. 
3- [When ContentParent receives it](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentParent.cpp#4039) and [ContentChild forwards the message](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/ipc/ContentChild.cpp#2511) to the code running in the content process

As in the scope of this ticket, due to the pref being disabled on Android, [this if check](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/dom/base/nsJSEnvironment.cpp#289) will never be satisfied and all these three cases will have no impact. 

There's also [some handling going on in the Graphics end](https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla6layers22MemoryPressureListener16OnMemoryPressureENS0_20MemoryPressureReasonE&redirect=false) which I believe should already be working on Android. (cc'ing Jaime in case I'm wrong.)

I could not spot any reference to zombifying a tab as Fennec was doing, but I believe what we are doing [when we receive a memory pressure callback from the Android OS](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt#576) on Fenix is doing smth similar: it [suspends tabs](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/TrimMemoryMiddleware.kt#54-56) which [unlinks the engine session from the tabs and then closes those sessions]( https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/SuspendMiddleware.kt#49-58) that at the end [releases the memory](https://searchfox.org/mozilla-central/rev/dd6e430c1bc2db90d9b3b1dd7e5215b4edc4d51a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#1815-1835) held on Java and native layers. "Unzombifying" corresponds to tab reloading and restoring the engine session.

Back to Bug 1450787 Comment 5