session.close stuck on DRM content
See original GitHub issueHave you read the FAQ and checked for duplicate open issues?
Yes, this is related to https://github.com/google/shaka-player/issues/1093 but this has been locked as too old.
What version of Shaka Player are you using?
Tried with both 2.5.12 and 3.0.1
Can you reproduce the issue with our latest release version?
Yes
Can you reproduce the issue with the latest code from master
?
Not tested
Are you using the demo app or your own custom app?
Custom App
If custom app, can you reproduce the issue using our demo app?
Not tested
What browser and OS are you using?
Chrome 84.0.4147.89, MacOS 10.15.6
For embedded devices (smart TVs, etc.), what model and firmware version are you using?
What are the manifest and license server URIs?
Shouldn’t be needed a specific manifest, but it must be a DASH with DRM.
What did you do?
- (see discussion below)
What did you expect to happen?
- (see discussion below)
What actually happened?
So, here’s what we were trying to do.
To get the correct license for a DRM content, we need three parameters. We obtain two of them through the HTTP Request that returns us also the main manifest URL. The third one is the token
for authenticating on the service that serves us everything about the media (parameters data included).
Theoretically, we might incur into an expired token. For this reason we want to throw error and unload the content.
Here’s our code:
return this.player.load(src, startTime, mimeType)
.then(() => {
console.log('READY - The video has now been loaded!');
this.changePlaybackState('READY');
})
.catch(this.handleShakaError_);
handleShakaError_(err: shaka.util.Error) {
// ... other code
console.log('onShakaError');
console.error(err);
this.unload_()
.then(() => {
console.log('THEN, WHAT?');
this.props.delegate?.onError(new ShakaError(err));
})
.catch((err) => console.log('error in unloading', err));
}
unload_() {
// more code ...
return this.player.unload(false)
.then(() => {
console.log('Unload shaka: finished');
this.changePlaybackState('IDLE');
})
.catch((err) => {
console.error('Error in unload', err);
return err;
});
}
We are receiving in handleShakaError_
this error if we pass in the license URL an expired or invalid token: Shaka Error DRM.LICENSE_REQUEST_FAILED
. So we expect then that both Unload shaka: finished
or Error in unload
AND THEN, WHAT?
to be printed in the console, but it never happen.
Instead we see only, in debug mode, Shaka’s logs:
Starting unload...
Closing session 027B2E46533F4895A5055741BFF24CAE
So we started digging down to the root of the problem and we found this:
What happens is that the flow into Shaka halts when this.drmEngine_.destroy();
is executed. In particular, it gets halted on await this.closeOpenSessions_();
.
We found that this issue seems linked to issue #1093. It was “solved” by saying that it was a problem with Chrome on MacOS, which wasn’t solving the session.close()
for any reason when working with DRM content.
A workaround has been introduced in - I don’t know which version it was available on Dec 2017 - this commit: https://github.com/google/shaka-player/commit/734797b8c0a2c68876683c8f544dc1625bd49584: a Promise.race
with a timeout.
Over time, this workaround has been moved to shaka.media.DrmEngine.closeSession_
, but at a certain point, on 1 November 2019, this method has been removed and the fix with it - check here: https://github.com/google/shaka-player/commit/6e252e7b81c49850653a87ba3482bb4cf68961d4#diff-052c6be0b439274b171a21b6729378b1L248
According to the commit message, the Chrome issue seems to be solved, but actually I don’t think it so. Also the topic of Chromebug (https://crbug.com/690583) that was linked in the original issue on GH, is not available anymore (I get “Permission Denied”).
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
I currently have the previous workaround (and a regression test) in code review. In the meantime, I don’t know how much you can do. Destroying the media element mid-unload is bound to cause weird effects. If I had to guess, I’d say that it’s unblocking the close session process… and then get to the next step of unloading, where we try to unset the media keys on the (now-destroyed) video element.
https://bugs.chromium.org/p/chromium/issues/detail?id=1108158 is still open and I’m still hoping to get the Chrome CDM team to do something about it.