TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.14k stars 2.88k forks source link

[BUG]: [Android] Trying to use IAM SDK results in a crash #4093

Open sntg-p opened 3 weeks ago

sntg-p commented 3 weeks ago

Version

6.4.3

What platforms are you having the problem on?

Android

System Version

14

On what device are you experiencing the issue?

Simulator

Architecture

Old architecture

What happened?

I'm expecting a test ad to get shown but instead the app seems to crash.

Reproduction

repository link

Reproduction

I'm using a test VAST URI provided by Google as adTagUrl. I've also set the onReceivedAdEvent to log the received event, which gets fired before and after the exception is thrown.

2024-08-15 20:33:37.345 25052-25228 ReactNativeJS      I  'onReceiveAdEvent', { data: {}, event: 'LOADED' }
2024-08-15 20:33:37.377 25052-25404 AndroidRuntime     E  FATAL EXCEPTION: ExoPlayer:Playback
                                                          Process: com.flixxo.apps.flixxoapp.dev, PID: 25052
                                                          java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.media3.exoplayer.source.MediaSource.addEventListener(android.os.Handler, androidx.media3.exoplayer.source.MediaSourceEventListener)' on a null object reference
                                                            at androidx.media3.exoplayer.source.CompositeMediaSource.prepareChildSource(CompositeMediaSource.java:120)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource.access$500(AdsMediaSource.java:63)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource$AdMediaSourceHolder.initializeWithMediaSource(AdsMediaSource.java:493)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource.maybeUpdateAdMediaSources(AdsMediaSource.java:342)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource.onAdPlaybackState(AdsMediaSource.java:310)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource.access$100(AdsMediaSource.java:63)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource$ComponentListener.lambda$onAdPlaybackState$0$androidx-media3-exoplayer-source-ads-AdsMediaSource$ComponentListener(AdsMediaSource.java:411)
                                                            at androidx.media3.exoplayer.source.ads.AdsMediaSource$ComponentListener$$ExternalSyntheticLambda0.run(Unknown Source:4)
                                                            at android.os.Handler.handleCallback(Handler.java:958)
                                                            at android.os.Handler.dispatchMessage(Handler.java:99)
                                                            at android.os.Looper.loopOnce(Looper.java:205)
                                                            at android.os.Looper.loop(Looper.java:294)
                                                            at android.os.HandlerThread.run(HandlerThread.java:67)
2024-08-15 20:33:37.381 25052-25404 s.flixxoapp.dev    W  Attempt to remove non-JNI local reference
2024-08-15 20:33:37.395 25052-25228 ReactNativeJS      I  'onReceiveAdEvent', { data: {}, event: 'CONTENT_PAUSE_REQUESTED' }
2024-08-15 20:33:37.445 25052-25250 TrafficStats       D  tagSocket(191) with statsTag=0xffffffff, statsUid=-1
2024-08-15 20:33:37.503 25052-25168 EGL_emulation      D  app_time_stats: avg=1.66ms min=0.83ms max=8.27ms count=60
2024-08-15 20:33:38.315 25052-25052 OrientationModule  D  onActivityPaused
2024-08-15 20:33:38.322 25052-25404 Process            I  Sending signal. PID: 25052 SIG: 9
moskalakamil commented 3 weeks ago

Hi, thanks for reporting the issue!

freeboub commented 3 weeks ago

@sntg-p can you provide your <Video call please ? do you have ads url and no source ?

sntg-p commented 3 weeks ago

@freeboub I have a source, I do not render the player if uri is not defined.

<Video
  source={{ uri }}
  paused={state.paused}
  style={styles.videoCont}
  resizeMode='contain'
  fullscreen={true}
  ignoreSilentSwitch={IgnoreSilentSwitchType.IGNORE}
  onBuffer={handleBuffering}
  onLoadStart={handleLoadStart}
  onLoad={handleLoad}
  onProgress={handleProgress}
  onEnd={handleEnd}
  onError={onError}
  ref={videoRef}
  adTagUrl='https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='
  onReceiveAdEvent={(e) => console.log(e)}
/>
freeboub commented 2 weeks ago

I have just try to reproduce on emulator, and the ads are playing correctly... I suspect something linked to your build... Maybe desugaring the apk can be the solution ... https://github.com/androidx/media/issues/1312#issuecomment-2090448787