Getting sometimes an ExoPlayerImplInternal: IllegalArgumentException
See original GitHub issueIssue description
Getting a playback error randomly and in very rare occasions. It happens right after our app finishes encoding a new video, and a new ExoPlayer instance is created to play it. There are no problem with the videos themselves, as trying a playback again will not produce any error.
In our flow we encode a video using the MediaCodec API. Then ensure the video is fully saved to file. Release the MediaCodec and MediaMuxer resources. And finally open a new ExoPlayer instance to play it.
The only thing I can think of, and I’m only guessing, is that maybe there is some type of OS lock when the system is in the process of releasing the MediaCodec used for encoding, making ExoPlayer to fail. Although, besides the fact that I don’t know how long does the OS take to release the codec resources, I don’t see why ExoPlayer would need a video codec which was used only for encoding, and not decoding.
Reproduction steps
To play a video right after has been created/encoded. The problem happens in very rare occasions.
A full bug report captured from the device
019-08-27 15:31:01.807 789-3756/? E/VDEC: [set_parameter] : [5399] Allocate native buffer failed, invalid port index 1
2019-08-27 15:31:01.807 789-3756/? E/OMXNodeInstance: setParameter(0xead79de0:hisi.decoder.avc, OMX.google.android.index.allocateNativeHandle(0x7f000008): Output:1 en=0) ERROR: BadPortIndex(0x8000101b)
2019-08-27 15:31:01.807 789-3756/? E/OMXNodeInstance: getExtensionIndex(0xead79de0:hisi.decoder.avc, OMX.google.android.index.storeMetaDataInBuffers) ERROR: NotImplemented(0x80001006)
2019-08-27 15:31:01.807 25784-27450/com.production.test E/ACodec: [OMX.hisi.video.decoder.avc] setPortMode on output to DynamicANWBuffer failed w/ err -2147483648
2019-08-27 15:31:01.807 789-3756/? E/VDEC: [set_parameter] : [5399] Allocate native buffer failed, invalid port index 1
2019-08-27 15:31:01.807 789-3756/? E/OMXNodeInstance: setParameter(0xead79de0:hisi.decoder.avc, OMX.google.android.index.allocateNativeHandle(0x7f000008): Output:1 en=0) ERROR: BadPortIndex(0x8000101b)
2019-08-27 15:31:01.807 789-3756/? E/OMXNodeInstance: getExtensionIndex(0xead79de0:hisi.decoder.avc, OMX.google.android.index.storeMetaDataInBuffers) ERROR: NotImplemented(0x80001006)
2019-08-27 15:31:01.809 25784-27450/com.production.test E/HwExtendedCodec: mime: video/avc matching compontent failed!
2019-08-27 15:31:01.813 789-3756/? E/OMXNodeInstance: setConfig(0xead79de0:hisi.decoder.avc, ConfigPriority(0x6f800002)) ERROR: BadParameter(0x80001005)
2019-08-27 15:31:01.828 3406-27458/? E/NfcNci:HwCustNfcService: applyRouting -1.1
2019-08-27 15:31:01.904 636-1184/? E/BufferQueueProducer: [SurfaceView - com.production.test/app.application.activities.PlayerVideoActivity$Internal#0] setMaxDequeuedBufferCount: requested buffer count 1 is less than minimum 2
2019-08-27 15:31:01.904 25784-27450/com.production.test E/Surface: IGraphicBufferProducer::setBufferCount(1) returned Invalid argument
2019-08-27 15:31:01.904 25784-27450/com.production.test E/ACodec: native_window_set_buffer_count failed: Invalid argument (22)
2019-08-27 15:31:01.906 25784-27446/com.production.test E/ExoPlayerImplInternal: Internal runtime error.
java.lang.IllegalArgumentException
at android.media.MediaCodec.native_setSurface(Native Method)
at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1986)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setOutputSurfaceV23(MediaCodecVideoRenderer.java:1103)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setSurface(MediaCodecVideoRenderer.java:509)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.handleMessage(MediaCodecVideoRenderer.java:475)
at com.google.android.exoplayer2.ExoPlayerImplInternal.deliverMessage(ExoPlayerImplInternal.java:973)
at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageToTarget(ExoPlayerImplInternal.java:944)
at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageInternal(ExoPlayerImplInternal.java:926)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:363)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:216)
at android.os.HandlerThread.run(HandlerThread.java:65)
2019-08-27 15:31:01.910 789-789/? E/VDEC: [check_port_param] : [5001] set_parameter: invalid buffer count 15, should not be bigger than max count 14
2019-08-27 15:31:01.910 789-789/? E/OMXNodeInstance: setParameter(0xead79de0:hisi.decoder.avc, ParamPortDefinition(0x2000001)) ERROR: Undefined(0x80001001)
2019-08-27 15:31:01.932 787-1260/? E/IppAlgoSmartAE: [b378326_64E] onUnloadLibrary() mSmartAESoState is unloaded ,so we not Uninit it!
2019-08-27 15:31:01.943 25784-25784/com.production.test E/main#1.VideoPlayerModule.onPlayerError: Unexpected video player error.content://media/external/video/media/37281
com.google.android.exoplayer2.ExoPlaybackException: java.lang.IllegalArgumentException
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:397)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:216)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.IllegalArgumentException
at android.media.MediaCodec.native_setSurface(Native Method)
at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1986)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setOutputSurfaceV23(MediaCodecVideoRenderer.java:1103)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setSurface(MediaCodecVideoRenderer.java:509)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.handleMessage(MediaCodecVideoRenderer.java:475)
at com.google.android.exoplayer2.ExoPlayerImplInternal.deliverMessage(ExoPlayerImplInternal.java:973)
at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageToTarget(ExoPlayerImplInternal.java:944)
at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageInternal(ExoPlayerImplInternal.java:926)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:363)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:216)
at android.os.HandlerThread.run(HandlerThread.java:65)
Version of ExoPlayer being used
2.10.4
Device(s) and version(s) of Android being used
Android PIE. Huawei P20Lite
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
We are narrowing the cause of the issue. The latest findings:
When we are encoding a video we use a TextureView as a camera preview surface, which is the source of the frames being encoded.
In our flow, once the encoding ends, we stop the camera preview “asynchronously”, and at the same time we open a new Activity for the new encoded video playback.
It seems that if before opening the video playback, we ensure to synchronously wait till the camera preview has fully released the allocated surface preview resources, then so far the issue can’t be longer reproduced.
Closing due to lack of activity. Please reopen if needed.