doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.23k stars 999 forks source link

`java.lang.IllegalStateException` bug in production app #1327

Closed adamsith100 closed 2 years ago

adamsith100 commented 2 years ago

Describe the bug java.lang.IllegalStateException bug in production app.

Unfortunately, it is causing the app to have a single-digit crash rate.

To Reproduce I have been unable to reliably reproduce on my device. The issue can be reproduced, but it's not clear to me how to reproduce reliably.

Example trace:

java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1795)
  at android.app.ContextImpl.startService (ContextImpl.java:1740)
  at android.content.ContextWrapper.startService (ContextWrapper.java:738)
  at android.content.ContextWrapper.startService (ContextWrapper.java:738)
  at com.guichaguri.trackplayer.module.MusicModule.waitForConnection (MusicModule.java:108)
  at com.guichaguri.trackplayer.module.MusicModule.getPosition (MusicModule.java:455)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:151)
  at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loop (Looper.java:246)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:226)
  at java.lang.Thread.run (Thread.java:923)

Environment (please complete the following information): This issue occurs in production across a number of devices in production. OS Android 8 to 11

react-native-info:

System:
    OS: macOS 11.6
    CPU: (4) x64 Intel(R) Core(TM) i3-1000NG4 CPU @ 1.10GHz
    Memory: 23.32 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.19.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /Users/_/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 14.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: ^0.63.2 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

What react-native-track-player version are you using?

2.1.1

Code

Audio is fired from an ordinary screen that manages a BackgroundTimer, Download logic, and a few API calls.

Additional dependencies:

"dependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@bugsnag/js": "^7.8.0",
    "@bugsnag/plugin-react": "^7.7.0",
    "@bugsnag/react-native": "^7.6.1",
    "@react-native-async-storage/async-storage": "^1.13.4",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.6",
    "@react-native-community/slider": "^3.0.3",
    "@react-native-firebase/analytics": "^13.0.0",
    "@react-native-firebase/app": "^13.0.0",
    "@react-native-firebase/crashlytics": "^13.0.0",
    "@react-native-firebase/dynamic-links": "^13.0.0",
    "@react-native-firebase/messaging": "^13.0.0",
    "@react-navigation/bottom-tabs": "^5.4.5",
    "@react-navigation/drawer": "^5.5.0",
    "@react-navigation/native": "^5.4.0",
    "@react-navigation/stack": "^5.2.13",
    "amplitude-js": "^7.4.1",
    "core-js": "^3.8.3",
    "expo-av": "^9.0.0",
    "fast-deep-equal": "^3.1.3",
    "jsc-android": "^241213.1.0",
    "lodash": "^4.17.19",
    "moment": "^2.24.0",
    "npm": "^6.14.14",
    "react": "16.13.1",
    "react-dom": "^17.0.1",
    "react-native": "^0.63.2",
    "react-native-appsflyer": "^6.2.10",
    "react-native-background-downloader": "^2.3.4",
    "react-native-background-timer": "^2.2.0",
    "react-native-code-push": "^6.3.0",
    "react-native-date-picker": "^3.3.2",
    "react-native-device-info": "^8.0.1",
    "react-native-dynamic": "^1.0.0",
    "react-native-elements": "^1.0.0-beta5",
    "react-native-fast-image": "^8.3.2",
    "react-native-fbsdk": "^2.0.0",
    "react-native-fs": "^2.16.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-global-props": "^1.1.1",
    "react-native-input-scroll-view": "^1.11.0",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal-datetime-picker": "git+https://git@github.com/...",
    "react-native-progress": "^4.0.3",
    "react-native-purchases": "^4.3.0",
    "react-native-rate": "^1.2.4",
    "react-native-reanimated": "^1.13.3",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.7.0",
    "react-native-size-matters": "^0.4.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.11.1",
    "react-native-svg-web": "^1.0.9",
    "react-native-swift": "^1.2.2",
    "react-native-track-player": "^2.1.1",
    "react-native-unimodules": "^0.12.0",
    "react-native-vector-icons": "^7.0.0",
    "react-native-version-check": "^3.4.2",
    "react-native-web": "^0.14.13",
    "react-native-web-swiper": "^2.2.1",
    "react-navigation-animated-switch": "^0.3.2",
    "react-redux": "^7.2.4",
    "reanimated-bottom-sheet": "^1.0.0-alpha.22",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.2.0",
    "regenerator-runtime": "^0.13.7",
    "rn-apple-healthkit": "^0.7.3",
    "rn-tourguide": "^2.7.1",
    "simple-crypto-js": "^2.5.0",
    "thunk": "0.0.1",
    "utf8": "^3.0.0",
    "uuid": "^3.3.3"
  },
ramisalem commented 2 years ago

Same here

bradfloodx commented 2 years ago

Hi @ramisalem and @adamsith100

We are doing a major overhaul of the Android logic here #1371 could you please help us test this?