Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Service killed if main activity cleaned up on Android #6

Open
jasongrishkoff opened this issue Mar 5, 2017 · 4 comments
Open

Service killed if main activity cleaned up on Android #6

jasongrishkoff opened this issue Mar 5, 2017 · 4 comments

Comments

@jasongrishkoff
Copy link

Hey so, if my main React Native application is cleared up by Android for memory, the service also stops. This kinda sucks because it means if they're listening to a song, it ends mid-way. I've tried as much as I can to lower the memory footprint of my app, but if I'm doing heavy browsing on multiple apps in the foreground, Android cleans it up.

Any idea how to tweak the code to keep the RNAudioStreamer service alive and avoid Android from killing it when it clears up memory from the main activity? I've been looking into:

  1. startForeground
  2. START_STICKY or START_REDELIVER_INTENT

Both might be helpful, but not sure where I'd throw those into the code...

@jasongrishkoff
Copy link
Author

Here's a logcat dump of what happens. The music stops instantly.

03-07 11:24:21.374  3336  3336 I Finsky  : [1] com.google.android.finsky.x.i.b(1060): Stopping LocationRefresher
03-07 11:24:21.405 11409 11420 I art     : Background partial concurrent mark sweep GC freed 14445(743KB) AllocSpace objects, 3(148KB) LOS objects, 29% free, 38MB/54MB, paused 2.546ms total 392.958ms
03-07 11:24:21.424  3336  3336 I Finsky  : [1] com.google.android.finsky.utils.cj.onTrimMemory(17): Memory trim requested to level 20
03-07 11:24:21.430  3336  3336 I Finsky  : [1] com.google.android.finsky.utils.cj.onTrimMemory(21): Flushing in-memory image cache
03-07 11:24:21.604 11409 12088 I MediaFocusControl: AudioFocus  removeFocusStackEntryOnDeath(): removing entry for android.os.BinderProxy@3d5cf04
03-07 11:24:21.606 11409 14164 I ActivityManager: Process com.decoderhq.indieshuffle (pid 2439) has died
03-07 11:24:21.606 11409 14164 D ActivityManager: cleanUpApplicationRecord -- 2439
03-07 11:24:21.606 11409 18897 D GraphicsStats: Buffer count: 11
03-07 11:24:21.607 11409 14167 I WindowManager: WIN DEATH: Window{fa8801f u0 com.decoderhq.indieshuffle/com.decoderhq.indieshuffle.MainActivity}
03-07 11:24:21.607 11409 14164 W ActivityManager: Scheduling restart of crashed service com.decoderhq.indieshuffle/fm.indiecast.rnaudiostreamer.NotificationService in 117678ms
03-07 11:24:21.608 11409 14164 W ActivityManager: Scheduling restart of crashed service com.decoderhq.indieshuffle/com.tanguyantoine.react.MusicControlNotification$NotificationService in 127678ms
03-07 11:24:21.612  3725 23993 E OMXNodeInstance: !!! Observer died. Quickly, do something, ... anything...
03-07 11:24:21.620   396   396 E lowmemorykiller: Error writing /proc/3018/oom_score_adj; errno=22
03-07 11:24:21.634 21100 21127 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
03-07 11:24:21.653  3336  3336 I Finsky  : [1] com.google.android.finsky.utils.cj.onTrimMemory(17): Memory trim requested to level 80
03-07 11:24:21.697 11203 11216 W APM::EffectDescriptor: unregisterEffect() unknown effect ID 4835
03-07 11:24:21.742 11203 11289 D audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback headphones
03-07 11:24:21.743 11203 11289 D audio_hw_primary: disable_snd_device: snd_device(5: headphones)
03-07 11:24:21.750 11203 11216 W AudioFlinger: session id 16817 not found for pid 2439
03-07 11:24:21.750 11203 11216 W AudioFlinger: removeEffect_l() 0xf2b83780 cannot promote chain for effect 0xf3397680
03-07 11:24:21.750 11203 11216 W APM::EffectDescriptor: unregisterEffect() unknown effect ID 4835

@anderslemke
Copy link

Hi @jasongrishkoff
We're seeing similar things on our app.
Did you find a solution to this?

@jasongrishkoff
Copy link
Author

Hey @anderslemke, we've been working on a new project over here: https://github.com/Guichaguri/react-native-track-player/ (in the dev branch).

It's much more functional!

@anderslemke
Copy link

Hi @jasongrishkoff
Thanks!
I will check it out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants