THEOplayer / react-native-theoplayer

A React Native THEOplayerView component
https://theoplayer.github.io/react-native-theoplayer/
MIT License
65 stars 21 forks source link

Fix/Android: crash in Media Service #325

Closed kot331107 closed 2 months ago

kot331107 commented 5 months ago

Lib versions:

    "react-native-theoplayer": "7.2.0",
    "theoplayer": "7.4.0",

Description:

We have a repetitive crash in Android app with the following logcat:

Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{4020d8b u0 com.gotv.nflgamecenter.us.lite/com.theoplayer.media.MediaPlaybackService}
       at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2245)
       at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2216)
       at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8762)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Testing plan:

The issue occurs only in production so we're not able to provide a repro app/steps/snippets whatever. As we had this crash before and were able to resolve it in this way I'd like to suggest these changes for your codebase. Also let's keep it open until we have a confirmation with the latest stats from Crashlytics that the crash is gone (it might take some time). Please lmk if any objections @tvanlaerhoven

tvanlaerhoven commented 3 months ago

Also adding this related issue from Google's tracker here: https://issuetracker.google.com/issues/307329994

kot331107 commented 2 months ago

closing as it didn't resolve on our end (we've tested it as a patch)