ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Unable to restore playback after seek on Samsung Galaxy S5 Mini

Open pakerfeldt opened this issue 11 years ago • 18 comments

In short, with DRM content (Widevine) what happens on seek is that ExoPlayer goes into BUFFERING state but never returns to state READY.

The following information was gathered by one of our developers:

  1. When user seeks to some position in video, it results in calling ExoPlayerImplInternal.seekToInternal(). At the end of this method ExoPlayer state is set to ExoPlayer.STATE_BUFFERING.
  2. Then ExoPlayerImplInternal.doSomeWork() is called repeatedly. Eventually when buffering is ready, ExoPlayer should transit from ExoPlayer.STATE_BUFFERING to ExoPlayer.STATE_READY. But it doesn't happen.
  3. It happens when all renderers attached to ExoPlayer are done with their work by doing renderer.doSomeWork(). After some time it turns out than MediaCodecAudioTrackRenderer succeeds and returns true in ExoPlayerImplInternal.rendererReadyOrEnded(mediaCodecAudioTrackRenderer). But MediaCodecVideoTrackRenderer can't finish its work and always returns false in ExoPlayerImplInternal.rendererReadyOrEnded(mediaCodecVideoTrackRenderer).
  4. For MediaCodecVideoTrackRenderer method ExoPlayerImplInternal.rendererReadyOrEnded(mediaCodecVideoTrackRenderer) always returns false, because MediaCodecVideoTrackRenderer.isReady() returns false.
  5. MediaCodecVideoTrackRenderer.isReady() calls its super's MediaCodecTrackRenderer.isReady() and gets false.
  6. MediaCodecTrackRenderer.isReady() always returns false, because its field outputIndex = -1.
  7. In MediaCodecTrackRenderer outputIndex field is set in drainOutputBuffer() method as result of the call to MediaCodec.dequeueOutputBuffer(), which returns INFO_TRY_AGAIN_LATER = -1.
  8. MediaCodec.dequeueInputBuffer() calls native method native_dequeueInputBuffer() which returns -1. We don't get access to these sources.

So I guess it all boils down to the INFO_TRY_AGAIN_LATER we get from the, indicating that the call times out. Is there anything that can be done to further investigate? Btw, we can reproduce this with the ExoPlayer demo app.

pakerfeldt avatar Jul 07 '15 11:07 pakerfeldt

I got hold of an S5 Mini and can reproduce. A few additional notes:

  • dequeueInputBuffer does dequeue some buffers after the seek (5 of them), but no buffers are dequeued from dequeueOutputBuffer.
  • Behaviour is as you describe for samples that do not require HDCP. For samples that do require HDCP it appears that the failure is harder. The following exception is thrown:
E/wv_dash ( 1924): Trustlet did not send a valid return code: 0xd
E/wv_dash ( 1924): tee_send_msg_general_cmd is failed.
E/wv_dash ( 1924): process drm decrypt CTR failed
E/WVCdm   ( 1924): Decrypt error result in session sid3 during encrypted block: 1
E/ExoPlayerImplInternal( 8447): Internal track renderer error.
E/ExoPlayerImplInternal( 8447): com.google.android.exoplayer.ExoPlaybackException: android.media.MediaCodec$CryptoException: Error decrypting data.
  • If you don't require HDCP, it's possible to work around the first of these issues by modifying flushCodec in MediaCodecTrackRenderer. There's an if/else block in that method where the else path fully releases and re-instantiates the decoder in order to work around some known issues. If you force the implementation to follow that path then seeking works properly. You'd probably want to target this kind of workaround specifically at this device when using the H.264 decoder.

I'll try and get in touch with Samsung to see if they have any plans to resolve the underlying issue.

ojw28 avatar Jul 15 '15 17:07 ojw28

Thanks for the provided workaround! It helped to resolve the issue on our S5 Mini. Please, let us know if you have any updates from Samsung.

juleZZZ avatar Jul 21 '15 11:07 juleZZZ

returning true in MediaCodecTrackRenderer.codecNeedsFlushWorkaround as suggested enables the workaround mentioned above and fixes the issue on my s5 mini :+1:

What I'm wondering now is how I can activate this workaround without forking the player, since codecNeedsFlushWorkaround() is private and static, which makes it hard to add any additional check that activate the extra flushes.

what would be the preferred way to do solve this? should I create a pull request adding the OMX.Exynos.avc.dec.secure to the codec that need flushing? or make codecNeedsFlushWorkaround() non-static and protected? or wait for samsung to fix the issue?

thanks!

nosyjoe avatar Jan 15 '16 16:01 nosyjoe

We should probably put the fix directly in the library. The open question is what to target it at. It's unclear whether it's device specific or whether it affects all devices with that decoder, on what API levels the issue occurs on etc. If you have anything that might answer those questions. please let us know. If not, we'll have a think about what a best guess approximation might be.

Note that the fix doesn't help in the HDCP required case, as noted above, although it sounds like this wont be an issue for your use case.

ojw28 avatar Jan 15 '16 16:01 ojw28

makes sense. I don't know about any other occurrences with other devices or android versions apart from the the s5 mini on android 4.4.2. I'll update the issue if we find other systems with the issue.

How about adding a specific exception for the s5 mini with with api 19, with the option of broadening it later?

nosyjoe avatar Jan 15 '16 16:01 nosyjoe

According to Wikipedia there are multiple variants of the S5 Mini: SM-G800F, SM-G800H, SM-G800H/DS, SM-G800M, SM-G800Y.

I think the F, M and Y variants have the Exynos chipset. The H variant apparently has a Qualcomm chipset, so I'm guessing that it wouldn't be affected by the issue. I'm not sure about the H/DS variant. There's apparently a R4 variant as well. I'm not sure about that one.

ojw28 avatar Jan 15 '16 17:01 ojw28

I propose amending the condition for codecNeedsFlushWorkaround to be:

return Util.SDK_INT < 18
    || (Util.SDK_INT == 18
        && ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name)))
    || (Util.SDK_INT == 19 && Build.MODEL.startsWith("SM-G800")
        && ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name)));

Which should properly target only the S5 devices that have the Exynos decoder.

ojw28 avatar Jan 15 '16 20:01 ojw28

The amended condition looks good to me. I tested the condition and it fixed the issue on my SM-G800F. that's quite a list of different hardware versions for the s5 mini :(

thanks a lot for your help - will you integrate these changes or should I create a pull request?

nosyjoe avatar Jan 18 '16 10:01 nosyjoe

I'll push a fix. Thanks for testing!

ojw28 avatar Jan 18 '16 11:01 ojw28

@ojw28 This issue is still reproducing on many devices. I am still able to consistently reproduce the "Decrypt error result in session sid3 during encrypted block" error in the Demo app.

Repro steps:

  • Build ExoPlayer Demo app at r1.5.6 tag
  • Launch app and play "WV: Secure SD & HD (MP4,H264)"
  • Seek somewhere in the middle of the video
  • Allow video to play for a few seconds
  • Without pausing, press device Home button
  • Tap Recent Apps button and tap the player activity

Expected outcome: Video continues to play Actual outcome: Video fails to play and Retry button appears in player chrome. Exception is thrown in log.

Works as expected on these devices:

  • Nexus 6 (6.0.1/MMB29Q)
  • Nexus 5X (6.0.1/MMB29Q)
  • Nexus 9 (6.0.1/MMB29S)
  • Sony Xperia Z3 D6603 (5.1.1/23.4.A.1.232)
  • Galaxy Nexus (4.3/JWR66Y)

Fails on these devices:

  • AT&T Moto X 2nd Gen (5.1/LPE23.32-21.9)
  • Samsung Galaxy Note 4 (5.1.1/LMY47X)
  • Samsung Galaxy S6 Active (5.0.2/LRX22G.G890AUCU2AOF3)

Even when codecNeedsFlushWorkaround is changed to always return true so that the workaround referenced earlier is used for all of the above devices, the error occurs.

jschools avatar Feb 22 '16 21:02 jschools

Please file a new issue; it's unclear whether it's the same problem.

ojw28 avatar Feb 23 '16 13:02 ojw28

Hi colleagues, I still have this issue on the Samsung Galaxy S5 device, model SM-G900H: 03-09 20:53:50.403: E/ACodec(1309): [OMX.Exynos.avc.dec.secure] ERROR(0x80001000) 03-09 20:53:50.403: E/ACodec(1309): signalError(omxError 0x80001000, internalError -2147483648) 03-09 20:53:50.403: E/MediaCodec(1309): Codec reported err 0x80001000, actionCode 0, while in state 6 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): Internal runtime error. 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): java.lang.IllegalStateException 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at android.media.MediaCodec.native_dequeueInputBuffer(Native Method) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:983) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.MediaCodecTrackRenderer.feedInputBuffer(:552) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(:493) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.SampleSourceTrackRenderer.doSomeWork(:129) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(:431) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(:213) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at android.os.Handler.dispatchMessage(Handler.java:98) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at android.os.Looper.loop(Looper.java:145) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at android.os.HandlerThread.run(HandlerThread.java:61) 03-09 20:53:50.408: E/ExoPlayerImplInternal(1309): at com.google.android.exoplayer.util.PriorityHandlerThread.run(:40)

ChernyshovYuriy avatar Mar 12 '16 17:03 ChernyshovYuriy

Issue could be easily reproduce by:

  • select bit rate for video less then minimum variant (only Audio must be play)
  • select any valid bit rate

On selected samsung devices appropriate exception should be thrown.

ChernyshovYuriy avatar Mar 16 '16 19:03 ChernyshovYuriy

If I expand boolean codecNeedsFlushWorkaround(String name) method in order to process new Samsung device, it is not going to work because void flushCodec() throws ExoPlaybackException not invoking. Stack trace:

03-16 15:57:40.076 E/ExoPlayerImplInternal: Internal runtime error.
                                            java.lang.IllegalStateException
                                                at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                                                at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
                                                at com.google.android.exoplayer.MediaCodecTrackRenderer.drainOutputBuffer(MediaCodecTrackRenderer.java:867)
                                                at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:493)
                                                at com.google.android.exoplayer.SampleSourceTrackRenderer.doSomeWork(SampleSourceTrackRenderer.java:129)
                                                at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:431)
                                                at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:213)
                                                at android.os.Handler.dispatchMessage(Handler.java:98)
                                                at android.os.Looper.loop(Looper.java:145)
                                                at android.os.HandlerThread.run(HandlerThread.java:61)
                                                at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)

ChernyshovYuriy avatar Mar 16 '16 20:03 ChernyshovYuriy

Important update - issue reproducible on WV: Secure SD&HD (MP4, H264) content only. On Samsung S5 SM-G900.

ChernyshovYuriy avatar Mar 17 '16 17:03 ChernyshovYuriy

Hm ... Even if specifying legal variant index (not -1, like I did before, and thats caused an exception as well), for instance index 1 (not 0, because 0 is adaptive one), MediaCodec still failing when switching variant.

03-17 15:34:35.485 E/ACodec: [OMX.Exynos.avc.dec.secure] ERROR(0x80001000)
03-17 15:34:35.485 E/ACodec: signalError(omxError 0x80001000, internalError -2147483648)
03-17 15:34:35.485 E/MediaCodec: Codec reported err 0x80001000, actionCode 0, while in state 6
03-17 15:34:35.485 E/ExoPlayerImplInternal: Internal runtime error.
                                            java.lang.IllegalStateException
                                                at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                                                at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
                                                at com.google.android.exoplayer.MediaCodecTrackRenderer.drainOutputBuffer(MediaCodecTrackRenderer.java:861)
                                                at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:491)
                                                at com.google.android.exoplayer.SampleSourceTrackRenderer.doSomeWork(SampleSourceTrackRenderer.java:129)
                                                at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:431)
                                                at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:213)
                                                at android.os.Handler.dispatchMessage(Handler.java:98)
                                                at android.os.Looper.loop(Looper.java:145)
                                                at android.os.HandlerThread.run(HandlerThread.java:61)
                                                at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
03-17 15:34:35.485 E/ACodec: [OMX.Exynos.avc.dec.secure] ERROR(0x80001000)
03-17 15:34:35.485 E/ACodec: signalError(omxError 0x80001000, internalError -2147483648)
03-17 15:34:35.485 E/MediaCodec: Codec reported err 0x80001000, actionCode 0, while in state 9

ChernyshovYuriy avatar Mar 17 '16 19:03 ChernyshovYuriy

Hi, There was no response so far. Do I need to file new issue? Does anyone monitor closed ones?

ChernyshovYuriy avatar Mar 21 '16 16:03 ChernyshovYuriy

Please file a new issue containing all of the information requested in the issue template, including a full bug report.

ojw28 avatar Mar 21 '16 23:03 ojw28