[Bug] MediaCodec: Codec reported err 0xfffffff4/NO_MEMORY on Android 13 devices
See original GitHub issueExoPlayer Version
2.17.1 2.18.1
Devices that reproduce the issue
- Pixel 4
- Pixel 4XL
- Pixel 4a
- Pixel 4a (5G)
- Pixel 5
- Pixel 5a
Devices that do not reproduce the issue
Pixel 6 Pixel 6 Pro
Reproducible in the demo app?
Yes
Reproduction steps
-
Use the demo example of ExoPlayer: https://github.com/google/ExoPlayer/releases/tag/r2.18.1
-
Build the Demo and play Video with named: 60fps DASH / 4K (MP4, H264, Widevine cenc) content on Pixel 4a…etc device, Android 13 operating system.
-
Use the SEEK or SKIP function (continuously for a short period of time). You may need to keep using the SEEK function continuously until an error occurs. Maybe this error will not occur as soon as you seek the video, maybe you will need to seek continuously until the error occurs. But sometimes it happens the first time you seek. I also don’t know how much I need to seek, if the error will occur, there is no exact data.
-
Error will be displayed after you SEEK or SKIP a few times.
You can also keep playing the video without having to use the SEEK or SKIP function to reproduce this error. It will appear after a certain amount of time. It could be 3 minutes, 5 minutes, or more than 10 or 15 minutes.
You can also use the demo example on the version: https://github.com/google/ExoPlayer/releases/tag/r2.10.6, with Youtube DASH/Google Glass (MP4, H264) or Google Play (MP4, H264) . It seems more difficult to reproduce the error in version 2.18.1 than in version 2.10.6, but it still happens.
Expected result
We have not found a specific solution yet, so we hope you can review and solve it for us. Or at least suggest a specific workaround that can solve this problem.
Our current application is still using version 2.10.6, and currently it is not possible to upgrade to the latest version. So if you have any solutions for 2.10.6 version, I would be very grateful.
Sincerely Thank
Actual result
Our project is currently using the ExoPlayer library to play video contents or live streaming. But when the user uses the SEEK or SKIP function or some times even does nothing, after about 15-20 minutes, the video player will have an error and cannot continue playing.
The members of the project’s development team tried to debug and find the reason for the above problem, the results were as follows:
・It only happens on Android 13, Android 12 or earlier version does not.
・Currently our team only tested on a few devices, most of the devices below will have the above error, others seem to not.
Devices where the error occurred:
- Pixel 4
- Pixel 4XL
- Pixel 4a
- Pixel 4a (5G)
- Pixel 5
- Pixel 5a
Devices that do not appear to be error-prone:
- Pixel 6
- Pixel 6 Pro
At the moment we can only test on the above devices, so it is possible that other devices that we have not tested are also possible.
After members of our development team checked the log of the errors that occurred, it is mainly related to the MediaCodec class on the framework side of the system. To make sure it has something to do with the version of the ExoPlayer library we’re using, we’ve also tested it on the most recent version of the current ExoPlayer, and the above error still occurs, all on the above devices. And they all have the same error, both in the MediaCodec class.
I have attached the error log and where the error occurred and the necessary information.
Where the error occurs ?
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo E/CCodec: Resume request for Input Buffers failed
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo E/MediaCodec: Codec reported err 0xfffffff4/NO_MEMORY, actionCode 0, while in state 6/STARTED
Which ExoPlayer version using ?
ExoPlayer 2.10.6
ExoPlayer 2.17.1
ExoPlayer 2.18.1
Operating system version:
Android 13 Build version: TP1A.220905.004
Error log:
2022-09-30 13:49:59.513 16086-16142/com.google.android.exoplayer2.demo D/MediaCodec: keep callback message for reclaim
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo I/CCodecConfig: query failed after returning 17 values (BAD_INDEX)
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 1342179345.
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 2415921170.
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 1610614798.
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo W/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] start: cannot allocate memory at all
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo E/CCodec: Resume request for Input Buffers failed
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo E/MediaCodec: Codec reported err 0xfffffff4/NO_MEMORY, actionCode 0, while in state 6/STARTED
2022-09-30 13:49:59.513 16086-16157/com.google.android.exoplayer2.demo D/SurfaceUtils: disconnecting from surface 0x72f662aaf0, reason disconnectFromSurface
2022-09-30 13:49:59.514 16086-16165/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Ignoring stale input buffer done callback: last flush index = 1520, frameIndex = 1519
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] flushed work; ignored.
2022-09-30 13:49:59.514 16086-16159/com.google.android.exoplayer2.demo D/CCodecBufferChannel: [c2.qti.avc.decoder.secure#299] Discard frames from previous generation.
2022-09-30 13:49:59.518 16086-16173/com.google.android.exoplayer2.demo D/CCodecBuffers: [c2.android.aac.decoder#926:1D-Output.Impl[N]] Client returned a buffer it does not own according to our record: 0
2022-09-30 13:49:59.518 16086-16173/com.google.android.exoplayer2.demo D/CCodecBuffers: [c2.android.aac.decoder#926:1D-Output.Impl[N]] Client returned a buffer it does not own according to our record: 1
2022-09-30 13:49:59.518 16086-16173/com.google.android.exoplayer2.demo D/CCodecBuffers: [c2.android.aac.decoder#926:1D-Output.Impl[N]] Client returned a buffer it does not own according to our record: 2
2022-09-30 13:49:59.518 16086-16173/com.google.android.exoplayer2.demo D/CCodecBuffers: [c2.android.aac.decoder#926:1D-Output.Impl[N]] Client returned a buffer it does not own according to our record: 3
2022-09-30 13:49:59.519 16086-16142/com.google.android.exoplayer2.demo D/MediaCodec: keep callback message for reclaim
2022-09-30 13:49:59.519 16086-16173/com.google.android.exoplayer2.demo I/CCodecConfig: query failed after returning 20 values (BAD_INDEX)
2022-09-30 13:49:59.519 16086-16173/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 1342179345.
2022-09-30 13:49:59.519 16086-16173/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 2415921170.
2022-09-30 13:49:59.519 16086-16173/com.google.android.exoplayer2.demo W/Codec2Client: query -- param skipped: index = 1610614798.
2022-09-30 13:49:59.521 16086-16142/com.google.android.exoplayer2.demo E/MediaCodecVideoRenderer: Video codec error
android.media.MediaCodec$CodecException: Error 0xfffffff4
2022-09-30 13:49:59.522 16086-16142/com.google.android.exoplayer2.demo D/MediaCodecInfo: NoSupport [sizeAndRate.support, 3840x2160x60.0] [c2.qti.avc.decoder.secure, video/avc] [sunfish, Pixel 4a, Google, 33]
2022-09-30 13:49:59.524 16086-16142/com.google.android.exoplayer2.demo E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640033, 19382783, null, [3840, 2160, 60.0], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:575)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.video.MediaCodecVideoDecoderException: Decoder failed: c2.qti.avc.decoder.secure
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException(MediaCodecVideoRenderer.java:1512)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:813)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff4
2022-09-30 13:49:59.525 16086-16142/com.google.android.exoplayer2.demo E/ExoPlayerImplInternal: Disable failed.
java.lang.IllegalStateException
at android.media.MediaCodec.native_flush(Native Method)
at android.media.MediaCodec.flush(MediaCodec.java:2388)
at com.google.android.exoplayer2.mediacodec.AsynchronousMediaCodecAdapter.flush(AsynchronousMediaCodecAdapter.java:237)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:864)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:857)
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:1671)
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1411)
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1374)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:591)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Media
ExoPlayer 2.18.1
60fps DASH / 4K (MP4, H264, Widevine cenc)
ExoPlayer 2.10.6
Youtube DASH/Google Glass (MP4, H264) or Google Play (MP4, H264)
Bug Report
- You will email the zip file produced by
adb bugreport
to dev.exoplayer@gmail.com after filing this issue.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (7 by maintainers)
I believe the problem occurs when seeks are too frequent. You may be able to implement logic in your app to mitigate this by intercepting calls to seek on your player and delaying consecutive seek calls for a short while.
You could do this with
ForwardingPlayer
(you need to ensure you override allseek
-related methods). See more info: https://exoplayer.dev/customization.html#intercepting-method-calls-with-forwardingplayerThe fix included in Android 13 QPR1 Beta 2 build, here is the issue that tracked the platform bug.