viro icon indicating copy to clipboard operation
viro copied to clipboard

Video crashing on Android because of ExoPlayer breaking changes

Open Buthrakaur opened this issue 2 years ago • 6 comments

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: https://github.com/ViroCommunity/virocore/commit/6bad81c71f2de770a2415d03c1b912111da8e1d1 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} />);

Buthrakaur avatar Sep 21 '23 14:09 Buthrakaur

related issue from the original repository: https://github.com/viromedia/viro/issues/1004

Buthrakaur avatar Apr 04 '24 11:04 Buthrakaur

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 avatar Apr 04 '24 15:04 Buthrakaur

Hello @robertjcolley , could you please review the PR https://github.com/NativeVision/virocore/pull/154 and possibly release new react-viro version with the fix?

Buthrakaur avatar Apr 09 '24 15:04 Buthrakaur

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

Dani2097 avatar Apr 12 '24 12:04 Dani2097

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

JBhrayn avatar Apr 22 '24 00:04 JBhrayn

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

Buthrakaur avatar Apr 22 '24 11:04 Buthrakaur