Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception when expo-av used with react-native-track-player #18937

Closed
KrisLau opened this issue Aug 31, 2022 · 18 comments
Closed

Fatal Exception when expo-av used with react-native-track-player #18937

KrisLau opened this issue Aug 31, 2022 · 18 comments

Comments

@KrisLau
Copy link

KrisLau commented Aug 31, 2022

Summary

I get a fatal exception when I call createAsync when expo-av used with react-native-track-player. It crashes without throwing an error so I only got the log on Android Studio logcat

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.appname, PID: 17129
    java.lang.RuntimeException: Unable to stop service com.doublesymmetry.trackplayer.service.MusicService@c92725: kotlin.UninitializedPropertyAccessException: lateinit property player has not been initialized
        at android.app.ActivityThread.handleStopService(ActivityThread.java:4375)
        at android.app.ActivityThread.access$1900(ActivityThread.java:237)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: kotlin.UninitializedPropertyAccessException: lateinit property player has not been initialized
        at com.doublesymmetry.trackplayer.service.MusicService.onDestroy(MusicService.kt:471)
        at android.app.ActivityThread.handleStopService(ActivityThread.java:4355)
        at android.app.ActivityThread.access$1900(ActivityThread.java:237) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 

What platform(s) does this occur on?

Android

Environment

warn Package @sentry/react-native contains invalid configuration: "dependency.platforms.ios.sharedLibraries" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Fetching system and libraries information...
System:
    OS: macOS 12.5
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 54.57 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
    Watchman: 2022.07.04.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /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: 31, 33
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
      System Images: android-30 | Google Play Intel x86 Atom, android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.12 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^18.2.0 => 18.2.0 
    react-native: ^0.69.5 => 0.69.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Minimal reproducible example

https://github.com/KrisLau/reproExoplayer

@KrisLau KrisLau added the needs validation Issue needs to be validated label Aug 31, 2022
@KrisLau KrisLau changed the title Fatal Exception when used with react-native-track-player Fatal Exception when call createAsync when expo-av used with react-native-track-player Sep 1, 2022
@KrisLau KrisLau changed the title Fatal Exception when call createAsync when expo-av used with react-native-track-player Fatal Exception when expo-av used with react-native-track-player Sep 1, 2022
@KrisLau
Copy link
Author

KrisLau commented Sep 2, 2022

doublesymmetry/react-native-track-player#1678 suggests that it might be a version mismatch for exoplayer. I think exoplayer might need to be updated to 2.18.1.

EDIT: Ok yeah it's definitely a exoplayer version mismatch: https://stackoverflow.com/questions/68496246/is-it-possible-to-have-two-different-versions-of-a-same-library-coexist

@KrisLau
Copy link
Author

KrisLau commented Sep 2, 2022

@Kudo
Copy link
Contributor

Kudo commented Sep 5, 2022

@KrisLau you could add the following gradle expression to android/app/build.gradle for pinning down the exoplayer version

configurations.all {
    resolutionStrategy {
        force 'com.google.android.exoplayer:exoplayer:2.18.1', 'com.google.android.exoplayer:extension-okhttp:2.18.1'
    }
}

@KrisLau
Copy link
Author

KrisLau commented Sep 6, 2022

@Kudo Doing so crashes the app because expo-av underlying implementation uses methods and classes from 2.13.3 which have been deprecated now. react-native-track-player mentions this in one of of their issues:

ExoPlayer introduces breaking changes in minor versions unfortunately so things like this are going to be hard or impossible to prevent on our end.

All I can say is, for those having this issue, wait until react-native-video updates to the newest version of ExoPlayer.

react-native-video also has an open issue to upgrade the version:

So the only way for the packages to work together seems to be for expo-av to update to 2.18.1 unless there's a way to have two versions of exoplayer but from what i could tell from searching online that is not possible.


Error with the configurations.all workaround:

2022-09-06 08:56:20.968 22689-22689/com.example E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example, PID: 22689
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/exoplayer2/Player$EventListener;
        at expo.modules.av.player.PlayerData.createUnloadedPlayerData(PlayerData.java:192)
        at expo.modules.av.video.VideoView.setSource(VideoView.java:365)
        at expo.modules.av.video.VideoView.setSource(VideoView.java:334)
        at expo.modules.av.video.VideoViewManager.setSource(VideoViewManager.java:103)
        at java.lang.reflect.Method.invoke(Native Method)
        at expo.modules.core.ViewManager.updateProp(ViewManager.java:90)
        at expo.modules.adapters.react.views.ViewManagerAdapterUtils.setProxiedProperties(ViewManagerAdapterUtils.java:51)
        at expo.modules.adapters.react.views.SimpleViewManagerAdapter.setProxiedProperties(SimpleViewManagerAdapter.java:49)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:93)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
        at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:48)
        at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:144)
        at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:77)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281)
        at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:727)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.exoplayer2.Player$EventListener" on path: DexPathList[[zip file "/data/app/~~fXoHBjS-A6-fInm26J5tzQ==/com.example-YJohrpES32qHHoAAupKNbw==/base.apk"],nativeLibraryDirectories=[/data/app/~~fXoHBjS-A6-fInm26J5tzQ==/com.epicsports.epicmobile-YJohrpES32qHHoAAupKNbw==/lib/x86, /data/app/~~fXoHBjS-A6-fInm26J5tzQ==/com.epicsports.epicmobile-YJohrpES32qHHoAAupKNbw==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at expo.modules.av.player.PlayerData.createUnloadedPlayerData(PlayerData.java:192) 
        at expo.modules.av.video.VideoView.setSource(VideoView.java:365) 
        at expo.modules.av.video.VideoView.setSource(VideoView.java:334) 
        at expo.modules.av.video.VideoViewManager.setSource(VideoViewManager.java:103) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at expo.modules.core.ViewManager.updateProp(ViewManager.java:90) 
        at expo.modules.adapters.react.views.ViewManagerAdapterUtils.setProxiedProperties(ViewManagerAdapterUtils.java:51) 
        at expo.modules.adapters.react.views.SimpleViewManagerAdapter.setProxiedProperties(SimpleViewManagerAdapter.java:49) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:93) 
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136) 
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56) 
        at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:48) 
        at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:144) 
        at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:77) 
        at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281) 
        at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194) 
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110) 
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081) 
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29) 
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175) 
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85) 
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970) 
        at android.view.Choreographer.doCallbacks(Choreographer.java:796) 
        at android.view.Choreographer.doFrame(Choreographer.java:727) 
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
2022-09-06 08:56:27.153 23465-23465/com.example E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example, PID: 23465
    java.lang.RuntimeException: Unable to stop service com.doublesymmetry.trackplayer.service.MusicService@7c0ce65: kotlin.UninitializedPropertyAccessException: lateinit property player has not been initialized
        at android.app.ActivityThread.handleStopService(ActivityThread.java:4375)
        at android.app.ActivityThread.access$1900(ActivityThread.java:237)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: kotlin.UninitializedPropertyAccessException: lateinit property player has not been initialized
        at com.doublesymmetry.trackplayer.service.MusicService.onDestroy(MusicService.kt:471)
        at android.app.ActivityThread.handleStopService(ActivityThread.java:4355)
        at android.app.ActivityThread.access$1900(ActivityThread.java:237) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 

@Kudo
Copy link
Contributor

Kudo commented Sep 7, 2022

@KrisLau oh that's bad. i'm accepting this issue and plan to upgrade exoplayer. thanks for reporting this.

@Kudo Kudo added Android AV Issue accepted and removed needs validation Issue needs to be validated labels Sep 7, 2022
@Kudo Kudo self-assigned this Sep 7, 2022
@expo-bot
Copy link
Collaborator

expo-bot commented Sep 7, 2022

Thank you for filing this issue!
This comment acknowledges we believe this may be a bug and there’s enough information to investigate it.
However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

@KrisLau
Copy link
Author

KrisLau commented Sep 7, 2022

@Kudo No thank you for all the work you guys put in, I really appreciate it!

Is there a rough estimate for how long the upgrade will take? I'm just trying to decide if I should downgrade track player in the meantime haha but I'm not sure if their older version support react native > 0.69

@fbotalla
Copy link

Same exact problem here.
Thank you for working on this issue @Kudo!

Is there an ETA on this ? no rush or stress, just trying to decide a few things based on its timing.

@KrisLau
Copy link
Author

KrisLau commented Oct 3, 2022

@fbotalla hey just thought I'd let you know that it is just waiting to be merged so it should be done soon #19332

@fbotalla
Copy link

fbotalla commented Oct 5, 2022

So now do we have to wait until the expo-av gets published?

@KrisLau
Copy link
Author

KrisLau commented Oct 6, 2022

@fbotalla yeah basically but I'm not sure which version it is releasing in and when. you could also just use patch-package in the meantime. It'll be released in v13 looks like:

@KrisLau
Copy link
Author

KrisLau commented Oct 10, 2022

@Kudo Just out of curiosity is there a way to see the estimated date for a version to be released?

@fbotalla
Copy link

@KrisLau It's out for beta testing at the moment.

expo-av@13.0.0-beta.1

I tested it and it worked as expected.. so that's great news!

@KrisLau
Copy link
Author

KrisLau commented Oct 10, 2022

@fbotalla Oh that's good! i did a yarn outdated and couldn't see it hahah I'll try it in a second

@Kudo
Copy link
Contributor

Kudo commented Oct 10, 2022

Oh that's good! i did a yarn outdated and couldn't see it hahah I'll try it in a second

because it's for sdk 47 which will be open to beta 😅

@fbotalla
Copy link

@KrisLau
I also had to use
expo@47.0.0-alpha.1
in order to use expo-av properly in my tests.

But from my tests it has been working like a champ.. so.. thank you @Kudo !

@KrisLau
Copy link
Author

KrisLau commented Oct 11, 2022

Ohh ok sorry for all the trouble, thanks for all the help @fbotalla and thanks for all the awesome work @Kudo !

@Kudo
Copy link
Contributor

Kudo commented Nov 17, 2022

as expo sdk 47 is released, i'm closing this issue. thanks for everyone to report this.

@Kudo Kudo closed this as completed Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants