Open RickoNoNo3 opened 2 years ago
Actually, I've tried from 4.4.5
to 6.0.0-alpha0
, the problem alway exists.
Hi, could you please tell me how you integrated the exoplayer in the first place? I am also using react-native-video and it is working but the loading is very slow for me. I think it is using the media player instead of the exoplayer in my case. Would like to k now how you implemented it. Thanks
@hmShuvo314 The versions before v6.0
(such as v5.x
), are documented for this, see the document. You can integrate this library correctly only by following the chapter Android installation. The two integrating options in android/settings.gradle
only need to complete one, and be sure to put it at the end of the file, do not put anything below.
v6.x
has removed the Android Media Player, it can only and automatically use Exoplayer.
I've been having the exact same issue for quite some time. If you alternate rendering a Video
and another element such as an Image
infinitely, the memory eventually runs out. I've seen it crash in as little as 45 minutes with a 1 second delay between each render. This is a problem for us since our app is for digital signage so we require the ability to render multiple media types in a list.
@c-moyer It seems that I'm not in an isolated case.
Our project uses the video component as an animated background, and it switches between several video sources frequently, that causes trouble. We are using Android Media Player implementation now.
@RickoNoNo3 I haven't had a chance to review the memory profiler yet with my latest change, but commenting out the following code from react-native.config.js
seems to have improved performance.
// module.exports = {
// dependencies: {
// 'react-native-video': {
// platforms: {
// android: {
// sourceDir: '../node_modules/react-native-video/android-exoplayer',
// },
// },
// },
// },
// };
I've had the app running now for about 36 hours alternating between two videos and an image with 1 second between each render. With exoplayer, this crashes within 45 minutes. I did notice the UI froze for a couple of minutes about 24 hours in which was odd, but the app didn't crash like it usually does and I didn't receive any bugsnag notifications either. I'll try to do some more digging later this week but it seems like there's some sort of teardown that's missing which is needed specifically for Exoplayer.
After running the app for about an hour using Exoplayer, I began getting out of memory errors. Here's a sample of my logcat:
2022-09-14 22:57:51.884 426-23477/? I/MtkOmxVdecExV4L2: [0xa7118a00] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:57:51.899 426-492/? I/MtkOmxVdecExV4L2: [0xa7118a00] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:57:57.368 25405-23338/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 17856 free bytes and 17KB until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 22:57:57.861 23514-23542/? D/BlackbirdPluginHandler: kso device attributes: {"type":"DeviceAttributes","acceptLanguage":"en-US","apkVersion":"7.5.848.0","appVersion":"dynamic","cor":"US","deviceLocalTime":"America/Chicago","devicePartnerId":"NO_PARTNER_ID","deviceType":"AFTKA","directedId":"amzn1.account.AE3CHNEV5V52ASM2JEW3HVU22DRA","dsn":"G071R207132437JN","idfa":"03fb9eb9-3c8c-405a-976a-22eff9055cfe","launcherVersion":"639002610","optOut":false,"osVersion":"0024126400644","pconState":"0","pconViewingRestrictions":"-1","pfm":"ATVPDKIKX0DER","sha1UDID":"5f4806ce160a07799670accb9b000287302961d3","sisId":"A_riPLQ0gUegsXM-PsbbnD8","userAgent":"Dalvik/2.1.0 (Linux; U; Android 9; AFTKA Build/PS7292.2984N)"}
2022-09-14 22:57:57.988 23514-23542/? D/BlackbirdPluginHandler: kso device attributes: {"type":"DeviceAttributes","acceptLanguage":"en-US","apkVersion":"7.5.848.0","appVersion":"dynamic","cor":"US","deviceLocalTime":"America/Chicago","devicePartnerId":"NO_PARTNER_ID","deviceType":"AFTKA","directedId":"amzn1.account.AE3CHNEV5V52ASM2JEW3HVU22DRA","dsn":"G071R207132437JN","idfa":"03fb9eb9-3c8c-405a-976a-22eff9055cfe","launcherVersion":"639002610","optOut":false,"osVersion":"0024126400644","pconState":"0","pconViewingRestrictions":"-1","pfm":"ATVPDKIKX0DER","sha1UDID":"5f4806ce160a07799670accb9b000287302961d3","sisId":"A_riPLQ0gUegsXM-PsbbnD8","userAgent":"Dalvik/2.1.0 (Linux; U; Android 9; AFTKA Build/PS7292.2984N)"}
2022-09-14 22:58:01.855 25405-23338/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 13784 free bytes and 13KB until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 22:58:03.672 25405-23338/com.digitalsignageplayer E/LoadTask: OutOfMemory error loading stream
java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 13784 free bytes and 13KB until OOM, max allowed footprint 201326592, growth limit 201326592
at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
at com.google.android.exoplayer2.source.SampleDataQueue.preAppend(SampleDataQueue.java:392)
at com.google.android.exoplayer2.source.SampleDataQueue.sampleData(SampleDataQueue.java:181)
at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:471)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:552)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:192)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
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:764)
2022-09-14 22:58:07.705 426-492/? E/OMXNodeInstance: setParameter(0xa7118344:MTK.DECODER.AVC, OMX.google.android.index.allocateNativeHandle(0x7f20040e): Output:1 en=0) ERROR: BadParameter(0x80001005)
2022-09-14 22:58:07.705 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (176 144 176 160 5 46096 0x7f000001), pPortDef (176 144 176 160 5 46096 0x7f000001)
2022-09-14 22:58:07.707 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:07.824 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:07.824 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:08.107 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000003), pPortDef (3840 2160 3840 2176 5 12533776 0x10f)
2022-09-14 22:58:08.114 426-24163/? I/MtkOmxVdecExV4L2: [0xa7118340] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:08.116 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:08.117 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] --- FTBQ: mNumPendingOutput 1; mFillThisBufQ.size() 1, CCDst: 0, CCSrc: 0
2022-09-14 22:58:08.117 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:08.117 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118340] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:58:08.120 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:08.121 426-492/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:08.121 426-26744/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:09.926 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118340] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x10f), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:09.982 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:09.983 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] --- FTBQ: mNumPendingOutput 2; mFillThisBufQ.size() 0, CCDst: 0, CCSrc: 0
2022-09-14 22:58:09.983 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:09.989 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:10.299 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:10.300 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] --- FTBQ: mNumPendingOutput 9; mFillThisBufQ.size() 7, CCDst: 0, CCSrc: 0
2022-09-14 22:58:10.300 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:10.301 426-24162/? I/MtkOmxVdecExV4L2: [0xa7118340] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:10.334 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118340] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:58:18.193 24380-24429/? D/BlackbirdPluginHandler: kso device attributes: {"type":"DeviceAttributes","acceptLanguage":"en-US","apkVersion":"7.5.848.0","appVersion":"dynamic","cor":"US","deviceLocalTime":"America/Chicago","devicePartnerId":"NO_PARTNER_ID","deviceType":"AFTKA","directedId":"amzn1.account.AE3CHNEV5V52ASM2JEW3HVU22DRA","dsn":"G071R207132437JN","idfa":"03fb9eb9-3c8c-405a-976a-22eff9055cfe","launcherVersion":"639002610","optOut":false,"osVersion":"0024126400644","pconState":"0","pconViewingRestrictions":"-1","pfm":"ATVPDKIKX0DER","sha1UDID":"5f4806ce160a07799670accb9b000287302961d3","sisId":"A_riPLQ0gUegsXM-PsbbnD8","userAgent":"Dalvik/2.1.0 (Linux; U; Android 9; AFTKA Build/PS7292.2984N)"}
2022-09-14 22:58:18.201 24380-24429/? D/BlackbirdPluginHandler: kso device attributes: {"type":"DeviceAttributes","acceptLanguage":"en-US","apkVersion":"7.5.848.0","appVersion":"dynamic","cor":"US","deviceLocalTime":"America/Chicago","devicePartnerId":"NO_PARTNER_ID","deviceType":"AFTKA","directedId":"amzn1.account.AE3CHNEV5V52ASM2JEW3HVU22DRA","dsn":"G071R207132437JN","idfa":"03fb9eb9-3c8c-405a-976a-22eff9055cfe","launcherVersion":"639002610","optOut":false,"osVersion":"0024126400644","pconState":"0","pconViewingRestrictions":"-1","pfm":"ATVPDKIKX0DER","sha1UDID":"5f4806ce160a07799670accb9b000287302961d3","sisId":"A_riPLQ0gUegsXM-PsbbnD8","userAgent":"Dalvik/2.1.0 (Linux; U; Android 9; AFTKA Build/PS7292.2984N)"}
2022-09-14 22:58:19.964 25405-24374/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 65548 byte allocation with 53152 free bytes and 51KB until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 22:58:23.995 25405-24374/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 65552 byte allocation with 53392 free bytes and 52KB until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 22:58:24.067 25405-24374/com.digitalsignageplayer E/LoadTask: OutOfMemory error loading stream
java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 53392 free bytes and 52KB until OOM, max allowed footprint 201326592, growth limit 201326592
at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
at com.google.android.exoplayer2.source.SampleDataQueue.preAppend(SampleDataQueue.java:392)
at com.google.android.exoplayer2.source.SampleDataQueue.sampleData(SampleDataQueue.java:181)
at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:471)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:552)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:192)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
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:764)
2022-09-14 22:58:24.913 426-28806/? E/OMXNodeInstance: setParameter(0xa7118544:MTK.DECODER.AVC, OMX.google.android.index.allocateNativeHandle(0x7f20040e): Output:1 en=0) ERROR: BadParameter(0x80001005)
2022-09-14 22:58:24.913 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (176 144 176 160 5 46096 0x7f000001), pPortDef (176 144 176 160 5 46096 0x7f000001)
2022-09-14 22:58:24.915 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:25.019 426-492/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:25.020 426-492/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:25.237 426-24827/? I/MtkOmxVdecExV4L2: [0xa7118540] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:25.239 426-492/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:25.240 426-492/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:25.241 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] --- FTBQ: mNumPendingOutput 1; mFillThisBufQ.size() 1, CCDst: 0, CCSrc: 0
2022-09-14 22:58:25.241 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:25.242 426-26744/? I/MtkOmxVdecExV4L2: [0xa7118540] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:58:25.242 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:25.243 426-26744/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:25.243 426-26744/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:25.303 426-26744/? I/MtkOmxVdecExV4L2: [0xa7118540] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x10f), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:25.321 25405-24373/com.digitalsignageplayer E/ExoPlayerImplInternal: Source error
com.google.android.exoplayer2.upstream.Loader$UnexpectedLoaderException: Unexpected OutOfMemoryError: Failed to allocate a 65552 byte allocation with 53392 free bytes and 52KB until OOM, max allowed footprint 201326592, growth limit 201326592
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:421)
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:764)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 53392 free bytes and 52KB until OOM, max allowed footprint 201326592, growth limit 201326592
at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:102)
at com.google.android.exoplayer2.source.SampleDataQueue.preAppend(SampleDataQueue.java:392)
at com.google.android.exoplayer2.source.SampleDataQueue.sampleData(SampleDataQueue.java:181)
at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:471)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:552)
at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:192)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
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:764)
2022-09-14 22:58:25.322 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:25.323 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] --- FTBQ: mNumPendingOutput 2; mFillThisBufQ.size() 0, CCDst: 0, CCSrc: 0
2022-09-14 22:58:25.323 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:25.325 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:25.688 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:25.689 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] --- FTBQ: mNumPendingOutput 9; mFillThisBufQ.size() 8, CCDst: 0, CCSrc: 0
2022-09-14 22:58:25.689 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:25.691 426-24826/? I/MtkOmxVdecExV4L2: [0xa7118540] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:25.707 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118540] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:58:28.814 426-29796/? E/OMXNodeInstance: setParameter(0xa7118d44:MTK.DECODER.AVC, OMX.google.android.index.allocateNativeHandle(0x7f20040e): Output:1 en=0) ERROR: BadParameter(0x80001005)
2022-09-14 22:58:28.815 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (176 144 176 160 5 46096 0x7f000001), pPortDef (176 144 176 160 5 46096 0x7f000001)
2022-09-14 22:58:28.818 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:28.879 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:28.879 426-29796/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:29.065 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2176 5 12533776 0x7f000001), pPortDef (3840 2160 3840 2176 5 12533776 0x7f000001)
2022-09-14 22:58:29.066 426-24937/? I/MtkOmxVdecExV4L2: [0xa7118d40] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:29.069 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:29.070 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- FTBQ: mNumPendingOutput 1; mFillThisBufQ.size() 1, CCDst: 0, CCSrc: 0
2022-09-14 22:58:29.070 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:29.075 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:29.076 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:29.077 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- FTBQ: mNumPendingOutput 0; mFillThisBufQ.size() 0, CCDst: 0, CCSrc: 0
2022-09-14 22:58:29.077 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] -FlushOutputPort -> mNumPendingOutput(0)
2022-09-14 22:58:29.077 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118d40] MtkOmxVdec::FreeBuffer all output buffers have been freed!!! signal mOutPortFreeDoneSem(1)
2022-09-14 22:58:29.079 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] [getReconfigOutputPortSetting] u4CheckBufferCount: 13, u4ChagnedDPBSize: 5, mMinUndequeuedBufs: 4, FRAMEWORK_OVERHEAD: 3, MAX_COLORCONVERT_OUTPUTBUFFER_COUNT:1
2022-09-14 22:58:29.092 426-492/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:29.092 426-28806/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- GetOutputPortDefinition --- (3840 2160 3840 2184 13 12583040 0x7f000003), pPortDef (3840 2160 3840 2184 13 12583040 0x10f)
2022-09-14 22:58:29.095 455-484/? I/VCodecDrv: phHandle->fgOutputEarly 0
2022-09-14 22:58:29.097 426-24936/? I/MtkOmxVdecExV4L2: [0xa7118d40] --- FTBQ: mNumPendingOutput 0; mFillThisBufQ.size() 0, CCDst: 0, CCSrc: 0
The final memory error as my app crashed:
2022-09-14 23:01:38.166 25405-25264/com.digitalsignageplayer E/AndroidRuntime: FATAL EXCEPTION: Loader:ProgressiveMediaPeriod
Process: com.digitalsignageplayer, PID: 25405
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available
2022-09-14 23:02:17.829 25405-25469/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 120 byte allocation with 80 free bytes and 80B until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 23:02:21.407 25405-25417/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 56 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 23:02:24.540 25405-25264/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 32 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 23:02:31.327 25405-25405/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 16 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592"
2022-09-14 23:02:32.654 25405-25469/com.digitalsignageplayer W/alsignageplaye: Throwing OutOfMemoryError "Failed to allocate a 152 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592" (recursive case)
2022-09-14 23:02:35.385 25405-25417/com.digitalsignageplayer E/AndroidRuntime: FATAL EXCEPTION: FinalizerWatchdogDaemon
Process: com.digitalsignageplayer, PID: 25405
java.lang.OutOfMemoryError: Failed to allocate a 56 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at java.lang.Thread.getAllStackTraces(Thread.java:1588)
at com.bugsnag.android.ThreadState.<init>(ThreadState.kt:33)
at com.bugsnag.android.ThreadState.<init>(ThreadState.kt:16)
at com.bugsnag.android.ThreadState.<init>(ThreadState.kt:23)
at com.bugsnag.android.EventInternal.<init>(EventInternal.kt:46)
at com.bugsnag.android.Event.<init>(Event.java:35)
at com.bugsnag.android.Client.notifyUnhandledException(Client.java:698)
at com.bugsnag.android.ExceptionHandler.uncaughtException(ExceptionHandler.java:65)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)
at java.lang.Daemons$FinalizerWatchdogDaemon.finalizerTimedOut(Daemons.java:436)
at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:283)
at java.lang.Daemons$Daemon.run(Daemons.java:103)
at java.lang.Thread.run(Thread.java:764)
2022-09-14 23:02:36.383 25405-25405/com.digitalsignageplayer A/alsignageplaye: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI IsInstanceOf called with pending exception java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 8 free bytes and 8B until OOM, max allowed footprint 201326592, growth limit 201326592
And my profiler:
I did receive one error around the same time as the memory errors occurred that seemed a bit weird to me. I'm not sure if this is related but for documentation purposes here it is:
2022-09-14 22:56:39.349 514-514/? W/Binder: Outgoing transactions from this process must be FLAG_ONEWAY
java.lang.Throwable
at android.os.BinderProxy.transact(Binder.java:1116)
at com.amazon.connectivitymanager.IControllerManager$Stub$Proxy.registerEventCallback(IControllerManager.java:439)
at com.amazon.connectivitymanager.ConnectivityManager.registerConnectivityEventCallback(ConnectivityManager.java:671)
at com.amazon.service.AmazonAutoPairService$2.onRemoteServiceConnected(AmazonAutoPairService.java:209)
at com.amazon.connectivitymanager.ConnectivityManager$1.onServiceConnected(ConnectivityManager.java:518)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1748)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1780)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:211)
at com.android.server.SystemServer.run(SystemServer.java:471)
at com.android.server.SystemServer.main(SystemServer.java:307)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:838)
Sample of my code: Each half-second, a component re-renders causing this code to evaluate. For the purposes of my test above, I rendered an image and then a video in an endless loop until the app crashed. It took about an hour. Under normal use, we see this error after a couple of days:
if (asset.content_type.includes('image/')) {
return <Image testID='imageAsset' resizeMode={'stretch'} source={{uri:`file://...` }} style={styles.image} />
}
if (asset.content_type.includes('video/')) {
return <Video repeat={false} resizeMode="cover" style={styles.video} fullScreen={true} source={{uri: `file:....` }} />
}
@c-moyer thank you for the report! Just to be clear:
@freeboub
"react-native": "0.64.2",
"react-native-video": "version": "5.1.1",
I have only tried a 4k (25fps) mp4 that's saved locally to the file system. I'll upgrade tonight or tomorrow and see if I can still reproduce the error. I noticed @RickoNoNo3 said the issue appeared on 6 alpha but I'll attempt to reproduce.
Still working to update my app to React Native version 0.68.2, but just wanted to update that I'm getting constant memory errors on react-native-video 5.2.1 on react native 0.65.0. My initial test video won't even successfully loop once at this point.
2022-09-15 23:47:20.921 5073-6110/com.digitalsignageplayer E/LoadTask: OutOfMemory error loading stream
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available
2022-09-15 23:47:20.948 5073-5084/com.digitalsignageplayer E/System: java.lang.OutOfMemoryError: Failed to allocate a 24 byte allocation with 0 free bytes and 3GB until OOM, max allowed footprint 201328480, growth limit 201326592
at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:62)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
at java.lang.Daemons$Daemon.run(Daemons.java:103)
at java.lang.Thread.run(Thread.java:764)
2022-09-15 23:47:20.955 5073-6086/com.digitalsignageplayer E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Playback
Process: com.digitalsignageplayer, PID: 5073
java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 0 free bytes and 3GB until OOM, max allowed footprint 201328480, growth limit 201326592
at android.media.MediaCodec$BufferInfo.dup(MediaCodec.java:1545)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2705)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:82)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1779)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:824)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:948)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
2022-09-15 23:47:21.545 5073-5073/com.digitalsignageplayer A/alsignageplaye: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI IsInstanceOf called with pending exception java.lang.OutOfMemoryError: Failed to allocate a 40 byte allocation with 0 free bytes and 3GB until OOM, max allowed footprint 201328480, growth limit 201326592
I can confirm that the issue is also reproduced on basic sample (easy to reproduce with live channel), but I am not able to highlight the root cause for now.
@c-moyer My reproduction on sample seems to be linked (at least) to react-native version. I think I have this issue: https://github.com/facebook/react-native/issues/26407
I will try to update react-native version of sample. In the time, we are also upgrading our production app to 0.68 this week.
We can investigate the issue together you you want a fast fix :) let me know !
I rebuild a sample on react native 0.70 (new architecture enabled) with a very basic video player. (Notice I worked on my company fork) and I don't reproduce the issue. This is definitely the memory leak of react-native in my point of view. The leak can be reproduced with a simple setState called in loop.
@c-moyer Can you update after react native upgrade please ?
@freeboub Thanks for the update. I was trying to upgrade from 0.67 to 0.68 but ran into issues with the new architecture with our app. I'll try and look through that again tonight and see if I can get things to work. Thanks for looking into this, I'll do all I can to help as well!
newArchEnabled=false
@freeboub I created a fresh React Native app (no expo btw) on version 0.70.1 and installed react-native-video@6.0.0-alpha.3 and I'm still getting out of memory errors except I'm getting the errors almost immediately. The video I am attempting to play stutters terribly and then after it loops, the app crashes with a memory error:
2022-09-20 21:07:38.640 17399-17399/com.digitalsignageplayer W/RenderThread: type=1400 audit(0.0:139007): avc: denied { open } for path="/dev/__properties__/u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=1585 scontext=u:r:untrusted_app:s0:c203,c256,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
2022-09-20 21:07:38.672 17399-17573/com.digitalsignageplayer I/alsignageplaye: Waiting for a blocking GC Alloc
2022-09-20 21:07:38.676 17399-17545/com.digitalsignageplayer I/alsignageplaye: Waiting for a blocking GC Alloc
2022-09-20 21:07:38.686 17399-17481/com.digitalsignageplayer I/alsignageplaye: Waiting for a blocking GC Alloc
2022-09-20 21:07:38.723 17399-17410/com.digitalsignageplayer I/alsignageplaye: Clamp target GC heap from 197MB to 192MB
2022-09-20 21:07:38.723 17399-17573/com.digitalsignageplayer I/alsignageplaye: WaitForGcToComplete blocked Alloc on HeapTrim for 51.114ms
2022-09-20 21:07:38.723 17399-17573/com.digitalsignageplayer I/alsignageplaye: Starting a blocking GC Alloc
2022-09-20 21:07:38.724 17399-17545/com.digitalsignageplayer I/alsignageplaye: WaitForGcToComplete blocked Alloc on HeapTrim for 47.734ms
2022-09-20 21:07:38.724 17399-17545/com.digitalsignageplayer I/alsignageplaye: Starting a blocking GC Alloc
2022-09-20 21:07:38.724 17399-17481/com.digitalsignageplayer I/alsignageplaye: WaitForGcToComplete blocked Alloc on HeapTrim for 38.063ms
2022-09-20 21:07:38.724 17399-17481/com.digitalsignageplayer I/alsignageplaye: Starting a blocking GC Alloc
2022-09-20 21:07:38.724 17399-17573/com.digitalsignageplayer E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Loader:ProgressiveMediaPeriod
Process: com.digitalsignageplayer, PID: 17399
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available
2022-09-20 21:07:38.725 17399-17573/com.digitalsignageplayer I/alsignageplaye: Starting a blocking GC Alloc
2022-09-20 21:07:38.728 17399-17573/com.digitalsignageplayer I/alsignageplaye: Starting a blocking GC Alloc
2022-09-20 21:07:38.729 17399-17545/com.digitalsignageplayer I/alsignageplaye: Waiting for a blocking GC Alloc
2022-09-20 21:07:38.735 17399-17481/com.digitalsignageplayer I/alsignageplaye: Waiting for a blocking GC Alloc
2022-09-20 21:07:38.782 17399-17573/com.digitalsignageplayer I/alsignageplaye: Clamp target GC heap from 197MB to 192MB
I am testing this on a physical Amazon 4k Max Firestick.
From an emulator, I haven't yet received an out of memory error, but I am getting a ton of W/ExoPlayer Warning: Free memory reached 0, forcing garbage collection
in the logcat. The video is still stuttering terribly on the emulator too.
newArchEnabled=true
Working to enable the new architecture but am currently getting the error RCTVideo is not Fabric compatible yet
when rendering the Video
component.
Hello @c-moyer, let's keep newArch feature in dedicated ticket (I have no plan to enable it in a near future, but we will need to do it for sure! )
For the memory leak, I found yesterday that there is an option enabled to prioritize time for size which can lead to a but amount of memory reserved: see https://github.com/react-native-video/react-native-video/blob/2349fad25f402d75812d449e4630172851590dc6/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java#L591
Can you try to dis ale it manually, please ? I did it yesterday in my fork, but I am not 100% sure it fixes the issue... Let me know !
@freeboub
So changing the parameter to false
didn't fix the memory issue, but it did result in a different overall error. I still noticed warnings in my logcat of forced garbage collection because memory limits had been exceeded, but here is the error which actually crashed the app. I was able to replicate this three times in a row.
2022-09-23 01:43:30.727 27155-19737/com.digitalsignageplayer A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 19737 (CodecLooper), pid 27155 (alsignageplayer)
2022-09-23 01:43:31.213 27155-19714/com.digitalsignageplayer I/alsignageplaye: Explicit concurrent copying GC freed 6576(768KB) AllocSpace objects, 130(8MB) LOS objects, 3% free, 155MB/161MB, paused 144us total 2.349s
2022-09-23 01:43:31.210 27155-27155/com.digitalsignageplayer W/MediaCodec_loop: type=1400 audit(0.0:565980): avc: denied { read } for name="u:object_r:media_prop:s0" dev="tmpfs" ino=1403 scontext=u:r:untrusted_app:s0:c203,c256,c512,c768 tcontext=u:object_r:media_prop:s0 tclass=file permissive=0
2022-09-23 01:43:31.215 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: [ASAP] HW.video.avc Got First Frame Render 194786969(4261)
2022-09-23 01:43:31.216 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: App sets Timestamps for render in SurfaceFlinger
2022-09-23 01:43:31.216 27155-19719/com.digitalsignageplayer E/BufferQueueProducer: [SurfaceTexture-0-27155-5038] queueBuffer: BufferQueue has been abandoned
2022-09-23 01:43:31.216 27155-19719/com.digitalsignageplayer E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
2022-09-23 01:43:31.216 27155-19719/com.digitalsignageplayer E/FrameEvents: updateAcquireFence: Did not find frame.
2022-09-23 01:43:31.216 27155-19719/com.digitalsignageplayer E/ACodec: queueBuffer failed in onOutputBufferDrained: -19
2022-09-23 01:43:31.216 27155-19719/com.digitalsignageplayer E/ACodec: signalError(omxError 0x80001001, internalError -19)
2022-09-23 01:43:31.217 27155-19718/com.digitalsignageplayer E/MediaCodec: Codec reported err 0xffffffed, actionCode 0, while in state 6
2022-09-23 01:43:31.217 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: 27155.HW.video.avc.DecoderErrorFatal = 1
2022-09-23 01:43:31.217 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: 27155.HW.video.avc.ASAP-P2Ms = 4
2022-09-23 01:43:31.217 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: 27155.HW.video.avc.ASAP-P3Ms = 15
2022-09-23 01:43:31.217 27155-19718/com.digitalsignageplayer I/MediaCodecLogger: 27155.HW.video.avc.FirstFrameReadyMs = 246
2022-09-23 01:43:31.218 27155-19718/com.digitalsignageplayer E/libc: Access denied finding property "media.metrics.enabled"
2022-09-23 01:43:31.220 27155-19718/com.digitalsignageplayer D/SurfaceUtils: disconnecting from surface 0xbba4e008, reason disconnectFromSurface
2022-09-23 01:43:31.221 27155-19714/com.digitalsignageplayer E/MediaCodecVideoRenderer: Video codec error
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueInputBuffer(Native Method)
at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2635)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:99)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1190)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:794)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
2022-09-23 01:43:31.222 27155-19714/com.digitalsignageplayer E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640033, -1, null, [3840, 2160, 25.0], [-1, -1]), format_supported=YES
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:566)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.android.exoplayer2.video.MediaCodecVideoDecoderException: Decoder failed: OMX.MTK.VIDEO.DECODER.AVC
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1590)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:813)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueInputBuffer(Native Method)
at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2635)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:99)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1190)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:794)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:989)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:490)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
2022-09-23 01:43:31.225 27155-19714/com.digitalsignageplayer E/ExoPlayerImplInternal: Disable failed.
java.lang.IllegalStateException
at android.media.MediaCodec.native_flush(Native Method)
at android.media.MediaCodec.flush(MediaCodec.java:2131)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:166)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:877)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:870)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:710)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:561)
at com.google.android.exoplayer2.BaseRenderer.disable(BaseRenderer.java:186)
at com.google.android.exoplayer2.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1651)
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1392)
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1355)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:582)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:65)
I am also running into this issue (on 6.0.0-alpha3) on Android, but only (or only noticeable) when the video file is local (gallery or camera, I didn't try bundled video in app package). It's pretty bad as loading any local video over a few minutes long will immediately trigger the out of memory exception. It will also trigger if few short videos were loaded consecutively. Loading videos from a remote url doesn't seem to trigger it.
Upon further digging, my issue seems to be related to this: https://github.com/google/ExoPlayer/issues/7480 Disabling the "repeat" seems to solve the problem for me.
I have been struggling with this memory issue too. I realized that my memory problem was partly related to React Navigation. I had too many screens with the Video component in the navigation stack. Once I started replacing screens instead of navigating, things got manageable. However, is there a better technique for un-mounting/disabling the Video component without having to modify the Navigation Stack?
@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.
@freeboub Have you had a chance to look at this anymore?
seeing it also
i'm having this issue in my project as well, the app crashes after i record a video, when the app shows a preview of it
only crashes with resolutions above FHD tho
here is my logcat output
i used adb logcat -D *:E
tested on samsung s20+ and s21
I created a fresh React Native app and installed 6.0.0-alpha.3. I'm noticing a difference in the memory leak compared with my initial profiler that I posted above. In the initial profiler, the memory leakage was appearing under "other" but now it's appearing under "native". I've spent countless hours trying to figure this out and would appreciate any help since this is vital to our app.
These rendered nodes seems to be hanging around. A few minutes later:
Hello,
Have you tried bufferConfig ? Default max buffer length is 50 sec which is a lot.
I got my app crash with just 3 or 4 very short looping videos. After limiting the buffer to something shorter than video length the memory stabilized.
i got it fixed by adding
android:largeHeap="true"
android:hardwareAccelerated="true"
to my manifest, it does not mean the issue is fixed tho, only means the app won't crash as often
but give it a try @RickoNoNo3
Not sure on how to handle this issue as it seems linked to props (loop) and video type. On my side I don't see any leak with video... Not sure on how to proceed. To be reproduced with sample exoplayer to ensure this is not an exoplayer issue ...
@freeboub Can you provide the code you're testing with that doesn't have the memory leak?
until there is a resolution on this, this solution(https://github.com/react-native-video/react-native-video/issues/2984) solved my case:
react-native: 0.72.3 react-native-video: 6.0.0-alpha.6 Android: 13 Videos <= 1min
<Video ref={playerRef} source={{ uri: file.path }} resizeMode="contain" controls bufferConfig={{ minBufferMs: 2500, maxBufferMs: 3000, // default is 50 segundos, 3 seconds bufferForPlaybackMs: 2500, bufferForPlaybackAfterRebufferMs: 2500, }} />
Might be related to my work around here: https://github.com/react-native-video/react-native-video/issues/2984#issuecomment-1853228133
I have a FlatList w/ Videos and I was able to workaround this Memory issue by disabling
repeat
on Android:<Video ref={vidRef} // RNV SOURCE IS HLS | .m3u8 source={uri} ... // RNV ANDROID ISSUE - `hideShutterView` ONLY WORKS W/ TEXTURE VIEWS NOT SURFACE VIEWS :/ useTextureView hideShutterView // RNV VIDEO LOOP (REPEAT) CAUSES MEMORY CRASH repeat={Platform.OS === 'android' ? false : true} />
Having issues with this as well on 5.2.1 and 6.0.0-beta.3 BufferConfig and repeat didn't make a difference.
Hi Team,
We have this issue as well:
[ExoPlayer:Playback] Free memory reached 0, forcing garbage collection
Background concurrent mark compact GC freed 30863(9548KB) AllocSpace objects, 28(17MB) LOS objects, 39% free, 36MB/60MB, paused 1.693ms,7.307ms total 270.995ms
WaitForGcToComplete blocked Explicit on Background for 183.764ms
Explicit concurrent mark compact GC freed 3274(696KB) AllocSpace objects, 1(152KB) LOS objects, 40% free, 35MB/59MB, paused 2.520ms,7.236ms total 251.234ms
bufferpool2 0xb400006c2e7dde28 : 5(40960 size) total buffers - 4(32768 size) used buffers - 1433/1438 (recycle/alloc) - 5/1435 (fetch/transfer)
Made these changes with no improvement at all:
BufferConfig and repeat
android:largeHeap="true"
android:hardwareAccelerated="true"
This has been opened for a while and we don't see any developments. Any updates?
@dnetcrawler I tried to investigate and it seems to be an issue in exoplayer (I cannot find anymore the issue I found). If you reproduce it, I would advise you to try on a sample exoplayer to tripple check...
After doing seek operation on the Video player, the video starts to lag or flick. I think is related to memory leaks.
The issue persists, use HLS live stream to reproduce it immediately.
I can confirm the issue still persists on 6.3.0
For me the repeat
prop was causing the memory leak, fixed by repeating the video using ref
import Video, { VideoRef } from 'react-native-video';
<Video
ref={videoRef}
source={require('~/assets/videos/intro.mp4')}
resizeMode="cover"
repeat={false}
onEnd={() => videoRef.current?.seek(0)}
/>
For me the
repeat
prop was causing the memory leak, fixed by repeating the video using refimport Video, { VideoRef } from 'react-native-video'; <Video ref={videoRef} source={require('~/assets/videos/intro.mp4')} resizeMode="cover" repeat={false} onEnd={() => videoRef.current?.seek(0)} />
thanks tried this resolved my issue its due to repeating the video.
Whats the final solution to this? Can we do something? Can we contribute in some way? I have the same memory leakage and I must render multiple HD videos at the same time.
@davinun99 I my mind all issues comes from exoplayer, not react native video itself. There is one leak issue in exoplayer, when you repeat small videos (with repeat=true) a workround is available in the thread. Some 4K video leaks. not 100% sure f the root cause. Keep in mind that video decoders of the device can also leak :/
Bug
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:
Platform
Android Exoplayer
Environment info
React native info output:
Library version: 4.4.5 ~ 5.2.0 ~ 6.0.0-alpha0 all have this problem
Steps To Reproduce
react-native-video
autoplay
andsilent
andplayInBackground
andrepeat
and 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)setInterval
to update it regularly. This step is to let the Video component auto refresh many times.demo
:Expected behaviour
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.