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

Video crashing on Android because of ExoPlayer breaking changes #229

Closed
3 tasks done
Buthrakaur opened this issue Sep 21, 2023 · 8 comments
Closed
3 tasks done

Video crashing on Android because of ExoPlayer breaking changes #229

Buthrakaur opened this issue Sep 21, 2023 · 8 comments
Labels
Android Affects google devices running Android bug Something isn't working

Comments

@Buthrakaur
Copy link

Buthrakaur commented Sep 21, 2023

Requirements:

Please go through this checklist before opening a new issue

Environment

Please provide the following information about your environment:

  1. Development OS: Mac, Windows
  2. Device OS & Version: Android 13
  3. Version: @viro-community/react-viro 2.23.0 and React Native 0.71.3. We don't specify exoplayer version in our build.gradle file so it's picked up from viro.
  4. Device(s): Google Pixel 7A, Samsung A14 5G

Description

The app crashes when ViroVideo component is added to the AR scene with an exception:

java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/android/exoplayer2/upstream/BandwidthMeter;)V 
  in class Lcom/google/android/exoplayer2/trackselection/AdaptiveTrackSelection$Factory; or its super classes (declaration of 'com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection$Factory' appears in /data/app/~~w_ah16GTD9rXZlbGVbjXvw==/org.smart_guide.smartguide.T_00007-JIfgNEWRCUEvF3YUu5IqKw==/base.apk!classes2.dex)
  at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:98)
  at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2)
  at void com.viro.core.internal.PlatformUtil.access$000(int) (PlatformUtil.java:77)
  at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97)
  at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502)
  at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272)

There was a breaking change in exoplayer2 in the AdaptiveTrackSelection.Factory method which was handled in this commit: ReactVision/virocore@6bad81c but it looks like react-viro somehow didn't get the virocore version with this change even though it was merged into virocore years ago and links exoplayer version AFTER the breaking change which causes the exception and app crash. I tried to understand versioning of virocore vs react-viro but I must admit I got completely lost. I believe the is some mismatch between react-viro and virocore versions.

Reproducible Demo

  1. create a new React Native app
  2. add react-viro @viro-community/[email protected]
  3. create a simple AR scene with ViroVideo component
  4. run the app causing the AR scene to render => app crashes
const styles = StyleSheet.create({
  viroScene: { flex: 1 },
});

const scene = (
  <ViroARScene>
            <ViroNode position={[0, 0, 0]} width={1.3} height={1}>
              <ViroVideo rotation={[rotateX90 ? -90 : 0, 0, 0]} position={[0, 0, 0]} loop width={1.3} height={1} source="https://download.samplelib.com/mp4/sample-5s.mp4" />
            </ViroNode>
  </ViroARScene>
);

return (<ViroARSceneNavigator autofocus={true} initialScene={scene} style={styles.viroScene} />);
@robertjcolley robertjcolley added bug Something isn't working Android Affects google devices running Android labels Jan 31, 2024
@Buthrakaur
Copy link
Author

related issue from the original repository: viromedia/viro#1004

@Buthrakaur
Copy link
Author

I just tried current version of viro-starter-kit with latest viro release (react-viro 2.41.0) and the issue still persist - the exception is a bit different now though:

java_vm_ext.cc:591] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/media3/exoplayer/trackselection/DefaultTrackSelector;
java_vm_ext.cc:591]   at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:91)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272)
java_vm_ext.cc:591] Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.media3.exoplayer.trackselection.DefaultTrackSelector" on path: DexPathList[[zip file "/data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/base.apk"],nativeLibraryDirectories=[/data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/lib/arm64, /data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
java_vm_ext.cc:591]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:259)
java_vm_ext.cc:591]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
java_vm_ext.cc:591]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
java_vm_ext.cc:591]   at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:91)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272)
java_vm_ext.cc:591] 
java_vm_ext.cc:591]     in call to NewGlobalRef
java_vm_ext.cc:591]     from void com.viro.core.internal.PlatformUtil.runTask(int)

@Buthrakaur
Copy link
Author

Hello @robertjcolley , could you please review the PR ReactVision/virocore#154 and possibly release new react-viro version with the fix?

@Buthrakaur Buthrakaur changed the title Video crashing on Android because of AdaptiveTrackSelection.Factory (exoplayer) breaking change Video crashing on Android because of ExoPlayer breaking changes Apr 9, 2024
@Dani2097
Copy link

@Buthrakaur I've just emailed you the module that I managed to get working with your fix. You helped me a lot

@JBhrayn
Copy link

JBhrayn commented Apr 22, 2024

Currently having this issue on my expo dev build app. I don't get any error message, the app just crashes.

@Buthrakaur
Copy link
Author

Hi @Dani2097 , I'm struggling to find the email from you - could you please mention your email address or post the message simply here?

@andresteves
Copy link

I just tried current version of viro-starter-kit with latest viro release (react-viro 2.41.0) and the issue still persist - the exception is a bit different now though:

java_vm_ext.cc:591] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/media3/exoplayer/trackselection/DefaultTrackSelector;
java_vm_ext.cc:591]   at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:91)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272)
java_vm_ext.cc:591] Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.media3.exoplayer.trackselection.DefaultTrackSelector" on path: DexPathList[[zip file "/data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/base.apk"],nativeLibraryDirectories=[/data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/lib/arm64, /data/app/~~JeBeBXFe1Yr4iL_tu48CFA==/com.virostarterkit-TSBOdFAY987HZPWdvzrzTw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
java_vm_ext.cc:591]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:259)
java_vm_ext.cc:591]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
java_vm_ext.cc:591]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
java_vm_ext.cc:591]   at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:91)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1)
java_vm_ext.cc:591]   at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502)
java_vm_ext.cc:591]   at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272)
java_vm_ext.cc:591] 
java_vm_ext.cc:591]     in call to NewGlobalRef
java_vm_ext.cc:591]     from void com.viro.core.internal.PlatformUtil.runTask(int)

You need to use new dependcy on Android
def media3_version = "1.3.1"

// For media playback using ExoPlayer
implementation "androidx.media3:media3-exoplayer:$media3_version"

@Buthrakaur
Copy link
Author

the PR ReactVision/virocore#154 with fix was already merged so I'm closing this - waiting for release though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Affects google devices running Android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants