expo-av Load encountered an error: the OnErrorListener was called with 'what' code 1 and 'extra' code -2147483648

Please provide the following:

  1. SDK Version:35
  2. Platforms(Android/iOS/web/all):Android

Hello, our app has fullscreen horizontal slider and each slide is video. the video play/puase is based on current slide.

expo-av videos crashes the expo app on android phones if used directly as stated in docs.( shoulPlay controlled using state and applied to video component directly).

But whe we change this approach and use a ref to loadAsync the video on mount and using androidImplementation:MediaPlayer and unloadAsync on state update(non active),
it works fines on expo app development as well as published version.

And when build apk is installed on andriod phones the app crashes where videos are there.
We installed sentry error logger which gives the following error message

Load encountered an error: the OnErrorListener was called with ‘what’ code 1 and ‘extra’ code -2147483648.

on ios the videos work fine.

Hey @flukkas,

Thanks for the report. I relayed this internally and we’ll follow up when we know more. Would it be possible for you to share your code, ideally in something reproducible we can test on our end?

Cheers,
Adam

i have created 2 test cases
case 1 : coded as per the docs using shouldPlay inline to video component and controlled using state. on some android devices it alerts the error as
com.google.android.exoplayer2.g.b$a: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1,null,null,video/avc,null,-1,null,[1080,1920,-1,0],[-1,-1]

case 2: coded using ref to loadasync and unload. If androidImplementation:‘MediaPlayer’ is not used sometimes it gives the above error(decoder init failed). Most of the times it works on expo app as well as apk build.
If androidImplementation:‘MediaPlayer’ is used it gives the following error sometimes
MediaPlayer failed with ‘what’ code 1 and ‘extra’ code-1010. And also here it works most of the times on expo app but in build apk it doesnt.

I am afraid this in neither expo nor react-native issue. It seems, that some devices impose limit on number of instances of codec that can be instantiated at once. See this issue on ExoPlayer.

If this is the root cause, and I believe it is, the only solution is to prevent rendering too many players at a time. Currently, because you use AndroidViewPager even though some players are invisible, they are still instantiated and loaded.

Even worse, I do not know of any method that would expose number of possible codecs to bi instantiated. If you’ll find one, however, we will be more than happy to expose it in expo-av module.