APP crashing when device loses internet connection [Android]
Hi All,
This is happening on a real device, when the device loses internet connect, then recover it crashes the app. fabric.io is showing these logs
MusicModule.java line 102
com.guichaguri.trackplayer.module.MusicModule.waitForConnection
Fatal Exception: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=/com.guichaguri.trackplayer.service.MusicService }: app is in background uid UidRecord{4df9b02 u0a156 CAC bg:+1m6s332ms idle change:cached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1522)
at android.app.ContextImpl.startService(ContextImpl.java:1478)
at android.content.ContextWrapper.startService(ContextWrapper.java:650)
at android.content.ContextWrapper.startService(ContextWrapper.java:650)
at com.guichaguri.trackplayer.module.MusicModule.waitForConnection(MusicModule.java:102)
at com.guichaguri.trackplayer.module.MusicModule.stop(MusicModule.java:322)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
at java.lang.Thread.run(Thread.java:764)
version: 1.1.4
@ntk860 Are you saying you've been able to reproduce this?
We have been trying to track down the cause in #473
Oh that would be nice if it is the cause of the crash thanks a lot for that @ntk860 ! @Guichaguri what do you think of it?
@ntk860 What exactly is the circumstance that causes this for you?
Are you saying:
- start playing a track
- disable connection
- track reaches end of buffer
- enable connection
- the error happens?
In the case I described, I just get a playback-error.
@curiousdustin, when I go to a zone where the device loses internet connection, and then I get back to a good zone and the device reestablish the connection it crash the app and throw the exception. I run ads on my app (using react-native-video). It usually happens when the audio from (react-native-audio-player) ends, then a ad comes on (react-native-video), if the device loses connection while the content on (react-native-video) is playing, when the ads end and I try to go to the next track, thats where the app crash.
I'm getting a similar crash happening only on Android 9. See crash log below:

@The0racle Same issue. Did you solve this?
@Saehanseul no
I've deployed an app using this library and have around 500 users now, and this crash is my top Crashlytics report right now (about 10-20 reports so far). although upgrading React-Native to 0.60+ reduced number of reports considerably. Unfortunately since my users does not have any significance computer knowledge it's hard to asses why this happens and get a decent scenario from them.
@Guichaguri @curiousdustin I'm also experiencing this crash
We are using this with a pretty substantial userbase and this is our most frequent issue by a wide margin.
+1
We are using this with a pretty substantial userbase and this is our most frequent issue by a wide margin.
I am quite sure it is not related to loss of internet
I'm getting a similar crash happening only on Android 9. See crash log below:
Same issue here. Is very annoying

+1
+1