webkitGenerateKeyRequest polyfill exception ( at least from WebOS 3.0 )
See original GitHub issueHave you read the FAQ and checked for duplicate open issues?
Yes, no similar issues found
What version of Shaka Player are you using?
3.0.5
Can you reproduce the issue with our latest release version?
Yes, branch v3.0.x also contanis the issue
Can you reproduce the issue with the latest code from master
?
Yes
Are you using the demo app or your own custom app?
Own custom app, but demo app will throw same exception ( I’ll add an example )
If custom app, can you reproduce the issue using our demo app?
Yes, exception is thrown
What browser and OS are you using?
WebOS 3.0 ( 2016 )
For embedded devices (smart TVs, etc.), what model and firmware version are you using?
WebOS 3.0 ( 2016 ) firmware: 05.50.95 model: 43UH650V-ZB
What are the manifest and license server URIs?
Any DASH content + playready can be used ( See example I’ll add )
What did you do?
Try to play any DASH playready DRM protected content
What did you expect to happen?
The content should play
What actually happened?
An exception is thrown from https://github.com/google/shaka-player/blob/acc4c0e2574874d2aaa9f2e7d177024d729d330b/lib/media/drm_engine.js#L1090-L1094
ISSUE
Trying Shaka Player
migration from 2.5.X
to 3.0.X
we faced this issue when
lib/polyfill/patchedmediakeys_webkit.js
is applied. A basic example:
// Code in javascript
// Example from https://shaka-player-demo.appspot.com/demo/
var url = 'https://amssamples.streaming.mediaservices.windows.net/622b189f-ec39-43f2-93a2-201ac4e31ce1/BigBuckBunny.ism/manifest(format=mpd-time-csf)';
var license = 'https://amssamples.keydelivery.mediaservices.windows.net/PlayReady/';
// Intsall polyfills
shaka.polyfill.installAll();
// Create video element
var video = document.querySelector('video');
if (!video) {
video = document.createElement('video');
video.style.position = 'absolute';
video.style.left = '0px';
video.style.top = '0px';
video.style.width = '100%';
video.style.height = '100%';
video.preload = 'auto';
video.autoplay = true;
document.body.appendChild(video);
}
// Override webkitGenerateKeyRequest in order to show more logs
if (!HTMLMediaElement.prototype._webkitGenerateKeyRequest) {
HTMLMediaElement.prototype._webkitGenerateKeyRequest = HTMLMediaElement.prototype.webkitGenerateKeyRequest;
HTMLMediaElement.prototype.webkitGenerateKeyRequest = function() {
var args = [].slice.call(arguments);
try {
console.log('webkitGenerateKeyRequest call');
this._webkitGenerateKeyRequest.apply(this, args);
} catch(error) {
console.log('webkitGenerateKeyRequest exception', error);
throw error;
}
}
}
// Also show shaka logs
shaka.log.setLevel(shaka.log.Level.DEBUG);
// Create the player and play
var player = new shaka.Player(video);
player.configure({ drm: { servers: { 'com.microsoft.playready': license } } });
player.attach(video);
player.load(url, 0)
.catch(function(e) { console.log('Exception!', JSON.stringify(e)); });
And from this load an exception is thrown:
Trace
Here is a “traced” explanation:
When load is called onInitializeDrm_ ( from shaka.Player ) is called from drm-engine
. And you replaced inside this method the call from:
shaka 2.5
=> this.filterAllPeriods_(this.manifest_.periods);
vs
shaka 3.0
=> this.filterManifest_(this.manifest_);
filterManifest_ method is calling
this.drmEngine_.newInitData(initData.initDataType, initData.initData);
And newInitData from drmEngine method is calling:
this.createTemporarySession_(initDataType, initData);
and this createTemporarySession_ method calls:
- At first (this.mediaKeys_.createSession(…);](https://github.com/google/shaka-player/blob/98df64c1af61490bdc926cfbf89a0d621e3a77cf/lib/media/drm_engine.js#L1018-L1024)
which is creating this.media_ with an empty <video src=‘about:blank’ /> see createSession
- And after that session.generateRequest(initDataType, initData)
which is calling finally to the video object method webkitGenerateKeyRequest
(from the generateRequest polyfill call
and this webkitGenerateKeyRequest
method is throwing a DOMException
because correct video object is not being used
DOMException
{
message: 'Failed to execute \'webkitGenerateKeyRequest\' on \'HTMLMediaElement\': No media has been loaded',
name: 'InvalidStateError',
code: 11,
...
}
And this exception is thrown as CRITICAL
( as it should )
We think the problem is because “attach” was not called, but since attach is called from load maybe there should be
applied a workaround in order to ensure this.media_ is correctly initialized when creating the session since the player
has been initialized from new shaka.Player(video)
or player.attach(video)
before calling player.load
Thank you very much
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Unfortunately, we aren’t able to debug this directly without a WebOS device. We’ll leave it open until someone can help diagnose and work around the issue.
Thx @avelad ( you were faster than me 😅 doing the PR ) we tested https://github.com/google/shaka-player/pull/3109 and issue get’s fixed from
WebOS 3.0
, also I tested fromWebOS 4.5
+WebOS 5.0
+Tizen 2020
and player is working fine.Thank you very much