react-native-video: Remote videos slow + ANR on Android 9 and 10
Bug
On Android 9 and 10, remotely loaded videos seem to take a very long time to play. Seeking is also extremely slow (changing the seek position will result in the same initial load time).
What’s worse, an ANR can happen while loading. Here’s the ANR stack trace:
ANR ·MainActivity
Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing....
MediaPlayer.java:-2 · android.media.MediaPlayer.setPlaybackParams
--
ReactVideoView.java:470 · com.brentvatne.react.ReactVideoView.setRateModifier
ReactVideoView.java:521 · com.brentvatne.react.ReactVideoView.applyModifiers
ReactVideoView.java:561 · com.brentvatne.react.ReactVideoView.onPrepared
MediaPlayer.java:3346 · android.media.MediaPlayer$EventHandler.handleMessage
Platform
Which player are you experiencing the problem on:
- Android MediaPlayer
Environment info
React Native: 0.61.5 Library version: “react-native-video”: “5.0.2”
Steps To Reproduce
Load <Video> with the HTTP link provided below. Use on Android 9 or 10 (works fine on Android < 9).
…
Expected behaviour
Reproducible sample code
Video sample
If possible, include a link to the video that has the problem that can be streamed or downloaded from. https://zinspectordev2.s3.amazonaws.com/usi/2/1576687667933fbdddc5f5458c8b013fef64127c99.mp4
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 16
@pyeonjaesik I just added the required gradle changes (pretty much manual linking). Here’s what I did with RN 0.61 (taken from https://github.com/react-native-community/react-native-video#android-installation)
First add/update
react-native.config.jsto tell RN to not auto link the module:Then update
settings.gradleto add the dependency:Also update
build.gradle:Add package to
MainApplication.java:I probably missed something, but the instructions are clear on the link above.
I think there are various buffering and stream setting you can test, but I haven’t tried that at all.
El mié., 12 de febrero de 2020 13:30, pyeonjaesik notifications@github.com escribió:
I solved the issue by manually linking the Android version and using the “exoplayer” version instead. That one works fine; I wonder why it is not the default implementation.
I don’t think you can make it even faster. You may try fine tuning the library settings, or looking at your backend to see if you’re providing a good/fast stream. Other than that, I don’t know 😦
As a last resource, try a webview with a youtube player 😃
@cristianoccazinsp Thank you! I solved this problem. Thanks to your help, remote loading is faster than before. But I want far more faster than this . Can you give me a tip?