ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed:

Open Jaydipnathani opened this issue 2 years ago • 24 comments

Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1])

Every Time generate this issue

  1. Play video in our app -> works fine
  2. Run other video application
  3. Start video in other video application
  4. Minimize other video application
  5. Go back to our app
  6. Try to play video -> fail DecoderInitializationException
  7. Kill other video application
  8. Go back to our app
  9. Try to play video -> works fine

And Also show black screen on playerview

2021-07-27 16:51:10.097 10029-10904/com.oneintro.intromaker E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, null, video/avc, avc1.4D402A, -1, null, [1920, 1080, 60.000004], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1051)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1465)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
        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:164) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
     Caused by: android.media.MediaCodec$CodecException: Error 0xffffec77
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:1943)
        at android.media.MediaCodec.configure(MediaCodec.java:1872)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1137)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1044)

Is there any way to release programmatically codec resources which are used by another app? This is quite a significant problem for us.

I can not find any solution so if you have any solution please help me out.

I have wasted 3 days in this issue but have not yet found a solution. Please give solution.

Jaydipnathani avatar Jul 27 '21 11:07 Jaydipnathani

What is the "other video" application you refer to? Is it a specific one?

christosts avatar Jul 27 '21 12:07 christosts

What is the "other video" application you refer to? Is it a specific one?

Like TED , VideoLab, ExoPlayer demo ..ect app that uses video app exoplayer

Jaydipnathani avatar Jul 27 '21 13:07 Jaydipnathani

This is quite unusual. Since it's more than one app and we don't have any reports about these apps not releasing resources (and the ExoPlayer demo app should definitely behave properly!). I wonder if the problem is the other way around, and whether your app is managing resources properly.

In your application, do you release and re-create player instances in your app accordingly? The demo app's PlayerActivity (or the ExoPlayer code lab) show this clearly. Is it possible your app does not release resources?

christosts avatar Jul 27 '21 13:07 christosts

This is quite unusual. Since it's more than one app and we don't have any reports about these apps not releasing resources (and the ExoPlayer demo app should definitely behave properly!). I wonder if the problem is the other way around, and whether your app is managing resources properly.

In your application, do you release and re-create player instances in your app accordingly? The demo app's PlayerActivity (or the ExoPlayer code lab) show this clearly. Is it possible your app does not release resources?

The same issue occurs in ExoPlayer demo app

every time black screen and Decoder init failed: when others video app is open.

release and re-create player instances in your app accordingly? YES

2021-07-28 09:33:36.055 7940-9706/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.64002A, 10948900, null, [1920, 1080, 60.0], [-1, -1]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, null, video/avc, avc1.64002A, 10948900, null, [1920, 1080, 60.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1051)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1465)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
        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:164) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 
     Caused by: android.media.MediaCodec$CodecException: Error 0xffffec77
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:1943)
        at android.media.MediaCodec.configure(MediaCodec.java:1872)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1137)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1044)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1465) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945) 
        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:164) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 

Same error in Exoplayer Demo App.

https://user-images.githubusercontent.com/54942991/127268058-9244829d-df78-4e96-b403-0be92cbed4d5.mp4

Jaydipnathani avatar Jul 28 '21 03:07 Jaydipnathani

Thank you for the recording. I tried the same setup as your recording:

  • ExoPlayer demo app starts
  • Then switch to VideoLab
  • Then go back to ExoPlayer demo app

but I did not observe the problem. I tried on a Pixel 4 device and a Samsung Galaxy S9 with Android 9. From your recording, I believe you are using a Samsung device (Exynos chip). I assume you have not modified the ExoPlayer demo app. Also from the recording, it appears to me that the VideoLab is the one not releasing the MediaCodec instance properly.

On what devices have you seen this behavior? Is it only one specific device? Does this happen with any combination of video applications?

To answer your question

Is there any way to release programmatically codec resources which are used by another app?

I am not aware of such an API.

If you want to debug what app is holding MediaCodec instances, you may run adb shell dumpsys (documentation about the command). For example, with adb shell dumpsys media.resource_manager you can see which process holds the MediaCodec instance (you may run this after apps are in the background). This command will show the ID of the process, you can find the package name of the process by running adb shell dumpsys and searching for the specific PID.

So far, this does not look like a problem specific to ExoPlayer, but I'll wait for any additional information you have before closing this issue.

christosts avatar Jul 28 '21 11:07 christosts

On what devices have you seen this behavior? Is it only one specific device? Does this happen with any combination of video applications?

I have an issue with Samsung-J7 and Samsung-J5 device.

But My question is Why the issue comes only in the Exoplayer demo app. Why the issue does not come in the video lab ? Same Exoplayer use in both app.

I used the adb command but I did not understand the output of the command. So Please help me how to fix this issue.

adb shell dumpsys media.resource_manager adb shell dumpsys

D:\Android\sdk\platform-tools>adb shell dumpsys media.resource_manager
ResourceManagerService: 0xf26302c0
  Policies:
    SupportsMultipleSecureCodecs: 1
    SupportsSecureWithNonSecureCodec: 1
  Processes:
    Pid: 6060
    Pid: 10688
      Client:
        Id: 3731018656
        Name: OMX.Exynos.avc.dec
        Resources:
          non-secure-codec/video-codec:1
    Pid: 13300
      Client:
        Id: 3246079232
        Name: OMX.Exynos.avc.dec
        Resources:
          non-secure-codec/video-codec:1
          graphic-memory/unspecified:0
        mediaInfo:
          854x480(fps:25) - SoftCodec : No, Encorder : No
        state: Waiting
      Client:
        Id: 3345963968
        Name: OMX.Exynos.avc.dec
        Resources:
          non-secure-codec/video-codec:1
          graphic-memory/unspecified:0
        mediaInfo:
          600x900(fps:25) - SoftCodec : No, Encorder : No
        state: Waiting
      Client:
        Id: 3298701440
        Name: OMX.Exynos.avc.dec
        Resources:
          non-secure-codec/video-codec:1
          graphic-memory/unspecified:0
        mediaInfo:
          640x360(fps:30) - SoftCodec : No, Encorder : No
        state: Waiting
      Client:
        Id: 3298743040
        Name: OMX.Exynos.avc.dec
        Resources:
          non-secure-codec/video-codec:1
    Pid: 14860
  Events logs (most recent at top):
    07-29 09:25:19 removeResource(pid 14860, clientId 3328557472)
    07-29 09:25:19 removeResource(pid 14860, clientId 3328557472)
    07-29 09:25:19 addResource(pid 14860, clientId 3328557472, resources non-secure-codec/video-codec:1 )
    07-29 09:25:19 removeResource(pid 14860, clientId 3328557472)
    07-29 09:25:19 addResource(pid 14860, clientId 3328557472, resources non-secure-codec/video-codec:1 )
    07-29 09:25:16 removeResource(pid 14860, clientId 3328703776)
    07-29 09:25:16 removeResource(pid 14860, clientId 3328703776)
    07-29 09:25:16 addResource(pid 14860, clientId 3328703776, resources non-secure-codec/video-codec:1 )
    07-29 09:25:16 removeResource(pid 14860, clientId 3328703776)
    07-29 09:25:16 addResource(pid 14860, clientId 3328703776, resources non-secure-codec/video-codec:1 )
    07-29 09:25:12 removeResource(pid 14860, clientId 3764052320)
    07-29 09:25:12 removeResource(pid 14860, clientId 3764052320)
    07-29 09:25:12 removeResource(pid 14860, clientId 3764052096)
    07-29 09:25:12 removeResource(pid 14860, clientId 3764052096)
    07-29 09:25:06 addMediaInfo(PID 14860, clientID 3764052096, Resources 1920x1080(fps:60) - SoftCodec : No, Encorder : No )
    07-29 09:25:06 addResource(pid 14860, clientId 3764052096, resources graphic-memory/unspecified:0 )
    07-29 09:25:06 addResource(pid 14860, clientId 3764052096, resources non-secure-codec/video-codec:1 )
    07-29 09:23:46 removeResource(pid 14860, clientId 3764052224)
    07-29 09:23:46 removeResource(pid 14860, clientId 3764052224)
    07-29 09:23:46 removeResource(pid 14860, clientId 3764052064)
    07-29 09:23:46 removeResource(pid 14860, clientId 3764052064)
    07-29 09:23:32 addMediaInfo(PID 14860, clientID 3764052064, Resources 1920x1080(fps:60) - SoftCodec : No, Encorder : No )
    07-29 09:23:32 addResource(pid 14860, clientId 3764052064, resources graphic-memory/unspecified:0 )
    07-29 09:23:32 addResource(pid 14860, clientId 3764052064, resources non-secure-codec/video-codec:1 )
    07-29 09:23:25 removeResource(pid 14860, clientId 3326818624)
    07-29 09:23:25 removeResource(pid 14860, clientId 3326818624)
    07-29 09:23:25 removeResource(pid 14860, clientId 3326816544)
    07-29 09:23:25 removeResource(pid 14860, clientId 3326816544)
    07-29 09:23:21 addMediaInfo(PID 14860, clientID 3326816544, Resources 1920x1080(fps:60) - SoftCodec : No, Encorder : No )
    07-29 09:23:21 addResource(pid 14860, clientId 3326816544, resources graphic-memory/unspecified:0 )
    07-29 09:23:21 addResource(pid 14860, clientId 3326816544, resources non-secure-codec/video-codec:1 )
    07-29 09:23:13 addMediaInfo(PID 13300, clientID 3298701440, Resources 640x360(fps:30) - SoftCodec : No, Encorder : No )
    07-29 09:23:13 addResource(pid 13300, clientId 3298701440, resources graphic-memory/unspecified:0 )
    07-29 09:22:40 addMediaInfo(PID 13300, clientID 3345963968, Resources 600x900(fps:25) - SoftCodec : No, Encorder : No )
    07-29 09:22:40 addResource(pid 13300, clientId 3345963968, resources graphic-memory/unspecified:0 )
    07-29 09:22:39 addMediaInfo(PID 13300, clientID 3246079232, Resources 854x480(fps:25) - SoftCodec : No, Encorder : No )
    07-29 09:22:39 addResource(pid 13300, clientId 3246079232, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3298743040, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addResource(pid 13300, clientId 3298701440, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345963968, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addResource(pid 13300, clientId 3246079232, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439328)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439328)
    07-29 09:22:15 addResource(pid 13300, clientId 3345439328, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439328)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246079200)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246079200)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246218528)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246218528)
    07-29 09:22:15 removeResource(pid 13300, clientId 3298702048)
    07-29 09:22:15 removeResource(pid 13300, clientId 3298702048)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345963872)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345963872)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345962272)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345962272)
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3246079200, Resources 1680x720(fps:30) - SoftCodec : Yes, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3246079200, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3246079200, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3246218528, Resources 1680x720(fps:30) - SoftCodec : Yes, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3246218528, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3246218528, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3298702048, Resources 1680x720(fps:30) - SoftCodec : Yes, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3298702048, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3298702048, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3345963872, Resources 1680x720(fps:30) - SoftCodec : Yes, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3345963872, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345963872, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3345962272, Resources 1680x720(fps:30) - SoftCodec : Yes, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3345962272, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345962272, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345439328, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3345964608)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345964608)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345962272)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345962272)
    07-29 09:22:15 removeResource(pid 13300, clientId 3337917792)
    07-29 09:22:15 removeResource(pid 13300, clientId 3337917792)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246144320)
    07-29 09:22:15 removeResource(pid 13300, clientId 3246144320)
    07-29 09:22:15 addResource(pid 13300, clientId 3246144320, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3246144320)
    07-29 09:22:15 addResource(pid 13300, clientId 3246144320, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3298702048)
    07-29 09:22:15 removeResource(pid 13300, clientId 3298702048)
    07-29 09:22:15 addResource(pid 13300, clientId 3298702048, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3298702048)
    07-29 09:22:15 addResource(pid 13300, clientId 3298702048, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3345964608, Resources 1680x720(fps:30) - SoftCodec : No, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3345964608, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345964608, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3345962272, Resources 1680x720(fps:30) - SoftCodec : No, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3345962272, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3345962272, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 addMediaInfo(PID 13300, clientID 3337917792, Resources 1680x720(fps:30) - SoftCodec : No, Encorder : No )
    07-29 09:22:15 addResource(pid 13300, clientId 3337917792, resources graphic-memory/unspecified:0 )
    07-29 09:22:15 addResource(pid 13300, clientId 3337917792, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439456)
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439456)
    07-29 09:22:15 addResource(pid 13300, clientId 3345439456, resources non-secure-codec/video-codec:1 )
    07-29 09:22:15 removeResource(pid 13300, clientId 3345439456)
    ...

Jaydipnathani avatar Jul 29 '21 04:07 Jaydipnathani

I'm afraid I don't have access to the specific Samsung devices.

Running adb shell dumpsys media.resource_manager will output what process has acquired decoders. When I have the ExoPlayer demo app playing video on a Pixel 4 and run the command, it outputs something like this

Pid: 22696
      Client:
        Id: 516341531888
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
          battery/video-codec:[]:1

This says that process 22696 has acquired the decoder c2.qti.avc.decoder. When I minimize the ExoPlayer demo app and re-run the command, the output for process 22696 is empty, which indicates that the app released the codec (correct behavior).

When I run VideoLab and then run the command, the following output is produced:

Pid: 29962
      Client:
        Id: -5476376630540986320
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
      Client:
        Id: -5476376630540968400
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
      Client:
        Id: -5476376630540958208
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
      Client:
        Id: -5476376630540944208
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
      Client:
        Id: -5476376630540785168
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
          battery/video-codec:[]:1
      Client:
        Id: -5476376630540719424
        Name: c2.qti.avc.decoder
        Resources:
          non-secure-codec/video-codec:[]:1
          battery/video-codec:[]:1

VideoLab has acquired multiple decoder instances. When I minimize VideoLab and re-run the command, I still see the decoders being reported as acquired, so my guess is that VideoLab has not released MediaCodec instances. This guess is consistent with my observation above:

Also from the recording, it appears to me that the VideoLab is the one not releasing the MediaCodec instance properly.

To verify which application maps to a PID, you can run adb shell dumpsys and search for the specific PID, e.g. when I ran adb shell dumpsys | grep 29962 I could see it mapped to com.jellybus.videolab.

As I said, it looks like VideoLab is not releasing resources and I don't think it's an ExoPlayer issue. That does not mean that this will break all video apps: devices may create multiple instances of a certain decoder (it's up to the device). Also other video apps may play video in other formats, for example YouTube will likely play video in VP9 and it will acquire a different decoder. You can also try to play the VP9 videos with ExoPlayer, I believe the error will not occur.

At this point, I think the resources are leaked from VideoLab. If the problem occurs only with VideoLab, I recommend contacting them.

christosts avatar Jul 29 '21 10:07 christosts

My issue is not Resolve so please open this issue.

To verify which application maps to a PID, you can run adb shell dumpsys and search for the specific PID, e.g. when I ran adb shell dumpsys | grep 29962 I could see it mapped to com.jellybus.videolab

This is just for information. This is not the solution to my issue.

At this point, I think the resources are leaked from VideoLab. If the problem occurs only with VideoLab, I recommend contacting them.

Video Lab Just one Example. This problem occurs with so many apps.

Capture

When I first open the Exoplayer demo app and open the video, video is played and minimize demo app and that time not released MediaCodec instances because of comment release code in the demo app. then I open the video lab app and play the video. In the video lab, video is played. then minimize video lab open Exoplayer demo app Video does not play in. So in this case the issue comes in the video lab, right?

why this issue in the demo? why not in the video lab? I don't release MediaCodec from the demo app. Where does the video lab get MediaCodec from?

Jaydipnathani avatar Jul 30 '21 04:07 Jaydipnathani

When you say

Video Lab Just one Example. This problem occurs with so many apps.

Can you please name exactly what combinations you tried and which one failed?

I need to point that video apps may acquire different decoders based on the video format played. Therefore, if a combination of apps work that does not mean that the specific apps are releasing the codecs properly. It might be that

  • the apps acquire different decoders and there is not shortage of decoder instances. In your example above, VideoLab was acquiring H264 decoders (c2.qti.avc.decoder). If you try VideoLab in combination with ExoPlayer and you only play VP9 videos on ExoPlayer, I believe that would work. Another example which would work is trying VideoLab with Youtube, because YouTube will likely acquire VP9 decoders too.
  • apps may have additional logic to try a different decoder if they fail to acquire a decoder. For example, if an app fails to acquire an H264 decoder, it might try using another video format that it supports. The ExoPlayer demo app does not have such a logic.

So, please try the following at least:

  • Try ExoPlayer with VideoLab and play only VP9 content with ExoPlayer. If it works, it means that the problem is specifically with H264 decoders (possibly not released by VideoLab)
  • If you have seen this happening with other combinations of apps, please tell us what these combinations are, and the order of apps on each combination: which app starts first and then goes to the background, which app starts second and so on.
  • Please try installing two separate ExoPlayer apps (you need to change the package name to have the same app installed again) and play the same H264 content on both apps. If that works, that would show that ExoPlayer can resume playback provided that another app (2nd ExoPlayer app) has made sure to release the same codec once it goes in the background.

Please use the latest version of ExoPlayer (2.14.2 at the moment) and make sure you have not performed any code modifications, especially around releasing the player.

Note: I'm not aware of other reports of similar issues happening on these specific devices (Samsung J5/J7), so at the moment I believe there is something more specific to your setup (apps, device) and not a generic problem.

christosts avatar Jul 30 '21 11:07 christosts

  • For example, if an app fails to acquire an H264 decoder, it might try using another video format that it supports.

Please explain to me how to use a decoder. You tell me how to know the decoder of video. and how to change the video decoder.

  • Try ExoPlayer with VideoLab and play only VP9 content with ExoPlayer. If it works, it means that the problem is specifically with H264 decoders (possibly not released by VideoLab)

YES, It works but the problem is with the same decoder. so how to use another decoder.

Please use the latest version of ExoPlayer (2.14.2 at the moment)

The same version was used.

Jaydipnathani avatar Jul 31 '21 04:07 Jaydipnathani

Please explain to me how to use a decoder. You tell me how to know the decoder of video. and how to change the video decoder.

I can think of two options

  1. If you control the generation of content, you choose an encoding other than H264, e.g. use HEVC or VP9 video. The majority of devices support this encoding. 2.Try enabling decoder fallback on the ExoPlayer by calling DefaultRenderersFactory. setEnableDecoderFallback(true). For example, in the demo app's DemoUtil.java you can do
return new DefaultRenderersFactory(context.getApplicationContext())
        .setExtensionRendererMode(extensionRendererMode).setEnableDecoderFallback(true);
  1. Otherwise, following this answer, you can pass a custom MediaCodecSelector to the player which will have your custom logic to select an H264 decoder (if the video format is H264, you have to pick an H264 decoder). On an Android platform, you typically find a hardware and software decoder for H264. By default, ExoPlayer uses MediaCodecSelector.DEFAULT which prefers the hardware decoder. You may create a custom MediaCodecSelector that returns a list of decoders, with the software decoder for H264 on the top of the list instead of the hardware decoder. An easy way to achieve that is to wrap MediaCodecSelector.DEFAULT and re-order its returned results. For example, in the demo app, you can do something like this
return new DefaultRenderersFactory(context.getApplicationContext())
        .setExtensionRendererMode(extensionRendererMode).setMediaCodecSelector(
            new MediaCodecSelector() {
              @Override
              public List<MediaCodecInfo> getDecoderInfos(String mimeType,
                  boolean requiresSecureDecoder, boolean requiresTunnelingDecoder)
                  throws MediaCodecUtil.DecoderQueryException {
                List<MediaCodecInfo> decoderInfos = MediaCodecSelector.DEFAULT
                    .getDecoderInfos(mimeType, requiresSecureDecoder, requiresTunnelingDecoder);
                if (MimeTypes.VIDEO_H264.equals(mimeType)) {
                  // copy the list because MediaCodecSelector.DEFAULT returns an unmodifiable list
                  decoderInfos = new ArrayList<>(decoderInfos);
                  Collections.reverse(decoderInfos);
                }
                return decoderInfos;
              }
            });
  }

Please note the following for option 3:

  • I would not advice to always pick the software decoder (on the basis that it might fail) because using the software decoder is not as performant as the hardware (battery usage, frame drops etc)
  • the error you see on the specific devices does not happen on any device I have tested. What I believe is happening on your devices is that H264 decoders are acquired and not released when you put the particular video editing apps in the background. However, it's up to the device capabilities on how many different instances of a certain decoder to create and share between processes.
  • The errors you see on your devices, may not happen on other devices
  • Therefore, you should first attempt to play videos with the hardware decoder and only if it fails, you should fallback to the software decoder.

Overall, I believe the issue you are seeing so far is not with ExoPlayer but with the video editing apps that seem to not release their resources when put them in the background. I have not managed to reproduce using Pixel devices and a Samsung S9. My guess is that the specific devices you are testing (Samsung J5/J7) may not have the ability to share resources. That said, I am not sure how else we have help you with the issue you are facing.

christosts avatar Aug 02 '21 12:08 christosts

Hi, @christosts Thank you very much for the response. This is exactly what I was looking for. I will try to use a software decoder when the hardware decoder fails. Thanks

Therefore, you should first attempt to play videos with the hardware decoder, and only if it fails, you should fall back to the software decoder.

How to know the hardware decoder fails?

After using this my issue was resolve. DefaultRenderersFactory always returns software decoder?

DefaultRenderersFactory rf = new DefaultRenderersFactory(context.getApplicationContext())
                .setExtensionRendererMode(EXTENSION_RENDERER_MODE_PREFER).setMediaCodecSelector(
                        new MediaCodecSelector() {
                            @Override
                            public List<MediaCodecInfo> getDecoderInfos(String mimeType,
                                                                        boolean requiresSecureDecoder, boolean requiresTunnelingDecoder)
                                    throws MediaCodecUtil.DecoderQueryException {
                                List<MediaCodecInfo> decoderInfos = MediaCodecSelector.DEFAULT
                                        .getDecoderInfos(mimeType, requiresSecureDecoder, requiresTunnelingDecoder);
                                if (MimeTypes.VIDEO_H264.equals(mimeType)) {
                                    // copy the list because MediaCodecSelector.DEFAULT returns an unmodifiable list
                                    decoderInfos = new ArrayList<>(decoderInfos);
                                    Collections.reverse(decoderInfos);
                                }
                                return decoderInfos;
                            }
                        });

  simpleExoPlayer = new SimpleExoPlayer.Builder(context, rf).build();

Please Explain this condition.

if (MimeTypes.VIDEO_H264.equals(mimeType)) {

I am not getting that which setExtensionRendererMode have to use when?

Jaydipnathani avatar Aug 04 '21 06:08 Jaydipnathani

How to know the hardware decoder fails?

The player will raise an error on the AnalyticsListener.onPlayerError callback and the passed ExoPlaybackException will contain a MediaCodecRenderer.DecoderInitializationException. You can see that in the first stack trace you posted on the issue description. In your app, you should add an AnalyticsListener to the player and if onPlayerError is raised, you can inspect if it was the decoder that failed as follows:

@Override
  public void onPlayerError(EventTime eventTime, ExoPlaybackException e) {
    if (e.getRendererException() instanceof MediaCodecRenderer.DecoderInitializationException) {
      MediaCodecRenderer.DecoderInitializationException decoderInitializationException = (MediaCodecRenderer.DecoderInitializationException) e.getRendererException();
      MediaCodecInfo codecInfo = decoderInitializationException.codecInfo;
      Log.d("EXO_V2", "Decoder failed to initialize: " + codecInfo.name);
      Log.d("EXO_V2", "Hardware? " + codecInfo.hardwareAccelerated);
      Log.d("EXO_V2", "Mime type? " + codecInfo.mimeType);
      Log.d("EXO_V2", "Is H264? " + MimeTypes.VIDEO_H264.equals(codecInfo.mimeType));
    }
  }

I've added some extra statements to show you some of the information you can obtain the exception's MediaCodecInfo, such as the MIME type (from which you can tell if it's an H264 decoder), the specific decoder name and if it's a hardware one.

Unfortunately, if you wait until the player fails and then try out with a different decoder, your app will need extra time until it starts playing the video. Please try if DefaultRenderersFactory. setEnableDecoderFallback(true) solves your problem before you try this solution.

DefaultRenderersFactory always returns software decoder?

By default, the DefaultRenderersFactory will prefer a hardware decoder if one exists. This comes down to the device capabilities, and the player will query the device to find out what decoders are available for the specific video. If for a certain video format there is a hardware and a software decoder, the player's default behavior is to prefer to hardware. But if the device only has one decoder for a certain video format, the player will pick that decoder nevertheless.

Please Explain this condition.

if (MimeTypes.VIDEO_H264.equals(mimeType)) {

This checks is the video format is H264. Media formats are defined by a MIME type. You can check the player's MimeTypes class. For the snippet of code I shared above, this condition changes the default codec selection only for H264 (you'd want the default behavior for other codecs). Feel free to change the condition if you find more issues with decoders not being available.

I am not getting that which setExtensionRendererMode have to use when?

This is a setting used by the demo app, and works if you want to use the DefaultRenderersFactory with ExoPlayer extensions (feel free to ignore if you don't use extensions).

Please let me know if I can assist further, otherwise I will close tis issue now.

christosts avatar Aug 04 '21 11:08 christosts

DefaultRenderersFactory. setEnableDecoderFallback(true)

Thank you so much :+1: . After using this my issue was resolve.

One last question. How to know software/hardware decoder use?

Jaydipnathani avatar Aug 05 '21 08:08 Jaydipnathani

How to know software/hardware decoder use?

You can get the name of decoder used by listening to the AnalyticsListener.onVideoDecoderInitialized event. How to tell whether that's a software or hardware decoder?

  1. For devices with API 29+ (Android 10+), ExoPlayer uses the platform API MediaCodecInfo.isHardwareAccelerated. However, MediaCodecInfo instances are not directly propagated to the app, so if you want to have access to this information, you can wrap MediaCodecSelector.DEFAULT (similar as above) only to iterate the on returned MediaCodecInfo and keep track of which decoder is hardware or not, maybe in a map with decoder names as key. When the onVideoDecoderInitialized, you can go to the map and seek for information.

  2. For older APIs, ExoPlayer tries to derive if the decoder is software by the decoder's name. Please see the code in MediaCodecUtil.isSoftwareOnly link to code. You may replicate a similar log in your app.

christosts avatar Aug 06 '21 09:08 christosts

DefaultRenderersFactory. setEnableDecoderFallback(true)

After using this my issue was resolve when I test in debug mode. But when I did App release, the issue started coming back to my user so the issue not resolve.

A version of ExoPlayer being used 2.14.1

I have an issue with ... Device Name:-

Samsung

  • Galaxy J1(2016) - Android : 5.1.1
  • Galaxy A20 - Android : 11
  • Galaxy A20e - Android : 11
  • Galaxy J6+ - Android : 10
  • Galaxy A10 - Android : 10
  • Galaxy C7 - Android : 8.0.0
  • Galaxy A2 - Core Android : 8.1.0
  • Galaxy J7 - Android : 5.1.1
Non-fatal Exception: java.lang.Exception: Title : Videoview Blackscreen issue : Activity
Function : prepareVideo()
Callback : videoview setOnErrorListener()
Error : MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.4D4029, -1, null, [1920, 1080, 29.970028], [-1, -1]), format_supported=YES
Error_code : 1
App_name : 
Message : Video path : file:///data/user/0/packagename/files/app_templates/32717/602d038a0e280_zip_file_1613562762/602d038a0e280_zip_file_1613562762/title_video_mkf16.mp4
 Is Video path exist? : true
 Error rendererName : MediaCodecVideoRenderer
 Error rendererFormat : Format(1, null, null, video/avc, avc1.4D4029, -1, null, [1920, 1080, 29.970028], [-1, -1])
 Error rendererFormatSupport4
 Error LocalizedMessage : Decoder failed: c2.android.avc.decoder
 Error Message : Decoder failed: c2.android.avc.decoder

Video :- title_video_mkf16.mp4 HUAWEI

  • HUAWEI Y5 2019 - android : 9
  • Huawei MediaPad T5 - android : 8.0.0
  • HUAWEI P smart 2019 - android : 10
  • Mate 20 Pro - android : 10
  • Mate 20 - android : 10
  • P20 - android : 10
  • 荣耀畅玩7X - android : 9
  • HUAWEI P20 Lite - android : 9
Non-fatal Exception: java.lang.Exception: Title : Videoview Blackscreen issue : Activity
Function : prepareVideo()
Callback : videoview setOnErrorListener()
Error : MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640028, -1, null, [1920, 1080, 30.0], [-1, -1]), format_supported=YES
Error_code : 1
App_name : 
Message : Video path : file:///data/user/0/packagename/files/app_templates/36028/bd468f5a62b44_zip_file_1625309727657/bd468f5a62b44_zip_file_1625309727657/outro_video_pgg3.mp4
 Is Video path exist? : true
 Error rendererName : MediaCodecVideoRenderer
 Error rendererFormat : Format(1, null, null, video/avc, avc1.640028, -1, null, [1920, 1080, 30.0], [-1, -1])
 Error rendererFormatSupport4
 Error LocalizedMessage : Decoder init failed: OMX.hisi.video.decoder.avc, Format(1, null, null, video/avc, avc1.640028, -1, null, [1920, 1080, 30.0], [-1, -1])
 Error Message : Decoder init failed: OMX.hisi.video.decoder.avc, Format(1, null, null, video/avc, avc1.640028, -1, null, [1920, 1080, 30.0], [-1, -1])

Video :- outro_video_pgg3.mp4

VIVO

  • V2029 Android : 10
Non-fatal Exception: java.lang.Exception: Title : Videoview Blackscreen issue : Activity
Function : prepareVideo()
Callback : videoview setOnErrorListener()
Error : MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 30.0], [-1, -1]), format_supported=YES
Error_code : 1
App_name :
Message : Video path : file:///storage/emulated/0/Android/data/packagename/files/Movies/1Intro/bg_video_trim/fcb9c851f0564_trim_video_file_1629262336212.mp4
Is Video path exist? : true
Error rendererName : MediaCodecVideoRenderer
Error rendererFormat : Format(1, null, null, video/avc, avc1.42C028, -1, null, [1920, 1080, 30.0], [-1, -1])
Error rendererFormatSupport4
Error LocalizedMessage : Decoder failed: c2.android.avc.decoder
Error Message : Decoder failed: c2.android.avc.decoder 

Layout:

<com.google.android.exoplayer2.ui.PlayerView
                    android:id="@+id/videoView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:gravity="center"
                    app:use_controller="false" />

Java Code.

     private PlayerView playerView ;
     private SimpleExoPlayer simpleExoPlayer;
    private View surfaceView;

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      videoPlayerView = findViewById(R.id.videoView);
      initializePlayer();
}

 @Override
    protected void onPause() {
        super.onPause();

      onDestroyPlayerView();  
    }

  @Override
    protected void onResume() {
        super.onResume();

        Log.e(TAG, "onResume: ");
         initializePlayer();
       }



 public void initializePlayer() {

        Log.i(TAG, "initializePlayer: ");
        Log.e(TAG, "Exoplayer INIT: ");

        DefaultRenderersFactory rf = new DefaultRenderersFactory(context.getApplicationContext()).setEnableDecoderFallback(true);
        simpleExoPlayer = new SimpleExoPlayer.Builder(context, rf).build();

        if (playerView != null) {
            playerView.setPlayer(simpleExoPlayer);
            playerView.setUseController(setController);
            playerView.setResizeMode(RESIZE_MODE);
            surfaceView = playerView.getVideoSurfaceView();
            if (surfaceView != null) {
                Log.i(TAG, "initializePlayer: SURFACE Found!!");
            } else {
                Log.i(TAG, "initializePlayer: SURFACE = NULL ");
            }
           setSurfaceViewToExoPlayer();
        }
    }

public void setSurfaceViewToExoPlayer() {

        Log.i(TAG, "setSurfaceViewToExoPlayer: ");
        if (surfaceView != null) {
            if (simpleExoPlayer != null) {
                if (surfaceView instanceof SurfaceView) {
                    simpleExoPlayer.setVideoSurfaceView((SurfaceView) surfaceView);
                }
            }
        }
    }

    public void prepareVideo() {
     
        if (simpleExoPlayer != null && videoPath != null && videoPath.length() > 0) {

            MediaItem mediaItem = new MediaItem.Builder()
                    .setUri(Uri.fromFile(FileUtils.getValidFile(videoPath.replace(" ", "%20"))))
                    .setMimeType(MimeTypes.VIDEO_MP4)
                    .build();

            if (simpleExoPlayer.getMediaItemCount() > 0) {
                simpleExoPlayer.clearMediaItems();
            }

            simpleExoPlayer.setMediaItem(mediaItem);
            simpleExoPlayer.setRepeatMode(repeatMode);
            simpleExoPlayer.setPlayWhenReady(isPlayWhenReady);
            simpleExoPlayer.setVolume(1f);
            simpleExoPlayer.seekTo(0, 0);
            simpleExoPlayer.addListener(this);
            simpleExoPlayer.prepare();
        }
    }

public void onDestroyPlayerView() {

            simpleExoPlayer.pause();
            if (simpleExoPlayer.getMediaItemCount() > 0) {
                simpleExoPlayer.clearMediaItems();
            }
            Log.e(TAG, "Exoplayer RELEASE: ");

            simpleExoPlayer.stop(true);
            simpleExoPlayer.clearVideoSurface();
            simpleExoPlayer.removeListener(this);
            simpleExoPlayer.release();
            simpleExoPlayer = null;
     
    }

Please help me with how to fix this issue. @christosts @ojw28 @marcbaechinger @andrewlewis

Thanks

Jaydipnathani avatar Aug 19 '21 07:08 Jaydipnathani

app:surface_type="texture_view" I removed this line and it got fixed Also i was using two instances of Exoplayer and i am releasing one first before initializing another one THis issue was happening with DASH videos during DRM implementation

wahdatjan avatar Nov 26 '21 14:11 wahdatjan

app:surface_type="texture_view" I removed this line and it got fixed

I do not use this line. @wahdatjan

My XML code

<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/videoView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:gravity="center" app:use_controller="false" />

Jaydipnathani avatar Nov 29 '21 03:11 Jaydipnathani

@Jaydipnathani If you are using two instances of exoplayer then make sure release one properly

wahdatjan avatar Nov 29 '21 04:11 wahdatjan

@Jaydipnathani If you are using two instances of exoplayer then make sure release one properly

#9396 please review this issue, sir. @wahdatjan

Jaydipnathani avatar Nov 29 '21 06:11 Jaydipnathani

Is there someone checking this issue?

vmmontes avatar Apr 21 '22 09:04 vmmontes

Is there someone checking this issue?

Yes, we will work on this issue.

Jaydipnathani avatar Apr 26 '22 12:04 Jaydipnathani

Getting below error:

com.google.android. exoplayer2. ExoPlaybackException: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec,

In my case, I have a list of videos using recyclerview like Instagram. When the feed of the video list gets scrolled very frequently it throws the above error and stops playing other items also.

Anyone could help me here,

Thanks

ishaileshmishra avatar Aug 02 '22 07:08 ishaileshmishra

Getting below error:

com.google.android. exoplayer2. ExoPlaybackException: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec,

In my case, I have a list of videos using recyclerview like Instagram. When the feed of the video list gets scrolled very frequently it throws the above error and stops playing other items also.

Anyone could help me here,

Thanks

Try rendering fewer videos at a time

julian-gargicevich avatar Aug 02 '22 10:08 julian-gargicevich

Hello I'm facing the same isse on Samsung A01 Core, and WiWo Extreme

Stacktrace:

com.google.android.exoplayer2.video.MediaCodecVideoDecoderException Decoder failed: c2.android.avc.decoder com.google.android.exoplayer2.video.MediaCodecVideoRenderer.createDecoderException (MediaCodecVideoRenderer.java:1410) com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render (MediaCodecRenderer.java:844) com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork (ExoPlayerImplInternal.java:978) com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage (ExoPlayerImplInternal.java:482) android.os.Handler.dispatchMessage (Handler.java:103) android.os.Looper.loop (Looper.java:214) android.os.HandlerThread.run (HandlerThread.java:67)

Caused by java.lang.IllegalStateException android.media.MediaCodec.native_dequeueOutputBuffer (MediaCodec.java) android.media.MediaCodec.dequeueOutputBuffer (MediaCodec.java:2789) com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex (SynchronousMediaCodecAdapter.java:105) com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer (MediaCodecRenderer.java:1824) com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render (MediaCodecRenderer.java:823) com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork (ExoPlayerImplInternal.java:978) com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage (ExoPlayerImplInternal.java:482) android.os.Handler.dispatchMessage (Handler.java:103) android.os.Looper.loop (Looper.java:214) android.os.HandlerThread.run (HandlerThread.java:67)

hussein-yassine avatar Aug 16 '22 07:08 hussein-yassine

We are getting Error 0xffffec77 too. Samsung Galaxy J4 with Android 9.

error.txt

chladto1 avatar Nov 24 '22 15:11 chladto1

@christosts, you can easily reproduce this issue on any device. At least i get this exception on all my devices. Tested on Android 9+.

  1. Enable FFMPEG & VP9 extensions.
  2. Turn on this video: https://woolyss.com/f/spring-vp9-vorbis.webm
  3. Turn on any HLS video stream. Don't exit current screen (fragment, activity). You have to open video directly after VP9 video without leaving screen. It's IMPORTANT.

Releasing player before opening second video won't help.

menscikov avatar Dec 01 '22 11:12 menscikov

Getting below error: com.google.android. exoplayer2. ExoPlaybackException: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.Exynos.avc.dec, In my case, I have a list of videos using recyclerview like Instagram. When the feed of the video list gets scrolled very frequently it throws the above error and stops playing other items also. Anyone could help me here, Thanks

I am having pretty similar issue on Pixel 6, Exoplayer version 2.0.16. Any advises about how to handle it? It is weird since the player works fine in the first items and then, after about 7 items, the player throws this error for the same video, exactly same file.

Stacktrace:

...exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: c2.exynos.h264.decoder, Format(1, null, null, video/avc, avc1.4D401F, -1, null, [854, 480, 24.0], [-1, -1])
                                                                                                          at tv.teads.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:989)
                                                                                                          at tv.teads.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:540)
                                                                                                          at tv.teads.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1395)
                                                                                                          at tv.teads.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:759)
                                                                                                          at tv.teads.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:936)
                                                                                                          at tv.teads.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:765)
                                                                                                          at tv.teads.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:980)
                                                                                                          at tv.teads.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:484)
                                                                                                          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: start failed

github-lucas-bon avatar Mar 07 '23 10:03 github-lucas-bon

The fundamental problem is that devices cannot play multiple videos at once. Some Android devices can only provide only one decoder instance at a time to an app, some can offer multiple but with a limit. This varies per device and there is no consistent behavior (as of Android 12 there is some improvement - see next paragraph). ExoPlayer takes a conservative approach, and only occupies one codec instance at a time, e.g. when moving between items in a playlist ExoPlayer makes sure to first release a codec before acquiring the next one.

Many reports here are mentioning apps that play multiple videos concurrently. The general suggestion is to ensure you have only one player instance at a time playing video, if not having one instance in total in your app (see similar discussion in #8189). On Android 12, the platform introduced the performance class by which an app can figure out if the device can provide multiple decoders concurrently, hence the app can do multiple playbacks. You can use the API to figure out if you can have multiple ExoPlayer instances.

In cases where we've seen this issue, the problem tends to be app-specific or device-specific and no single fix can be applied to ExoPlayer. We try to offer assistance to apps to work around the limitations. This issue has now collected multiple reports and it is difficult to have a focused discussion, which can be misleading for those reading the comments thread. As such:

  • I'll close the issue as I don't see an concrete action item for ExoPlayer here (I believe commenting is still possible)
  • If you are facing the issue on your app and you are confident your app does not have multiple player instances occupying codecs concurrently, please open a new issue providing all the information asked on the bug template and we may be able to assist you specifically for your app. Note that we will need a way to reproduce the problem. Opening multiple issues for the same error is a bit against the general guideline, please mention this comment as to why you opened a new issue and did not re-use this one.

Thanks.

christosts avatar Mar 08 '23 13:03 christosts