react-native-track-player: Calling TrackPlayer.Destroy() in useEffect cleanup function crashes ios and "fries" android on 2.2.0-rc4

Describe the Bug A clear and concise description of what the bug is.

On the page where we use the track player we have a useEffect cleanup function that when the page is unloaded the TrackPlayer is destroyed. On RC4, calling this function on iOS causes an immediate hard crash. The type that triggers a popup from MacOs saying the app quit unexpectedly. On Android it technically doesn’t crash, but the app begins to display extremely weird behavior afterwards. For instance, despite not saying so, it loses connection to metro. At least so far as fast refresh goes. Additionally, we are using Firebase and all of our Firestore listeners stop working. Like I said… weird behavior.

Steps To Reproduce How can someone else reproduce this bug?

Call TrackPlayer.Destroy() during unmounting of the track player on RC4

Code To Reproduce Please provide a simple code example that allows others to replicate the bug.

useEffect(() => { return () => { TrackPlayer.destroy(); }; }, []);

Environment Info: Paste the results of npx react-native info System: OS: macOS 12.4 CPU: (12) x64 Intel® Core™ i9-8950HK CPU @ 2.90GHz Memory: 791.21 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.13.2 - /usr/local/bin/node Yarn: 1.22.19 - ~/.yarn/bin/yarn npm: 8.1.2 - /usr/local/bin/npm Watchman: 2022.03.14.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 29, 30, 31 Build Tools: 29.0.2, 30.0.2, 31.0.0, 32.0.0 System Images: android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8512546 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.13 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found info React Native v0.69.1 is now available (your project is running on v0.68.2).

Paste the exact react-native-track-player version you are using Exact same code works on 2.2.0-RC3, the crash occurs on 2.2.0-RC4

Real device? Or simulator? Both (iOS and Android)

What OS are you running? MacOS

How I can Help What can you do to help resolve this? Have you investigated the underlying JS or Swift/Android code causing this bug? Can you create a Pull Request with a fix?

There’s a potential this is related to this issue, but for now, I suggest to anyone encountering this issue just roll back the version.

I can post the crash log from MacOs, but to be honest, I spent hours trying to figure it out before posting here and I didn’t see anything worth while in it. But happy to share it if you think it can help!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

The reset issue has been fixed on another ticket. The destroy issue I have not been able to reproduce. Please try to create a repro based on the example project.

I don’t have the ability to release. But I hope for one in the next week or two. I suggest using RC3 if this is a showstopper for you.

++ .reset() as well