HLS+Fairplay stream resources freeing issue

The Context

I'm using the HTML video element to play HLS+Fairplay streams (VOD and live) in Safari. My application is a Netflix-like. You can watch a video, stop, and watch another one. Concretly, the <video> tag is created upon each play and destroyed when the player exits.

The Problem

Sometimes, after exiting the player, launching a new video causes a MEDIA_ERR_DECODE error without anymore explanation. I can trace in my code that the Fairplay certificate and the CKC have been correctly retrieved and that the media session has been created and updated (with the CKC). In fact, when I log everything, I see the exact same logs as when it works. Except the final MEDIA_ERR_DECODE error.

When I get this error, if I immediately retry to play, the same error happens, but if I wait about 5~10 seconds, it successfully plays. It's like some resource is waiting to be garbage-collected.

What I tried

I tried playing non-DRMed videos and it works perfectly: I could play, stop, play, etc. without any issue.

So my guess is something is happening at the EME level. I've browsed the whole Internet (twice) and couldn't come up with a clear explanation. Most of the hints I found couldn't explain my issue (e.g. bad DRM-encryption, but how could it work the first time?) or solve it (e.g. videoElement.src = "").

I'm throwing a bottle into the sea, here... Thanks for your help!

Replies

Seeing similar issues when using Shaka to play HLS video with FairPlay DRM, but not when letting Safari handle playback natively.

The issue is on the hls playlist, check this post https://github.com/shaka-project/shaka-player/issues/2379#issuecomment-582854434