question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SDK 45 BETA-8 [android][expo-av] - Crash randomly when un-mounting or pausing/unloading videos

See original GitHub issue

Summary

Related: https://github.com/expo/expo/pull/16611

This PR did not fix the issue unfortunately. It never happened to me on expo-av 11.1.0 though, only after the upgrade to Expo SDK 45

Your app just crashed. See the error below.

java.lang.IllegalStateException: Player is accessed on the wrong thread. See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
at com.google.android.exoplayer2.SimpleExoPlayer.verifyApplicationThread(SimpleExoPlayer.java:1953)
at com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady(SimpleExoPlayer.java:1466)
at expo.modules.av.player.SimpleExoPlayerData.pauseImmediately(SimpleExoPlayerData.java:247)
at expo.modules.av.player.PlayerData.onPause(PlayerData.java:477)
at expo.modules.av.video.VideoView.onPause(VideoView.java:521)
at expo.modules.av.AVManager.lambda$onHostPause$2$expo-modules-av-AVManager(AVManager.java:236)
at expo.modules.av.AVManager$$ExternalSyntheticLambda2.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:224)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:919)

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

SDK 45-beta-8

Environment

  expo-env-info 1.0.3 environment info:
    System:
      OS: macOS 12.3.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.19.1 - /usr/local/opt/node@14/bin/node
      Yarn: 1.22.17 - /usr/local/bin/yarn
      npm: 6.14.16 - /usr/local/opt/node@14/bin/npm
    Managers:
      CocoaPods: 1.11.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.6953283
      Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
    npmGlobalPackages:
      eas-cli: 0.51.0
      expo-cli: 5.4.2
    Expo Workflow: bare

Reproducible demo

This happens pretty randomly, therefore no MCVE. I try to provide quick issues.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mnightingalecommented, Apr 28, 2022

It appears for Video SimpleExoPlayerData.load is getting called on the main thread (I tried via props and loadAsync). But Audio via Audio.Sound.createAsync is on the native module thread.

I think the previous PR will have fixed it for Audio but broken Video.

To fix it I think we need to decide which is the correct thread to interactive with it from, as far as I can see from the docs ExoPlayer handles its own threading so it doesn’t really matter which we use as long as its consistent.

I think making sure it uses the main thread is the simplest as the previous PR can be reverted.

It’s also an opportunity to fix: https://github.com/expo/expo/blob/5e13e1e137060e3dc61bf3a6274488f390bf587f/packages/expo-av/android/src/main/java/expo/modules/av/player/SimpleExoPlayerData.java#L129-L133

The tricky bit will be ensuring every interaction with the player is on the correct thread.

0reactions
hirbodcommented, Apr 29, 2022

@mnightingale I can confirm that your PR did fully fix the issue for me. I could not reproduce it anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found