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.3k stars 1.01k forks source link

Minimal Expo 52 app crashes when using form sheet modals #2401

Open doughsay opened 3 days ago

doughsay commented 3 days ago

Describe the Bug In a minimal expo 52 app with new arch disabled, having a set-up track player causes a crash when attempting to open a form sheet modal, but only after first closing the app once.

Steps To Reproduce I have provided a minimal reproducing case that should demonstrate the issue. I've also recorded a short video showing the issue:

rntp-crash.webm

Steps:

  1. open the app
  2. see that the form sheet modal opens
  3. close the app (not just background)
  4. open the app again
  5. try and open the modal and see that it crashes instead

This only happens when track player has been set up.

Code To Reproduce Minimal expo repro app here: https://github.com/doughsay/expo-test-app

Replicable on Example App? Can you replicate this bug in the React Native Track Player Example App?

N/A / example app doesn't use expo

Environment Info:

System:
  OS: Linux 6.9 Pop!_OS 22.04 LTS
  CPU: (16) x64 AMD Ryzen 7 7800X3D 8-Core Processor
  Memory: 12.14 GB / 30.50 GB
  Shell:
    version: 3.3.1
    path: /usr/bin/fish
Binaries:
  Node:
    version: 22.11.0
    path: ~/.asdf/installs/nodejs/22.11.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.yarn/bin/yarn
  npm:
    version: 10.9.0
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 4.9.0
    path: /usr/bin/watchman
SDKs:
  Android SDK:
    API Levels:
      - "30"
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 34.0.0
      - 35.0.0
      - 35.0.0
    System Images:
      - android-30 | Google Play Intel x86 Atom
      - android-33 | Google Play Intel x86_64 Atom
      - android-34 | Google Play Intel x86_64 Atom
      - android-35 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: AI-242.23339.11.2421.12550806
Languages:
  Java:
    version: 22.0.2
    path: /home/chris/.asdf/shims/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.2
    wanted: latest
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Paste the exact react-native-track-player version you are using: react-native-track-player@4.1.1 Real device? Or simulator?: both What OS are you running?: linux

How I can Help What can you do to help resolve this?

If this is a bug in react-native-screens or expo, I can help by opening issues with those repos as well; but since it only happens with RNTP setup, I figured I'd ask here first for some guidance.

Have you investigated the underlying JS or Swift/Android code causing this bug?

No, I don't really know where to start.

Can you create a Pull Request with a fix?

I don't know what the problem is yet.

puckey commented 3 days ago

Guessing that this is related to the timers bug which will be fixed when this pr ships: https://github.com/facebook/react-native/pull/47496

lovegaoshi commented 3 days ago

im rather inclined to believe this is an expo issue. try reproducing without rntp.

doughsay commented 2 days ago

im rather inclined to believe this is an expo issue. try reproducing without rntp.

I tried and wasn't able to, the only thing to start causing it was adding rntp. I was thinking it might have something to do with the headless js task that rntp creates? So I was thinking of trying to repro today with a non-rntp headless task, if that's even possible on expo.

doughsay commented 2 days ago

Guessing that this is related to the timers bug which will be fixed when this pr ships: https://github.com/facebook/react-native/pull/47496

I thought this only affected the new architecture, which I have turned off.

lovegaoshi commented 2 days ago

u can register a headless task via AppRegistry.registerHeadlessTask. see https://reactnative.dev/docs/headless-js-android

doughsay commented 2 days ago

I tried using expo-background-fetch to repro, no dice; works as expected. But I guess that's not really the same thing...?

doughsay commented 2 days ago

opened an issue here, maybe someone there can help me: https://github.com/software-mansion/react-native-screens/issues/2507

doughsay commented 2 days ago

Updated the repro repo to react-native 0.76.2, it didn't help

doughsay commented 2 days ago

I also just attempted to switch to the new architecture (and apply the pending RNTP patches for it), but it also didn't help. I get the exact same crash in the exact same way.

Here are the new-arch updates I applied: https://github.com/doughsay/expo-test-app/compare/main...new-arch

lovegaoshi commented 2 days ago

i happen to use expo 52, react-native-screens via react navigation. RNTP is stable under either the new or old arch currently. though i dont use the expo modal, I use paper's modal/portal and its been fine.

i doubt this is the issue since its screen related, but i dont see an android folder with the provided repo. i dont think ppl typically use the expo managed/plugin route with this lib, bc nobody wrote one. id recommend u installing expo following this, onto the example app https://github.com/doublesymmetry/react-native-track-player/pull/2395, upgrading to 0.76.2, then try the same thing in prod.

doughsay commented 2 days ago

Thanks, I'll see about doing that tomorrow. Which version of react-native-screens are you on? I was wondering if it's something related to the freshly released 4.0.0. but even still, if you're not using their modals I guess you still might not see any problems...