ExoPlayer has memory leakage problem
See original GitHub issueBug
Finally, the application went crashed with a number of out of memory exceptions, after many or several times (depending on the device performance) of mount/unmount/hot-reload operations. This only happens on ExoPlayer, not so on Android Media Player.
Here is a cut of my Android Logcat:
2022-07-14 22:13:31.287 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":1.954}])
2022-07-14 22:13:31.288 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoEnd",null])
2022-07-14 22:13:33.027 24490-24490/? W/unknown:WrappingUtils: Don't know how to round that drawable: com.facebook.react.views.image.ReactImageDownloadListener$EmptyDrawable@56846f1
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":4.777}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":4.134}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":3.032}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":3.91}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":5.186}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":2.971}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":2.971}])
2022-07-14 22:13:33.028 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":6.188}])
2022-07-14 22:13:33.624 24490-28550/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:33.624 24490-28550/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 42144 free bytes and 41KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50160224 kB)
2022-07-14 22:13:34.800 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":4.01}])
2022-07-14 22:13:35.039 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":4.211}])
2022-07-14 22:13:35.301 24490-28550/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:35.301 24490-28550/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 3816 free bytes and 3816B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50142736 kB)
2022-07-14 22:13:35.488 24490-28529/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:35.488 24490-28529/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 14888 free bytes and 14KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50142736 kB)
2022-07-14 22:13:35.829 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":2.971}])
2022-07-14 22:13:35.830 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":7.798}])
2022-07-14 22:13:36.422 24490-28561/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:36.423 24490-28561/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 13472 free bytes and 13KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50142736 kB)
2022-07-14 22:13:36.969 24490-28548/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:36.969 24490-28548/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 14256 free bytes and 13KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50055296 kB)
2022-07-14 22:13:37.294 24490-28545/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:37.294 24490-28545/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 14496 free bytes and 14KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50055296 kB)
2022-07-14 22:13:37.651 24490-28529/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:37.651 24490-28529/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 15952 free bytes and 15KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50055296 kB)
2022-07-14 22:13:38.289 24490-28560/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:38.290 24490-28560/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 5184 free bytes and 5184B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50037808 kB)
2022-07-14 22:13:38.475 24490-28529/? E/LoadTask: OutOfMemory error loading stream
java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 15952 free bytes and 15KB until OOM, target footprint 402653184, growth limit 402653184
at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
at com.google.android.exoplayer2.source.SampleQueue.preAppend(SampleQueue.java:624)
at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:544)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:533)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:187)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:898)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)
2022-07-14 22:13:38.478 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":2.506}])
2022-07-14 22:13:38.480 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":5.936}])
2022-07-14 22:13:38.480 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":10.574}])
2022-07-14 22:13:38.480 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":9.702}])
2022-07-14 22:13:38.480 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":6.611}])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":5.186}])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":9.535}])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":9.535}])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":7.961}])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoEnd",null])
2022-07-14 22:13:38.481 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoEnd",null])
2022-07-14 22:13:38.497 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":7.934}])
2022-07-14 22:13:38.497 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":6.409}])
2022-07-14 22:13:38.497 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoProgress",{"seekableDuration":2.96,"playableDuration":2.96,"currentTime":9.535}])
2022-07-14 22:13:38.497 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":7.798}])
2022-07-14 22:13:38.497 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([4897,"onVideoEnd",null])
2022-07-14 22:13:39.205 24490-28532/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:39.205 24490-28532/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 28200 free bytes and 27KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50055296 kB)
2022-07-14 22:13:39.695 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([89,"onVideoEnd",null])
2022-07-14 22:13:40.407 24490-28550/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:40.407 24490-28550/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 20984 free bytes and 20KB until OOM, target footprint 402653184, growth limit 402653184" (VmSize 50037820 kB)
2022-07-14 22:13:40.407 24490-28550/? E/LoadTask: OutOfMemory error loading stream
java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 20984 free bytes and 20KB until OOM, target footprint 402653184, growth limit 402653184
at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
at com.google.android.exoplayer2.source.SampleQueue.preAppend(SampleQueue.java:624)
at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:544)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:533)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:187)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:898)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)
2022-07-14 22:13:41.107 24490-28573/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:41.107 24490-28573/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 5160 free bytes and 5160B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49915488 kB)
2022-07-14 22:13:41.143 24490-24490/? W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3297,"onVideoProgress",{"seekableDuration":3,"playableDuration":3,"currentTime":6.703}])
2022-07-14 22:13:41.380 24490-28548/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:41.380 24490-28548/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 4792 free bytes and 4792B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49898000 kB)
2022-07-14 22:13:42.506 24490-28565/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:42.506 24490-28565/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 864 free bytes and 864B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49898000 kB)
2022-07-14 22:13:42.644 24490-28560/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:42.644 24490-28560/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 864 free bytes and 864B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49898000 kB)
2022-07-14 22:13:43.128 24490-28564/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:43.128 24490-28564/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 240 free bytes and 240B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49898000 kB)
2022-07-14 22:13:43.262 24490-28648/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:43.263 24490-28648/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 4016 byte allocation with 8 free bytes and 8B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49898000 kB)
2022-07-14 22:13:44.489 24490-28532/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:44.489 24490-28532/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 40 free bytes and 40B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:44.925 24490-28536/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:44.926 24490-28536/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 232 free bytes and 232B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:45.062 24490-24544/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:45.062 24490-24544/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 56 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:45.604 24490-28540/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:45.604 24490-28540/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:46.175 24490-28652/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:46.175 24490-28652/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 40 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:46.392 24490-24758/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:46.392 24490-24758/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 48 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:46.794 24490-28573/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:46.794 24490-28573/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:47.650 24490-28442/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:47.651 24490-28442/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 152 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:47.987 24490-24751/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:47.987 24490-24751/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 64 byte allocation with 16 free bytes and 16B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:48.804 24490-28557/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:48.804 24490-28557/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 0 free bytes and 0B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:49.100 24490-28538/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:49.100 24490-28538/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 32 byte allocation with 0 free bytes and 0B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49880524 kB)
2022-07-14 22:13:49.685 24490-24490/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:49.685 24490-24490/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 760 byte allocation with 400 free bytes and 400B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49845548 kB)
2022-07-14 22:13:49.825 24490-28548/? E/mypackage: [MemLeak.JavaTrack]: failed to write oom info: Operation not permitted
2022-07-14 22:13:49.825 24490-28548/? W/mypackage: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 1824 free bytes and 1824B until OOM, target footprint 402653184, growth limit 402653184" (VmSize 49845548 kB)
Platform
Android Exoplayer
Environment info
React native info output:
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 5.93 GB / 23.88 GB
Binaries:
Node: 16.14.2 - C:\nodejs\node.EXE
Yarn: 1.22.18 - C:\nodejs\yarn.CMD
npm: 8.5.0 - C:\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.2
System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio: 16.11.31911.196 (Visual Studio Community 2019)
Languages:
Java: javac 13 - C:\Program Files\Java\jdk-13\bin\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
Library version: 4.4.5 ~ 5.2.0 ~ 6.0.0-alpha0 all have this problem
Steps To Reproduce
- Create a React Native project and install
react-native-video - Create a Video component in App, style it as absolute and stretch(or fixed), make it
autoplayandsilentandplayInBackgroundandrepeatand all of the possible way to make it like a background of App View and not bother any other players or applications outside. Prepare several videos with length 1~5s. (see the demo below) - Create a state field in the App, and
setIntervalto update it regularly. This step is to let the Video component auto refresh many times. - Run the application in an Android device. hold on and wait… until it crashes. …
demo:
import React from 'react';
import {Dimensions, View} from 'react-native';
import Video from 'react-native-video';
const videos = [require('./video1.mp4'), require('./video2.mp4')];
//// for production release
// const videos = [{uri:'raw/video1'}, {uri:'raw/video2'}]
export default function App() {
const [src, setSrc] = React.useState(0);
const [width, setWidth] = React.useState(Dimensions.get('window').width);
const [height, setHeight] = React.useState(Dimensions.get('window').height);
React.useEffect(() => {
setTimeout(() => {
setSrc((src + 1) % videos.length);
}, 4000);
}, [src]);
return (
<View
style={{flex: 1}}
onLayout={({nativeEvent}) => {
setWidth(nativeEvent.layout.width);
setHeight(nativeEvent.layout.height);
}}>
<Video
source={videos[src]}
style={[
{
position: 'absolute',
top: 0,
left: 0,
zIndex: 1,
width: width,
height: height,
},
]}
resizeMode="cover"
repeat
allowsExternalPlayback={false}
ignoreSilentSwitch="obey"
mixWithOthers="mix"
muted
volume={0}
selectedAudioTrack={{type: 'disabled'}}
selectedTextTrack={{type: 'disabled'}}
playWhenInactive
playInBackground
disableFocus
/>
</View>
);
}
Expected behaviour
- Not crash!
Suppose
the reactContext in the module has been catched in unsafe ways. When the context hot changed, the module could not run correctly, but it still had some kind of references to the old reactContext and some others, that makes memory leakages and errors.
Issue Analytics
- State:
- Created a year ago
- Comments:31
Top Results From Across the Web
Potential Memory Leak #9755 - google/ExoPlayer - GitHub
Interesting. I'm having a Foreground service which creates and holds the player instance. When the service is destroyed, I release the player.
Read more >ExoPlayer MemoryLeak issues - LeakCanary - Stack Overflow
I found a Memory Leak in my splash screen. it is playing video from asset folder on splash screen with ExoPlayer.
Read more >Manage your app's memory - Android Developers
You still need to avoid introducing memory leaks, usually caused by holding ... Before you can fix the memory usage problems in your...
Read more >How to Solve OutOfMemoryError in Android Application?
Memory leaks cause the OutOfMemoryError to occur in Android. So, in order to remove the OutOfMemoryError, all you need to do is take...
Read more >Controlling memory with Google's ExoPlayer - Ian Bird
ExoPlayer will sequentially read the samples from the file, and just pass them onto the relevant tracks sample queue. One potential problem with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@TensionCoding
I had a similar issue but for iOS, which isn’t related to ExoPlayer, and solved it this way.
You can use a custom view to wrap your video component, and use
import { useIsFocused } from '@react-navigation/native';To conditionally render the Video component only when the screen is focused, otherwise rendering an Image component instead. You can also pass in a flag to pre-load the Video if needed.You can use Memo on other parts of the screen to further improve performance if needed.
Actually, I’ve tried from
4.4.5to6.0.0-alpha0, the problem alway exists.