THEOplayer / react-native-theoplayer

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

Fix/Android: crash in Media Service #325

Open kot331107 opened 1 month ago

kot331107 commented 1 month 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