question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fairplay launch the error always "FAILED_TO_GENERATE_LICENSE_REQUEST" but with the Apple demo page it's working

See original GitHub issue

Have you read the FAQ and checked for duplicate open issues? Yes

What version of Shaka Player are you using? 2.5.0

Can you reproduce the issue with our latest release version? Yes

Can you reproduce the issue with the latest code from master? Yes

Are you using the demo app or your own custom app? Demo app

If custom app, can you reproduce the issue using our demo app?

What browser and OS are you using? Safari 12.1 over Mojave

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

What are the manifest and license server URIs?

There is a discussion already started by mail with the link

What did you do?

Load a Fairplay stream

What did you expect to happen? Works without problem

What actually happened?

Captura de pantalla 2019-05-08 a las 13 08 13

but the video works (Note, that the screen is in blank due to Fairplay)

Note: I changed the custom.js in the demo to support Fairplay with the next change: const commonDrmSystems = new Set([ ‘com.widevine.alpha’, ‘com.microsoft.playready’, ‘com.adobe.primetime’, ‘com.apple.fps.1_0’, ‘org.w3.clearkey’, ]);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
bcupaccommented, Sep 2, 2019

Having the same issue as @KieronAllsop. Init data is generated 2 times, first time the DRM flow passes, and second time it throws FAILED_TO_GENERATE_LICENSE_REQUEST error. The stream can be played. Found out that encrypted event is triggered twice, so if in drm_engine.js I change:

// Explicit init data for any one stream or an offline session is
// sufficient to suppress 'encrypted' events for all streams.
      const cb = (e) => this.newInitData(
          e.initDataType, shaka.util.BufferUtils.toUint8(e.initData));
      this.eventManager_.listen(this.video_, 'encrypted', cb);

to

// Explicit init data for any one stream or an offline session is
// sufficient to suppress 'encrypted' events for all streams.
      const cb = (e) => this.newInitData(
          e.initDataType, shaka.util.BufferUtils.toUint8(e.initData));
      this.eventManager_.listenOnce(this.video_, 'encrypted', cb);

it goes away. Not sure what this in-code comment means, should this somehow already be suppressed to trigger just once?

1reaction
KieronAllsopcommented, Jun 24, 2019

Having just integrated against shaka 2.5.2 I can confirm this is an issue and hope that the following debug helps. This is in Safari in Mojave.

For a single key encrypted fairplay asset there are two sessions created, one with the correct initData and second one containing skd://uuid as the initData.

[Log] PatchedMediaKeysApple.onWebkitNeedKey_ ? WebKitMediaKeyNeededEvent {isTrusted: true, initData: Uint8Array, type: "webkitneedkey", ?} (patchedmediakeys_apple.js, line 611)
WebKitMediaKeyNeededEvent {isTrusted: true, initData: Uint8Array, type: "webkitneedkey", target: <video id="video">, currentTarget: <video id="video">, ?}WebKitMediaKeyNeededEventbubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: nulldefaultPrevented: falseeventPhase: 0initData: Uint8Array [84, 0, 0, 0, 115, 0, 107, 0, 100, 0, ?]Uint8Array (88)isTrusted: truereturnValue: truesrcElement: <video id="video"><video id="video">target: <video id="video"><video id="video">timeStamp: 1554type: "webkitneedkey"WebKitMediaKeyNeededEvent Prototype
[Debug] Creating new temporary session (drm_engine.js, line 1093)
[Log] PatchedMediaKeysApple.MediaKeys.createSession (patchedmediakeys_apple.js, line 324)
[Log] PatchedMediaKeysApple.MediaKeySession (patchedmediakeys_apple.js, line 408)
[Log] PatchedMediaKeysApple.MediaKeySession.generateRequest (patchedmediakeys_apple.js, line 448)
[Log] MyDebug: initData: Tskd://3e44...etc             (patchedmediakeys_apple.js, line 450)                    <= CORRECT
[Log] MyDebug: sessionId: 776d1488-e456-4859-aa7a-afe4c6e5eaeb (patchedmediakeys_apple.js, line 460)
[Debug] Key status changed for session - "" (drm_engine.js, line 1400)
[Debug] Creating new temporary session (drm_engine.js, line 1093)
[Log] PatchedMediaKeysApple.MediaKeys.createSession (patchedmediakeys_apple.js, line 324)
[Log] PatchedMediaKeysApple.MediaKeySession (patchedmediakeys_apple.js, line 408)
[Log] PatchedMediaKeysApple.MediaKeySession.generateRequest (patchedmediakeys_apple.js, line 448)
[Log] MyDebug: initData: skd://3e44d6d7-15a8-45c6-b4ec-c53c76fb70a7 (patchedmediakeys_apple.js, line 450)       <= INCORRECT
[Log] MyDebug: sessionId: da9a72b6-8a50-4210-9ad9-040f6db51727 (patchedmediakeys_apple.js, line 460)

The second session then gives the following error which results in the “FAILED_TO_GENERATE_LICENSE_REQUEST” error we are seeing.

[Log] PatchedMediaKeysApple.onWebkitKeyError_ - Event {isTrusted: true, type: "webkitkeyerror", target: WebKitMediaKeySession, ?} (patchedmediakeys_apple.js, line 705)
Event {isTrusted: true, type: "webkitkeyerror", target: WebKitMediaKeySession, currentTarget: WebKitMediaKeySession, eventPhase: 2, ?}Eventbubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: truereturnValue: truesrcElement: WebKitMediaKeySession {error: WebKitMediaKeyError, keySystem: "com.apple.fps.1_0", sessionId: "da9a72b6-8a50-4210-9ad9-040f6db51727", onwebkitkeyadded: null, onwebkitkeyerror: null, ?}WebKitMediaKeySessiontarget: WebKitMediaKeySession {error: WebKitMediaKeyError, keySystem: "com.apple.fps.1_0", sessionId: "da9a72b6-8a50-4210-9ad9-040f6db51727", onwebkitkeyadded: null, onwebkitkeyerror: null, ?}WebKitMediaKeySessiontimeStamp: 1578type: "webkitkeyerror"Event Prototype
[Log] MyDebug: sessionId: da9a72b6-8a50-4210-9ad9-040f6db51727 (patchedmediakeys_apple.js, line 706)

The first session created (with the correct initData) completes and the content plays.

[Info] LicenseRequest Success - Updating CDM (drm_engine.js, line 1209)
[Log] PatchedMediaKeysApple.MediaKeySession.update (patchedmediakeys_apple.js, line 493)
[Log] PatchedMediaKeysApple.onWebkitKeyAdded_ ? Event {isTrusted: true, type: "webkitkeyadded", target: WebKitMediaKeySession, ?} (patchedmediakeys_apple.js, line 679)
Event {isTrusted: true, type: "webkitkeyadded", target: WebKitMediaKeySession, currentTarget: WebKitMediaKeySession, eventPhase: 2, ?}Event
Read more comments on GitHub >

github_iconTop Results From Across the Web

IOS 15 Safari fails with Fairplay DRM playback
Hi, IOS 15 Safari does not support Fairplay DRM and gives an error, ... Apple team has accepted that it is a bug...
Read more >
Fairplay HTML5 example throws error on Safari 10
Hello,. Sample in the fairplay SDK throws "webkitkeyerror" event after upgrading safari to version 10. I can't really figure out the error codes...
Read more >
FairPlay streaming issue | Apple Developer Forums
I am using a sample test app provided by Apple (HLSCatalog) that works with FairPlay ... Error Domain=AVFoundationErrorDomain Code=-11836 "Cannot Open" ...
Read more >
FairPlay Streaming | Apple Developer Forums
We are running into an issue that seems unique to AVPlayer. We've built a new architecture for our HLS streams which makes use...
Read more >
Fairplay Offline playback error | Apple Developer Forums
I am using EZDRM provider for DRM protection and using Fairplay on Ipad application, the online video streaming works perfectly , we have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found