Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayReady InvalidStateError on Edge 25 #282

Closed
Doolali opened this issue Feb 8, 2016 · 31 comments
Closed

PlayReady InvalidStateError on Edge 25 #282

Doolali opened this issue Feb 8, 2016 · 31 comments
Assignees
Labels
component: EME The issue involves the Encrypted Media Extensions web API status: archived Archived and locked; will not be updated type: bug Something isn't working correctly

Comments

@Doolali
Copy link

Doolali commented Feb 8, 2016

Hello,

I've been testing PlayReady on Edge and have run into an issue that I'm struggling to find the source of.

On Edge 20 PlayReady playback works without any issues, this morning I updated to 25.10586.0.0 and have started getting a Player Error with a message of "InvalidStateError".

Has anyone else experienced this and/or has a solution?

Thanks,
Scott

Update:
Clear content does not have this issue.
Codec: avc1.64000D

@joeyparrish joeyparrish added the type: question A question from the community label Feb 8, 2016
@joeyparrish joeyparrish self-assigned this Feb 8, 2016
@sarge
Copy link

sarge commented Feb 8, 2016

Yes I spotted this too.

https://shaka-player-demo.appspot.com/
Attempting to playback with content "Oops" (modified YT DASH EME test) - MP4, multi-DRM"

Checking the release notes Edge has removed support for VP9, but I have checked the content which uses avc1.4D4015 which is supported. So I don't think it is a codec issue.

@sarge
Copy link

sarge commented Feb 9, 2016

So I have been digging in a bit more.

I think it is the call to setMediaKeys https://github.com/google/shaka-player/blob/87ac05e/lib/media/eme_manager.js#L452
The promise does not resolve.

Appears to be a native call on Edge, I am unsure if it should be polyfilled or not.

@joeyparrish
Copy link
Member

In uncompiled mode, you should have a log from shaka.polyfill.MediaKeys.install that says either "Using native EME as-is" or "Using EME v20140218".

If it's "native EME as-is", then it's not polyfilled and the lack of Promise resolution may be a bug in Edge. Or it could be an incompatibility between the latest Edge's EME and the rest of the ecosystem, in which case we may be able to change some small part of Shaka to be more flexible.

Lots of _may_s and _could_s, because I haven't had access to Edge 25 myself to investigate. :-) @sarge, can you check the status of the polyfill?

@sarge
Copy link

sarge commented Feb 10, 2016

So I get the message 'Using native EME as-is', also 'Using native Promises'.

@joeyparrish I am about for the next 2 hours if it suits you to take a crack at this.

@joeyparrish
Copy link
Member

Sorry, I'm unable to look into it at the moment. I don't have immediate access to Edge 25.

@sarge
Copy link

sarge commented Feb 10, 2016

Sure ok, any suggested next steps? How can I verify if the promise is not resolving.

The media keys object appears valid, it has the correct type and has the createSession, setServerCertificate methods on it.

@joeyparrish
Copy link
Member

Check app.video_.mediaKeys after the point where the Promise should have resolved. If it's null, then Edge really hasn't done it yet. If it's non-null, the Promise should definitely be resolved and I would lean more strongly toward guessing this is bug in Edge.

If Edge really isn't setting mediaKeys... I'm not sure where to go next. There's no obvious reason it would block on that. Are there any logs that might be relevant? In the JS console or otherwise?

@sarge
Copy link

sarge commented Feb 10, 2016

OK so it the mediaKeys are null

I thought should get another option
https://dev.windows.com/en-us/microsoft-edge/testdrive/demos/eme/
Running content on this page does not work, sintel trailer
Seems like a different error - MEDIA_ERROR_SRC_NOT_SUPPORTED

But looking at the media keys on the video element, they do appear they have been set. I noticed that they are not using a promise on the setMediaKeys function.

Could you check if this page does work for you, I don't have access to an older version. Then at least I can open that as a bug as well as referencing the shakaplayer.

Also I noticed that the dashif.org reference player is working, any issues if I look at that source to contribute to shaka?

@joeyparrish
Copy link
Member

If Edge implements an old version of EME which does not return a Promise from setMediaKeys(), then that might cause issues. We might have to detect this and polyfill it.

Does Edge 20 use native EME? Or are we polyfilling that just like we do for IE11?

@sarge
Copy link

sarge commented Feb 10, 2016

So Edge 20 is using a polyfill EME v20140218

I have force Edge to load that polyfill (on 1.6.2) which does get it further, eme seems to initialize

'All Streams have completed startup!'
'Timestamp correction 0'

Player Error - 'The browser does not support the media content'

app.video_.mediaKeys -> now has a mediakey with the key system set to "com.microsoft.playready"

Perhaps there is something in the polyfill I should remove?

@joeyparrish
Copy link
Member

"The browser does not support the media content" very likely corresponds to the MEDIA_ERROR_SRC_NOT_SUPPORTED you get from Microsoft's own demo. That is triggered by a decoder error event dispatched from the video element, and should not have anything to do with EME. We may not be able to do anything to fix that. Either the content is truly in an unsupported codec or the browser's media pipeline has a bug.

So I'd call "does not support" a successful fix for the EME part. :-)

I'm not sure we should force the polyfill for Edge as a permanent fix. Let's explore the problem a bit more.

Can you modify EmeManager's setupMediaKeys_ to change this:

return this.video_.setMediaKeys(this.mediaKeys_).then(

to something like this:

var setMediaKeysReturn = this.video_.setMediaKeys(this.mediaKeys_);
console.log('setMediaKeys return value', setMediaKeysReturn);
return setMediaKeysReturn.then(

It would be interesting to see whether or not setMediaKeys returns a Promise on Edge 25.

@Doolali
Copy link
Author

Doolali commented Feb 10, 2016

So I've done what Sarge has and I've forced Edge 25 to use the polyfill EME v20140218 and it's working!

Thanks for the help! I'll keep an eye out to see if there is a more permanent fix.

I ran the above and it just seems to return an object that doesn't seem to have anything in it.
setMediaKeys return value [object Object]

Let me know if you need me to try anything else.

@sarge
Copy link

sarge commented Feb 10, 2016

So Doolali is correct the console does that output.

Debugging shows that this is a Promise object, has methods of catch, then. So it would appear Edge does not resolve this promise.

Reordering the MediaKeys.install forcing the IE11 fixes works for me, testing on Chrome 49, Edge 25

if (window.MSMediaKeys) {
  shaka.log.info('Using EME v20140218');
  shaka.polyfill.PatchedMediaKeys.v20140218.install();
} else
...

@sarge
Copy link

sarge commented Feb 10, 2016

Actually one more thing, adding the catch to the promise shows that the promise is resolving but with an error.
This is the source of the InvalidStateError.

Seems to be some difference between the MediaKeys and MSMediaKeys on Edge.

@joeyparrish is this a bug or simply by design at this stage? Have MS committed to removing their vendor prefixes?

@joeyparrish
Copy link
Member

Looks like a rejected setMediaKeys Promise should land us in this error handler in Player:

https://github.com/google/shaka-player/blob/87ac05e/lib/player/player.js#L343

This should result in an 'error' event dispatched on player and the player.load() Promise being rejected.

@sarge can you confirm? If this isn't happening, Shaka has a bug in its error handling. (This is separate from finding the cause of the rejected Promise, but first things first.)

@sarge
Copy link

sarge commented Feb 11, 2016

Your understanding is correct, the error is bubbled up.

The fun was figuring out what the source of the error is, which I am now certain that it is the setMediaKeys call.

@joeyparrish
Copy link
Member

Okay, I see now. I would guess that InvalidStateError means Edge 25 expects some other order of events, but it will take time to investigate. In the mean time, preferring the IE11 EME polyfill seems to be a reasonable work-around.

@joeyparrish joeyparrish added type: bug Something isn't working correctly and removed type: question A question from the community labels Feb 11, 2016
@joeyparrish joeyparrish added this to the v2.0.0 milestone Feb 11, 2016
@joeyparrish joeyparrish removed this from the v2.0.0 milestone Feb 18, 2016
@joeyparrish
Copy link
Member

I have reproduced this issue with automated integration tests for v2, and I now have a handle on the cause. It seems that this happens when setMediaKeys is called before video.src is set.

We shouldn't have an issue with this in v2, as v2's DrmEngine has a two-phase system: initialize() and attach().

To fix it in v1, we will need to split up EmeManager.initialize() so that setupMediaKeys_() occurs after videoSource.attach(). We should be able to publish a fix in v1.6.4.

@joeyparrish
Copy link
Member

@sarge, @Doolali, can you please test the latest sources from the master branch and confirm that this fixes the issue for you?

@sergiofagostinho
Copy link

Hi,

I've recently started using Shaka Player and I'm struggling with the same issue as @Doolali.
@joeyparrish: I've just pulled and built the latest commit from master and I get the same error.

Thanks,

@sarge
Copy link

sarge commented Feb 24, 2016

@joeyparrish Comparing master and the release version 1.6.3, it looks like this fixes the live streaming on Edge, when testing using "GPAC/SegmentList" sample.

But the issue with the on demand profiles remains. I tested with "Oops"

It appears that it is still using the native EME.

The error still appears on the setMediaKeys. It looks like setMediaKeys is called before videoSource.attach() at https://github.com/google/shaka-player/blob/master/lib/player/player.js#L336 if that is still your theory for why this fails.

@joeyparrish
Copy link
Member

@sarge, using native EME on Edge from master is intentional. We are trying to fix the root of the problem rather than using prefixed EME to avoid it. (Also, "GPAC/SegmentList" isn't a live stream.)

I'm investigating now.

@joeyparrish joeyparrish reopened this Feb 25, 2016
@joeyparrish
Copy link
Member

We backported some Edge fixes from v2, but we missed something important. We are working on another fix.

shaka-bot pushed a commit that referenced this issue Feb 25, 2016
This moves MediaKeys attachment to after MSE attachment to avoid
InvalidStateError on Edge.

Issue #282

Change-Id: I84babc870976380f3891b2d1972688a1e18241cb
shaka-bot pushed a commit that referenced this issue Feb 26, 2016
Edge 13 does not seem to return capabilities in MediaKeySystemConfig.
If missing, fall back to a looser way to match streams.

Issue #282

Change-Id: I076aff62838bae3dc0e7e9c644c8c8d044c23f31
@joeyparrish
Copy link
Member

@Doolali, @sarge, @sergiofagostinho, please try with the latest from master. I believe we have fixed it now.

@joeyparrish joeyparrish added this to the v1 maintenance milestone Feb 27, 2016
@Doolali
Copy link
Author

Doolali commented Feb 27, 2016

I've tested 3-4 different pieces of content on a fresh copy of the master on Edge 20 and 25, so happy to say it's resolved.

@Doolali Doolali closed this as completed Feb 27, 2016
@joeyparrish
Copy link
Member

@Doolali, thanks! We'll roll these changes out in v1.6.4.

@sergiofagostinho
Copy link

Hi,

I've just pulled the latest commit from master and I get the following:

  • "Car" (YT DASH test) - MP4: OK
  • "Car/CENC" (YT DASH EME test): "NotSupportedError"
  • "Oops" (modified YT DASH EME test) - MP4, multi-DRM: (after playing for 8 seconds): "Unknown playback error."
  • "Sintel" (1080p high bitrate test): "InvalidStateError"

Which content have you tried @Doolali ?

@joeyparrish
Copy link
Member

@sergiofagostinho, specifically we fixed InvalidStateError with PlayReady assets.

It is a known issue that some of the test assets in v1 are incompatible with IE/Edge (#224). They will be replaced in v2.

If you have known-good PlayReady assets, please try those.

@sergiofagostinho
Copy link

@joeyparrish: ok, got it. I used Big Buck Bunny from Edge's Test Page and it worked both in Edge and Chrome. In other words, I've set the following:

Thanks.

@joeyparrish
Copy link
Member

@sergiofagostinho, thanks!

@Doolali
Copy link
Author

Doolali commented Feb 29, 2016

@sergiofagostinho I was using our own content which we used Unified Streaming's packager to DASH.

@TheModMaker TheModMaker added the component: EME The issue involves the Encrypted Media Extensions web API label Feb 2, 2017
@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: EME The issue involves the Encrypted Media Extensions web API status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

6 participants