Description
Hey Pocketcasterinos,
I'm a big long-term fan and my 1509 days total on the stats screen confirms that.
I run PocketCasts on my "podcast phone", a Nokia G42 with 4GB RAM (4GB ZRAM SWAP) which is clearly on the low and but used to work just fine but for a while now keeps dying in the background when small things happen like a WiFi change that triggers a bunch of background tasks.
I recorded a few Perfetto traces and noticed that there is seemingly a lot of UI work happening in the background causing both CPU and memory pressure.
In PlaybackManager.kt, there is a 1Hz observer that pushes PlaybackState while audio plays. In the player module, this causes eight Composables to run ungated with collectAsState() instead of collectAsStateWithLifecycle() so they keep collecting and recomposing while the host fragment view exists. That means it will keep the RenderThread busy while the app is backgrounded. As long as the app keeps requesting frames, Android's process-state heuristic treats it as foreground, the kernel weighs it against the actually-visible app, and on a 4 GB device PC loses the comparison.
Here's me backgrounding PocketCasts and opening Chrome. It survives for about a minute before it gets killed:
**Is there any particular reason not to use collectAsStateWithLifecycle() in player/view/PlayerHeaderFragment.kt? That would pause the UI updates while the app is backgrounded.
The always-invalidating ChapterProgressBar
player/view/ChapterProgressBar.kt currently has an unguarded invalidation which also causes more re-renders than necessary. If you guarded the invalidate() with an early return
if (field == value) return
and visibility check
if (isAttachedToWindow && isShown) invalidate()
you could save a lot of cycles.
Let me know if this resonates and makes sense. I'd be happy to give this a go myself to try out but didn't want to lose the data on my phone to try it out.
Step-by-step reproduction instructions
- Run PocketCasts in the background on low-end phone
- Open another apps or sometimes just the keyboard
- OOM killer comes after PocketCasts 💀
Screenshots or screen recording
No response
Did you search for existing bug reports?
Device, Operating system, and Pocket Casts app version
Nokia G42, Android 15.
Description
Hey Pocketcasterinos,
I'm a big long-term fan and my 1509 days total on the stats screen confirms that.
I run PocketCasts on my "podcast phone", a Nokia G42 with 4GB RAM (4GB ZRAM SWAP) which is clearly on the low and but used to work just fine but for a while now keeps dying in the background when small things happen like a WiFi change that triggers a bunch of background tasks.
I recorded a few Perfetto traces and noticed that there is seemingly a lot of UI work happening in the background causing both CPU and memory pressure.
In
PlaybackManager.kt, there is a 1Hz observer that pushesPlaybackStatewhile audio plays. In the player module, this causes eightComposables to run ungated withcollectAsState()instead ofcollectAsStateWithLifecycle()so they keep collecting and recomposing while the host fragment view exists. That means it will keep the RenderThread busy while the app is backgrounded. As long as the app keeps requesting frames, Android's process-state heuristic treats it as foreground, the kernel weighs it against the actually-visible app, and on a 4 GB device PC loses the comparison.Here's me backgrounding PocketCasts and opening Chrome. It survives for about a minute before it gets killed:
**Is there any particular reason not to use
collectAsStateWithLifecycle()inplayer/view/PlayerHeaderFragment.kt? That would pause the UI updates while the app is backgrounded.The always-invalidating
ChapterProgressBarplayer/view/ChapterProgressBar.ktcurrently has an unguarded invalidation which also causes more re-renders than necessary. If you guarded theinvalidate()with an early returnand visibility check
you could save a lot of cycles.
Let me know if this resonates and makes sense. I'd be happy to give this a go myself to try out but didn't want to lose the data on my phone to try it out.
Step-by-step reproduction instructions
Screenshots or screen recording
No response
Did you search for existing bug reports?
Device, Operating system, and Pocket Casts app version
Nokia G42, Android 15.