Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Conversation

krayong
Copy link

@krayong krayong commented Aug 29, 2021

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

@krayong krayong mentioned this pull request Aug 29, 2021
@surethink
Copy link

cool, hope it merged

@mirceaciu
Copy link

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.

@krayong
Copy link
Author

krayong commented Sep 26, 2021

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.

@mirceaciu
Copy link

I did checkout this branch and gave it a go, easy to use, cached the content just fine! Great job

@krayong
Copy link
Author

krayong commented Sep 26, 2021

Really appreciate you trying it out @mirceaciu let me know if you face any issues.

@mirceaciu
Copy link

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

2021-10-07 09:48:23.773 2538-3054/com.xxx.player I/ACodec: ignoring message as already freed component: AMessage(what = 'omxL', target = 12520) = {
      int32_t node = 21303417
      RefBase *messages = 0x768236a840
    }
2021-10-07 09:48:23.775 2538-3051/com.xxx.player W/MediaCodecRenderer: Failed to initialize decoder: OMX.rk.video_decoder.avc
      java.lang.IllegalArgumentException: start failed
        at android.media.MediaCodec.native_start(Native Method)
        at android.media.MediaCodec.start(MediaCodec.java:1991)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.start(SynchronousMediaCodecAdapter.java:66)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1113)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1011)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:578)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1420)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:694)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:965)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:811)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:947)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:477)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)
2021-10-07 09:48:23.775 2538-3051/com.xxx.player D/MediaCodecInfo: NoSupport [sizeAndRate.support, 1920x1080x25.0] [OMX.google.h264.decoder, video/avc] [rk3399_box, NEO_X39, rockchip, 25]
2021-10-07 09:48:23.776 2538-3051/com.xxx.player E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 25.0], [-1, -1]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:554)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.rk.video_decoder.avc, Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 25.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1018)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:578)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1420)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:694)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:965)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:811)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:947)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:477)
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.os.HandlerThread.run(HandlerThread.java:61) 
     Caused by: java.lang.IllegalArgumentException: start failed
        at android.media.MediaCodec.native_start(Native Method)
        at android.media.MediaCodec.start(MediaCodec.java:1991)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.start(SynchronousMediaCodecAdapter.java:66)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1113)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1011)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:578) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1420) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:694) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readToFlagsOnlyBuffer(MediaCodecRenderer.java:965) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:811) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:947) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:477) 
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.os.HandlerThread.run(HandlerThread.java:61) 
2021-10-07 09:48:23.879 2538-2538/com.xxx.player E/ExoPlayer Exception: com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 25.0], [-1, -1]), format_supported=YES
2021-10-07 09:48:23.879 2538-2538/com.xxx.player D/ReactExoplayerView: onStateChanged: playWhenReady=true, playbackState=idle
2021-10-07 09:48:23.882 2538-2592/com.xxx.player I/ReactNativeJS: { error: 
       { errorException: 'com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 25.0], [-1, -1]), format_supported=YES',
         errorString: 'Unable to instantiate decoder OMX.rk.video_decoder.avc' } }
xx2021-10-07 09:48:23.893 2538-3051/com.xxx.player D/MediaCodecInfo: NoSupport [sizeAndRate.support, 1920x1080x25.0] [OMX.google.h264.decoder, video/avc] [rk3399_box, NEO_X39, rockchip, 25]
2021-10-07 09:48:23.893 2538-3051/com.xxx.player D/MediaCodecInfo: NoSupport [sizeAndRate.support, 1920x1080x25.0] [OMX.google.h264.decoder, video/avc] [rk3399_box, NEO_X39, rockchip, 25]
2021-10-07 09:48:23.903 2538-3051/com.xxx.player D/MediaCodecInfo: NoSupport [sizeAndRate.support, 1920x1080x25.0] [OMX.google.h264.decoder, video/avc] [rk3399_box, NEO_X39, rockchip, 25]

the app crashed

2021-10-06 18:23:36.518 552-626/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{19403f2 V.E...... ........ 0,0-1920,1080 #1f7f}
2021-10-06 18:23:36.653 552-1542/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{19403f2 V.E...... ........ 0,0-1920,1080 #1f7f}
2021-10-06 18:23:47.311 552-1091/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{5f96d25 V.E...... ........ 0,0-1920,1080 #1f89}
2021-10-06 18:23:47.469 552-1091/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{5f96d25 V.E...... ........ 0,0-1920,1080 #1f89}
2021-10-06 18:23:58.135 552-626/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{b47f177 V.E...... ........ 0,0-1920,1080 #1f93}
2021-10-06 18:23:58.310 552-16495/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{b47f177 V.E...... ........ 0,0-1920,1080 #1f93}
2021-10-06 18:23:58.398 552-626/system_process I/ActivityManager: Start proc 19914:com.google.android.webview:webview_service/u0a68 for service com.google.android.webview/org.chromium.android_webview.services.VariationsSeedServer
2021-10-06 18:23:58.502 552-16495/system_process I/ActivityManager: Killing 12106:com.google.android.partnersetup/u0a18 (adj 906): empty for 3553s
2021-10-06 18:23:58.537 552-1542/system_process D/ActivityManager: cleanUpApplicationRecord -- 12106
2021-10-06 18:24:08.841 552-1542/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{438c129 V.E...... ........ 0,0-1920,1080 #1f9d}
2021-10-06 18:24:09.000 552-19944/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{438c129 V.E...... ........ 0,0-1920,1080 #1f9d}
2021-10-06 18:24:19.600 552-2156/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{4d4982a V.E...... ........ 0,0-1920,1080 #1fa7}
2021-10-06 18:24:19.773 552-2156/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{4d4982a V.E...... ........ 0,0-1920,1080 #1fa7}
2021-10-06 18:24:30.408 552-2156/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{4bb738a V.E...... ........ 0,0-1920,1080 #1fb1}
2021-10-06 18:24:32.544 552-2156/system_process I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10077/2592 clientId=android.media.AudioManager@9392d0fcom.brentvatne.exoplayer.ReactExoplayerView{4bb738a V.E...... ........ 0,0-1920,1080 #1fb1}
2021-10-06 18:24:34.631 552-662/system_process D/ConnectivityService: releasing NetworkRequest [ TRACK_DEFAULT id=15, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.632 552-662/system_process D/ConnectivityService:  Removing from current network NetworkAgentInfo [WIFI () - 100], leaving 10 requests.
2021-10-06 18:24:34.632 552-662/system_process D/ConnectivityService: sending notification RELEASED for NetworkRequest [ TRACK_DEFAULT id=15, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.857 552-19944/system_process D/ConnectivityService: requestNetwork for uid/pid:10077/2592 NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService: rematching NetworkAgentInfo [WIFI () - 100]
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService:  network has: [ Transports: WIFI Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&VALIDATED&FOREGROUND LinkUpBandwidth>=1048576Kbps LinkDnBandwidth>=1048576Kbps SignalStrength: -54]
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService:   checking if request is satisfied: NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService: currentScore = 0, newScore = 60
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService: rematch for NetworkAgentInfo [WIFI () - 100]
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService:    accepting network in place of null
2021-10-06 18:24:34.857 552-662/system_process D/ConnectivityService: sending new Min Network Score(60): NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.858 552-662/system_process D/ConnectivityService: Network NetworkAgentInfo [WIFI () - 100] was already satisfying request 8. No change.
2021-10-06 18:24:34.858 552-662/system_process D/ConnectivityService: Network NetworkAgentInfo [WIFI () - 100] was already satisfying request 29. No change.
2021-10-06 18:24:34.858 552-662/system_process D/ConnectivityService: Network NetworkAgentInfo [WIFI () - 100] was already satisfying request 1. No change.
2021-10-06 18:24:34.858 552-662/system_process D/ConnectivityService: sending notification AVAILABLE for NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:34.858 552-656/system_process D/WIFI_UT: got request NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 60
2021-10-06 18:24:34.858 552-656/system_process D/WIFI: got request NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 60
2021-10-06 18:24:34.858 552-696/system_process D/Ethernet: got request NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 60
2021-10-06 18:24:37.186 552-20029/system_process W/ActivityManager:   Force finishing activity com.xxx.player/.MainActivity
2021-10-06 18:24:37.195 552-599/system_process I/BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
2021-10-06 18:24:37.221 552-578/system_process W/ActivityManager: Failed setting process group of 2592 to 1
2021-10-06 18:24:37.221 552-578/system_process W/System.err: java.lang.IllegalArgumentException: Given thread 2653 does not exist
2021-10-06 18:24:37.223 552-578/system_process W/System.err:     at android.os.Process.setThreadPriority(Native Method)
2021-10-06 18:24:37.223 552-578/system_process W/System.err:     at com.android.server.am.ActivityManagerService.applyOomAdjLocked(ActivityManagerService.java:20828)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java:21338)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.am.ActivityManagerService.setProcessForeground(ActivityManagerService.java:7727)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.notification.NotificationManagerService.keepProcessAliveIfNeededLocked(NotificationManagerService.java:3090)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.notification.NotificationManagerService$5.enqueueToast(NotificationManagerService.java:1336)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at android.widget.Toast.show(Toast.java:124)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.am.LockTaskNotify.makeAllUserToastAndShow(LockTaskNotify.java:76)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.am.LockTaskNotify.show(LockTaskNotify.java:69)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.am.ActivityStackSupervisor$ActivityStackSupervisorHandler.handleMessage(ActivityStackSupervisor.java:4010)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at android.os.Looper.loop(Looper.java:154)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
2021-10-06 18:24:37.227 552-578/system_process W/System.err:     at com.android.server.ServiceThread.run(ServiceThread.java:46)
2021-10-06 18:24:37.271 552-2651/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
2021-10-06 18:24:37.271 552-2651/system_process D/OpenGLRenderer: Swap behavior 1
2021-10-06 18:24:37.279 552-1091/system_process W/BroadcastQueue: Exception when sending broadcast to ComponentInfo{com.xxx.player/com.xxx.player.AdminReceiver}
    android.os.DeadObjectException
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:615)
        at android.app.ApplicationThreadProxy.scheduleReceiver(ApplicationThreadNative.java:955)
        at com.android.server.am.BroadcastQueue.processCurBroadcastLocked(BroadcastQueue.java:286)
        at com.android.server.am.BroadcastQueue.processNextBroadcast(BroadcastQueue.java:1225)
        at com.android.server.am.ActivityManagerService.finishReceiver(ActivityManagerService.java:18936)
        at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:528)
        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2913)
        at android.os.Binder.execTransact(Binder.java:565)
2021-10-06 18:24:37.280 552-1091/system_process D/ActivityManager: cleanUpApplicationRecord -- 2592
2021-10-06 18:24:37.280 552-1091/system_process W/ActivityManager: Scheduling restart of crashed service com.xxx.player/org.eclipse.paho.android.service.MqttService in 1000ms
2021-10-06 18:24:37.281 552-2651/system_process D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2021-10-06 18:24:37.304 552-1091/system_process I/ActivityManager: Start proc 20032:com.xxx.player/u0a77 for broadcast com.xxx.player/.AdminReceiver
2021-10-06 18:24:37.314 552-645/system_process W/InputDispatcher: channel '8a91a8 com.xxx.player/com.xxx.player.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
2021-10-06 18:24:37.315 552-645/system_process E/InputDispatcher: channel '8a91a8 com.xxx.player/com.xxx.player.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-10-06 18:24:37.315 552-2156/system_process D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], android.os.BinderProxy@251bba7)
2021-10-06 18:24:37.316 552-2156/system_process D/GraphicsStats: Buffer count: 3
2021-10-06 18:24:37.316 552-662/system_process D/ConnectivityService: releasing NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:37.317 552-662/system_process D/ConnectivityService:  Removing from current network NetworkAgentInfo [WIFI () - 100], leaving 10 requests.
2021-10-06 18:24:37.317 552-662/system_process D/ConnectivityService: sending notification RELEASED for NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:37.318 552-662/system_process E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ TRACK_DEFAULT id=30, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
2021-10-06 18:24:37.328 552-2651/system_process D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2021-10-06 18:24:37.330 552-1620/system_process I/WindowManager: WIN DEATH: Window{8a91a8 u0 com.xxx.player/com.xxx.player.MainActivity}
2021-10-06 18:24:37.331 552-1620/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '8a91a8 com.xxx.player/com.xxx.player.MainActivity (server)'
2021-10-06 18:24:37.331 552-1620/system_process W/WindowManager: Force-removing child win Window{e23f854 u0 SurfaceView - com.xxx.player/com.xxx.player.MainActivity} from container Window{8a91a8 u0 com.xxx.player/com.xxx.player.MainActivity}
2021-10-06 18:24:37.344 552-1091/system_process W/WindowManager: Failed looking up window
    java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@e850dc4 does not exist
        at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:10046)
        at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:10037)
        at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1825)
        at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
2021-10-06 18:24:37.344 552-1091/system_process I/WindowManager: WIN DEATH: null
2021-10-06 18:24:40.751 552-552/system_process W/WindowManager: Attempted to remove non-existing token: android.os.Binder@7fae419
2021-10-06 18:24:42.767 552-552/system_process W/WindowManager: Attempted to remove non-existing token: android.os.Binder@1d46b43
2021-10-06 18:24:47.199 552-578/system_process W/ActivityManager: Launch timeout has expired, giving up wake lock!

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

@mirceaciu
Copy link

Could this be similar to the cached image issue described here facebook/react-native#12220 ?

@krayong
Copy link
Author

krayong commented Oct 15, 2021

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?

@mirceaciu
Copy link

mirceaciu commented Oct 15, 2021

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,

{ source && <Video source={source}  ... />

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

<Video source={source}>

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 source prop, passing it via reference or something.

@mirceaciu
Copy link

mirceaciu commented Oct 19, 2021

@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!

@shiprasharma12
Copy link

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?
.

@ghost
Copy link

ghost commented May 18, 2022

@krayong can you fix these conflicts?

@hueniverse
Copy link
Contributor

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.

@hueniverse hueniverse closed this Jun 23, 2022
@hueniverse hueniverse added the stale Closed due to inactivity or lack or resources label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Platform: Android stale Closed due to inactivity or lack or resources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants