-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Android ExoPlayer Cache #2470
Android ExoPlayer Cache #2470
Conversation
cool, hope it merged |
does this contain autocleaning ? e.g. if there is no more space to cache a new video file then remove some of the oldest unused files. |
Yes @mirceaciu it uses LRU caching which means after the max cache size is filled, the least recently used cache would get removed making space for new files. |
I did checkout this branch and gave it a go, easy to use, cached the content just fine! Great job |
Really appreciate you trying it out @mirceaciu let me know if you face any issues. |
Hi @krayong . I've been testing this branch for a while and I can confirm that the media files are cached, the app can work completely offline. I have the player set up to receive source as a prop, each time a video ends the source prop will be refreshed and the player will replay the content. Intent is to have the app play a list of one or more source is a loop, hours on end. With this approach sometimes the app gets in trouble and the video player can't decode the cached media files anymore. Issue can occur right after a restart of after a few hours of play. There might be a memory leak, some open files don't get released or the asynchronous model of react-native does not play well with this setup. Here are a few logcat extracts : video player stopped playing videos
the app crashed
Just installed the new release (master 5.2.0 alpha) and the app is working fine for 24+ hours, but streaming the same video over and over again is not fun :D |
Could this be similar to the cached image issue described here facebook/react-native#12220 ? |
Doesn't seem related to this issue. Also what I feel is that after playing for long, OS is trying to deallocate memory. Have been using this with playlisting on a production app for a while now, haven't faced this problem. Can you maybe share a code snippet of how you are changing sources and setting them? |
Last night I found the issue. I was using conditional rendering for the Video component, where the condition was the actual source being not null,
There are a few other props passed to this component but I did not include them here. While using this variant I could see, in the Android Profiling tool, that the memory consumption increases with each video play and does not get released at the end of a video. The graph for memory consumption looks like a staircase, starts with 10MB then increases (a few MB a a time) until the app crashed (~600MB for my Android Emulator) If I use the component without the condition
then I will get a warning whenever source is empty or null but memory get's released each time a video is played to the end. There might be something in the way I build the |
@krayong final update from my side. Looks like my issues are related to react-native-video's ExoPlayer implementation. When using the exoplayer mode the memory consumption grows with each video played and does not get released. This leads to all kind of bad stuff. The old MediaPlayer does not show the same behavior and is more stable so I will use that but this means that I can't use your PR. Can our PR be adapted to also support the MediaPlayer implementation of the player? In any case: good job on this! |
I am also facing this issue, in my android app i am showing the list of video with autoplay(whenever it gets in the viewable area) functionality. And video play stop loading the video urls after successfully loading 14-15 videos. I am receiving the same error there "Unable to instantiate decoder OMX.qcom.video.decoder.avc". Have you find any solution yet? |
@krayong can you fix these conflicts? |
Closing due to lack of response (from the original submitted or anyone else to review and rebase). If someone wants to pick this up please open a new PR that ports this code into the current master. We are doing our best to start clean with v6 which requires being a bit aggressive in closing stale PRs that are over a year old. Please don't consider this dismissing of your work and contribution - it's greatly appreciated. |
Basic implementation of ExoPlayer Cache.
It loads the media into a SimpleCache at the app's internal cache directory inside
video
, which can then be read by the ExoPlayer.Added 3 props.
cache
for runtime caching (default =false
),maxCacheSize
to determine the maximum cache size of the videos (default =100MB
),maxCacheFileSize
to determine the maximum file size that should be cached (default =10MB
).Also added the relevant docs.
Solves: #99 #1599 #1630 #1910