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

Emit keySystemLicenseRequestFailed twice if we block the license #6701

Closed
5 tasks done
JackPu opened this issue Sep 18, 2024 · 3 comments · Fixed by #6704
Closed
5 tasks done

Emit keySystemLicenseRequestFailed twice if we block the license #6701

JackPu opened this issue Sep 18, 2024 · 3 comments · Fixed by #6704
Labels
Bug Confirmed Bug report confirmed or reproduced.
Milestone

Comments

@JackPu
Copy link
Contributor

JackPu commented Sep 18, 2024

What version of Hls.js are you using?

the master

What browser (including version) are you using?

The recent Chrome 130.x

What OS (including version) are you using?

Mac OS Sonoma

Test stream

https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine-hls/hls.m3u8

Configuration

{
  "debug": true,
  "enableWorker": true,
  "lowLatencyMode": true,
  "backBufferLength": 90,
  "widevineLicenseUrl": "https://cwip-shaka-proxy.appspot.com/no_auth",
  "emeEnabled": true
}

Additional player setup steps

Please block the license url https://cwip-shaka-proxy.appspot.com/no_auth via Chrome Devtool

Checklist

Steps to reproduce

  • Please open the codepen https://codepen.io/Jack_Pu/pen/ZEddVPQ
  • Block the license url https://cwip-shaka-proxy.appspot.com/no_auth via Chrome Devtool
  • Check the error console

Expected behaviour

trigger keySystemLicenseRequestFailed only one time

What actually happened?

trigger keySystemLicenseRequestFailed twice
WX20240918-171006@2x

Console output

[log] > Debug logs enabled for "Hls instance" in hls.js version 1.5.14
hls.ts:380 [log] > attachMedia
buffer-controller.ts:198 [log] > [buffer-controller] created media source: MediaSource
hls.ts:442 [log] > stopLoad
hls.ts:410 [log] > loadSource:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine-hls/hls.m3u8
stream-controller.ts:576 [log] > [stream-controller]: Trigger BUFFER_RESET
buffer-controller.ts:994 [log] > [buffer-controller] Media source opened
level-controller.ts:337 [log] > [level-controller]: manifest loaded, 5 level(s) found, first bitrate: 831086
abr-controller.ts:58 [log] > setting initial bwe to 831086
buffer-controller.ts:186 [log] > [buffer-controller] 2 bufferCodec event(s) expected
hls.ts:431 [log] > startLoad(-1)
abr-controller.ts:701 [log] > [abr] picked start tier {"codecSet":"avc1,mp4a","videoRanges":["SDR"],"preferHDR":false,"minFramerate":0,"minBitrate":831086}
abr-controller.ts:855 [info] > [abr] switch candidate:0->0 adjustedbw(831086)-bitrate=0 ttfb:0.1 avgDuration:0.0 maxFetchDuration:4.0 fetchDuration:0.1 firstSelection:true codecSet:avc1,mp4a videoRange:SDR hls.loadLevel:-1
level-controller.ts:432 [log] > [level-controller]: Switching to level 0 (144p SDR avc1,mp4a @831086) from level -1
audio-track-controller.ts:186 [log] > [audio-track-controller]: Updating audio tracks, 6 track(s) found in group(s): default-audio-group
audio-track-controller.ts:332 [log] > [audio-track-controller]: Switching to audio-track 0 "stream_6" lang:en group:default-audio-group channels:6
base-stream-controller.ts:1659 [log] > [audio-stream-controller]: Reset loading state
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: STOPPED->IDLE
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: IDLE->WAITING_TRACK
subtitle-track-controller.ts:276 [log] > [subtitle-track-controller]: Updating subtitle tracks, 4 track(s) found in "default-text-group" group-id
subtitle-track-controller.ts:524 [log] > [subtitle-track-controller]: Switching to subtitle-track 0 "stream_0" lang:en group:default-text-group
level-controller.ts:600 [log] > [level-controller]: Loading level index 0 with https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine-hls/playlist_v-0144p-0100k-libx264.mp4.m3u8
base-stream-controller.ts:1801 [log] > [stream-controller]: STOPPED->IDLE
audio-track-controller.ts:422 [log] > [audio-track-controller]: loading audio-track playlist 0 "stream_6" lang:en group:default-audio-group
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: WAITING_TRACK->STOPPED
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: STOPPED->WAITING_TRACK
subtitle-track-controller.ts:437 [log] > [subtitle-track-controller]: Loading subtitle playlist for id 0
base-stream-controller.ts:1801 [log] > [subtitle-stream-controller]: STOPPED->IDLE
stream-controller.ts:639 [log] > [stream-controller]: Level 0 loaded [0,14][part-14--1], cc [0, 1] duration:60
buffer-controller.ts:861 [log] > [buffer-controller] Updating Media Source duration to 60.000
eme-controller.ts:388 [log] > [eme] Selecting key-system from fragment (sn: 2 main: 0) key formats urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed
eme-controller.ts:256 [log] > [eme] Requesting encrypted media "com.widevine.alpha" key-system access with config: [{"initDataTypes":["cenc"],"persistentState":"optional","distinctiveIdentifier":"optional","sessionTypes":["temporary"],"audioCapabilities":[{"contentType":"audio/mp4; codecs=\"mp4a.40.2\"","robustness":"","encryptionScheme":null}],"videoCapabilities":[{"contentType":"video/mp4; codecs=\"avc1.42c01e\"","robustness":"","encryptionScheme":null},{"contentType":"video/mp4; codecs=\"avc1.4d401f\"","robustness":"","encryptionScheme":null}]}]
eme-controller.ts:237 It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior.
requestMediaKeySystemAccess$1 @ eme-controller.ts:237
getMediaKeysPromise @ eme-controller.ts:261
attempt @ eme-controller.ts:194
(anonymous) @ eme-controller.ts:216
attemptKeySystemAccess @ eme-controller.ts:184
getKeySystemSelectionPromise @ eme-controller.ts:523
(anonymous) @ eme-controller.ts:408
getKeyFormatPromise @ eme-controller.ts:401
selectKeySystemFormat @ eme-controller.ts:393
_loop @ key-loader.ts:104
loadClear @ key-loader.ts:97
_doFragLoad @ base-stream-controller.ts:683
_loadInitSegment @ base-stream-controller.ts:480
loadFragment @ stream-controller.ts:372
doTickIdle @ stream-controller.ts:356
doTick @ stream-controller.ts:211
tick @ task-loop.ts:106
onLevelLoaded @ stream-controller.ts:696
emit @ index.js:203
emit @ hls.ts:310
trigger @ hls.ts:318
handlePlaylistLoaded @ playlist-loader.ts:683
handleTrackOrLevelPlaylist @ playlist-loader.ts:505
onSuccess @ playlist-loader.ts:319
readystatechange @ xhr-loader.ts:238
XMLHttpRequest.send
openAndSendXhr @ xhr-loader.ts:165
loadInternal @ xhr-loader.ts:124
load @ xhr-loader.ts:82
load @ playlist-loader.ts:352
onLevelLoading @ playlist-loader.ts:166
emit @ index.js:203
emit @ hls.ts:310
trigger @ hls.ts:318
loadPlaylist @ level-controller.ts:614
set @ level-controller.ts:481
set @ level-controller.ts:633
set @ hls.ts:574
startLoad @ stream-controller.ts:143
(anonymous) @ hls.ts:434
startLoad @ hls.ts:433
filterAndSortMediaOptions @ level-controller.ts:376
onManifestLoaded @ level-controller.ts:200
emit @ index.js:203
emit @ hls.ts:310
trigger @ hls.ts:318
handleMasterPlaylist @ playlist-loader.ts:429
onSuccess @ playlist-loader.ts:327
readystatechange @ xhr-loader.ts:238
XMLHttpRequest.send
openAndSendXhr @ xhr-loader.ts:165
loadInternal @ xhr-loader.ts:124
load @ xhr-loader.ts:82
load @ playlist-loader.ts:352
onManifestLoading @ playlist-loader.ts:154
emit @ index.js:203
emit @ hls.ts:310
trigger @ hls.ts:318
loadSource @ hls.ts:420
(anonymous) @ pen.js:13
Show 4 more frames
Show less
base-stream-controller.ts:758 [log] > [stream-controller]: Loading fragment initSegment cc: 0 of [0-14] level: 0, target: 0
base-stream-controller.ts:1801 [log] > [stream-controller]: IDLE->FRAG_LOADING
eme-controller.ts:275 [log] > [eme] Access for key-system "com.widevine.alpha" obtained
eme-controller.ts:164 [log] > [eme] No Server Certificate in config.drmSystems["com.widevine.alpha"]
eme-controller.ts:281 [log] > [eme] Create media-keys for "com.widevine.alpha"
audio-track-controller.ts:100 [log] > [audio-track-controller]: Audio track 0 "stream_6" lang:en group:default-audio-group loaded [0-14]
audio-stream-controller.ts:518 [log] > [audio-stream-controller]: Audio track 0 loaded [0,14][part-14--1],duration:60
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: WAITING_TRACK->IDLE
base-stream-controller.ts:758 [log] > [audio-stream-controller]: Loading fragment initSegment cc: 0 of [0-14] track: 0, target: 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: IDLE->FRAG_LOADING
subtitle-track-controller.ts:188 [log] > [subtitle-track-controller]: Subtitle track 0 "stream_0" lang:en group:default-text-group loaded [0-15]
subtitle-stream-controller.ts:283 [log] > [subtitle-stream-controller]: Subtitle track 0 loaded [0,15][part-15--1],duration:64
base-stream-controller.ts:758 [log] > [subtitle-stream-controller]: Loading fragment 0 cc: 0 of [0-15] track: 0, target: 0
base-stream-controller.ts:1801 [log] > [subtitle-stream-controller]: IDLE->FRAG_LOADING
eme-controller.ts:285 [log] > [eme] Media-keys created for "com.widevine.alpha"
base-stream-controller.ts:389 [log] > [subtitle-stream-controller]: Loaded fragment 0 of level 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: FRAG_LOADING->IDLE
base-stream-controller.ts:758 [log] > [audio-stream-controller]: Loading fragment 0 cc: 0 of [0-14] track: 0, target: 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: IDLE->FRAG_LOADING
base-stream-controller.ts:1801 [log] > [stream-controller]: FRAG_LOADING->IDLE
base-stream-controller.ts:758 [log] > [stream-controller]: Loading fragment 0 cc: 0 of [0-14] level: 0, target: 0
base-stream-controller.ts:1801 [log] > [stream-controller]: IDLE->FRAG_LOADING
transmuxer-interface.ts:88 [log] > injecting Web Worker for "audio"
audio-stream-controller.ts:637 [log] > [audio-stream-controller]: Unknown video PTS for cc 0, waiting for video PTS before demuxing audio frag 0 of [0 ,14],track 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: FRAG_LOADING->WAITING_INIT_PTS
base-stream-controller.ts:389 [log] > [audio-stream-controller]: Loaded fragment 0 of level 0
1e84db15-37fc-4db9-8d91-d444aac7fac8:555 [log] > Debug logs enabled for "audio" in hls.js version 1.5.14
transmuxer-interface.ts:88 [log] > injecting Web Worker for "main"
transmuxer-interface.ts:230 [log] > [transmuxer-interface, main]: Starting new transmux session for sn: 0 p: -1 level: 0 id: 1
        discontinuity: true
        trackSwitch: true
        contiguous: false
        accurateTimeOffset: true
        timeOffset: 0
        initSegmentChange: true
base-stream-controller.ts:389 [log] > [stream-controller]: Loaded fragment 0 of level 0
451d7b12-579d-453f-ac47-06e1040e4c5b:555 [log] > Debug logs enabled for "main" in hls.js version 1.5.14
base-stream-controller.ts:1801 [log] > [stream-controller]: FRAG_LOADING->PARSING
stream-controller.ts:1314 [log] > [stream-controller]: Init video buffer, container:video/mp4, codecs[level/parsed]=[avc1.42c01e/avc1.42C01E]
buffer-controller.ts:393 [log] > [buffer-controller] 1 bufferCodec event(s) expected video
audio-stream-controller.ts:134 [log] > [audio-stream-controller]: InitPTS for cc: 0 found from main: 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: WAITING_INIT_PTS->FRAG_LOADING
transmuxer-interface.ts:230 [log] > [transmuxer-interface, audio]: Starting new transmux session for sn: 0 p: -1 level: 0 id: 1
        discontinuity: true
        trackSwitch: true
        contiguous: false
        accurateTimeOffset: false
        timeOffset: 0
        initSegmentChange: true
base-stream-controller.ts:1801 [log] > [subtitle-stream-controller]: FRAG_LOADING->IDLE
base-stream-controller.ts:570 [log] > [subtitle-stream-controller]: Buffered subtitle sn: 0 of track 0 (frag:[NaN-NaN] > buffer:[0.000-4.000])
base-stream-controller.ts:758 [log] > [subtitle-stream-controller]: Loading fragment 1 cc: 0 of [0-15] track: 0, target: 4
base-stream-controller.ts:1801 [log] > [subtitle-stream-controller]: IDLE->FRAG_LOADING
transmuxer-interface.ts:394 [log] > [transmuxer.ts]: Flushed fragment 0 of level 0
base-stream-controller.ts:1801 [log] > [stream-controller]: PARSING->PARSED
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: FRAG_LOADING->PARSING
audio-stream-controller.ts:900 [log] > [audio-stream-controller]: Init audio buffer, container:audio/mp4, codecs[level/parsed]=[mp4a.40.2/mp4a.40.2]
buffer-controller.ts:393 [log] > [buffer-controller] 0 bufferCodec event(s) expected audio
buffer-controller.ts:943 [log] > [buffer-controller] creating sourceBuffer(video/mp4;codecs=avc1.42c01e)
buffer-controller.ts:943 [log] > [buffer-controller] creating sourceBuffer(audio/mp4;codecs=mp4a.40.2)
stream-controller.ts:850 [log] > [stream-controller]: Alternate track found, use video.buffered to schedule main fragment loading
transmuxer-interface.ts:394 [log] > [transmuxer.ts]: Flushed fragment 0 of level 0
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: PARSING->PARSED
eme-controller.ts:654 [log] > [eme] Setting media-keys for "com.widevine.alpha"
eme-controller.ts:645 [log] > [eme] "waitingforkey" event
eme-controller.ts:667 [log] > [eme] Media-keys set for "com.widevine.alpha"
eme-controller.ts:319 [log] > [eme] Creating key-system session "com.widevine.alpha" keyId: 63656332663634616137383930613131
eme-controller.ts:714 [log] > [eme] Generating key-session request for "encrypted-event-no-match": 63656332663634616137383930613131 (init data type: cenc length: 62)
base-stream-controller.ts:570 [log] > [stream-controller]: Buffered main sn: 0 of level 0 (frag:[0.000-4.000] > buffer:[0.000-4.000])
base-stream-controller.ts:1801 [log] > [stream-controller]: PARSED->IDLE
base-stream-controller.ts:758 [log] > [stream-controller]: Loading fragment 1 cc: 0 of [0-14] level: 0, target: 4
base-stream-controller.ts:1801 [log] > [stream-controller]: IDLE->FRAG_LOADING
base-stream-controller.ts:570 [log] > [audio-stream-controller]: Buffered audio sn: 0 of track 0 (frag:[0.000-4.032] > buffer:[0.000-4.011])
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: PARSED->IDLE
base-stream-controller.ts:758 [log] > [audio-stream-controller]: Loading fragment 1 cc: 0 of [0-14] track: 0, target: 4.032
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: IDLE->FRAG_LOADING
eme-controller.ts:814 [log] > [eme] Request generated for key-session "DA50049D4FD59FFC9BA8503D1D091832" keyId: 63656332663634616137383930613131
eme-controller.ts:729 [log] > [eme] "license-request" message event for session "DA50049D4FD59FFC9BA8503D1D091832" message size: 2
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 8 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 7 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 6 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 5 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 4 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 3 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 2 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:1153 [warn] > [eme] Retrying license request, 1 attempts left
xhr.onreadystatechange @ eme-controller.ts:1153
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
xhr.onreadystatechange @ eme-controller.ts:1156
XMLHttpRequest.send
(anonymous) @ eme-controller.ts:1180
Promise.then
(anonymous) @ eme-controller.ts:1172
requestLicense @ eme-controller.ts:1093
renewLicense @ eme-controller.ts:968
context._onmessage @ eme-controller.ts:736
eme-controller.ts:1095 [log] > [eme] Sending license request to URL: https://cwip-shaka-proxy.appspot.com/no_auth
eme-controller.ts:475 [error] > [eme] License Request XHR failed (https://cwip-shaka-proxy.appspot.com/no_auth). Status: 0 ()
handleError @ eme-controller.ts:475
(anonymous) @ eme-controller.ts:737
Promise.catch
context._onmessage @ eme-controller.ts:736
base-stream-controller.ts:1801 [log] > [stream-controller]: FRAG_LOADING->ERROR
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: FRAG_LOADING->ERROR
hls.ts:442 [log] > stopLoad
base-stream-controller.ts:1801 [log] > [stream-controller]: ERROR->STOPPED
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: ERROR->STOPPED
base-stream-controller.ts:1801 [log] > [subtitle-stream-controller]: FRAG_LOADING->STOPPED
pen.js:16 trigger error {type: 'keySystemError', details: 'keySystemLicenseRequestFailed', fatal: true, networkDetails: XMLHttpRequest, response: {…}, …}
eme-controller.ts:1277 [log] > [eme] Remove licenses and keys and close session DA50049D4FD59FFC9BA8503D1D091832
eme-controller.ts:475 [error] > [eme] License Request XHR failed (https://cwip-shaka-proxy.appspot.com/no_auth). Status: 0 ()
handleError @ eme-controller.ts:475
(anonymous) @ eme-controller.ts:641
Promise.catch
_onMediaEncrypted @ eme-controller.ts:641
base-stream-controller.ts:1801 [log] > [stream-controller]: STOPPED->ERROR
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: STOPPED->ERROR
hls.ts:442 [log] > stopLoad
base-stream-controller.ts:1801 [log] > [stream-controller]: ERROR->STOPPED
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: ERROR->STOPPED
pen.js:16 trigger error {type: 'keySystemError', details: 'keySystemLicenseRequestFailed', fatal: true, networkDetails: XMLHttpRequest, response: {…}, …}
eme-controller.ts:475 [error] > [eme] License Request XHR failed (https://cwip-shaka-proxy.appspot.com/no_auth). Status: 0 ()
handleError @ eme-controller.ts:475
(anonymous) @ eme-controller.ts:641
Promise.catch
_onMediaEncrypted @ eme-controller.ts:641
base-stream-controller.ts:1801 [log] > [stream-controller]: STOPPED->ERROR
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: STOPPED->ERROR
hls.ts:442 [log] > stopLoad
base-stream-controller.ts:1801 [log] > [stream-controller]: ERROR->STOPPED
base-stream-controller.ts:1801 [log] > [audio-stream-controller]: ERROR->STOPPED
pen.js:16 trigger error {type: 'keySystemError', details: 'keySystemLicenseRequestFailed', fatal: true, networkDetails: XMLHttpRequest, response: {…}, …}
9Request was blocked by DevTools: "<URL>"

More information

I located here https://github.com/video-dev/hls.js/blob/master/src/controller/eme-controller.ts#L771-L772

We use this.handleError(error); to send the error event. But then we use licenseStatus to emit the error. So it will trigger the error one more time.

https://github.com/video-dev/hls.js/blob/master/src/controller/eme-controller.ts#L809

https://github.com/video-dev/hls.js/blob/master/src/controller/eme-controller.ts#L459

Chrome media internals output

No response

@JackPu JackPu added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Sep 18, 2024
@robwalch
Copy link
Collaborator

robwalch commented Sep 18, 2024

License requests are retried based on the configured keyLoadPolicy:
https://github.com/video-dev/hls.js/blob/master/docs/API.md#fragloadpolicy--keyloadpolicy--certloadpolicy--playlistloadpolicy--manifestloadpolicy--steeringmanifestloadpolicy

Provide a maxNumRetry of 0 or add a shouldRetry callback to override the default behavior. You can also set timeoutRetry and errorRetry to null to disable retries:

keyLoadPolicy: {
  default: {
    maxTimeToFirstByteMs: 8000,
    maxLoadTimeMs: 20000,
    timeoutRetry: null,
    errorRetry: {
      maxNumRetry: 0,
      retryDelayMs: 0,
      maxRetryDelayMs: 0
    },
  },
},

const retryConfig = keyLoadPolicy.errorRetry;
const maxNumRetry = retryConfig ? retryConfig.maxNumRetry : 0;
this._requestLicenseFailureCount++;
if (
this._requestLicenseFailureCount > maxNumRetry ||
(xhr.status >= 400 && xhr.status < 500)
) {
reject(
new EMEKeyError(
{
type: ErrorTypes.KEY_SYSTEM_ERROR,
details: ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,
fatal: true,
networkDetails: xhr,
response: {
url,
data: undefined as any,
code: xhr.status,
text: xhr.statusText,
},
},
`License Request XHR failed (${url}). Status: ${xhr.status} (${xhr.statusText})`,

@robwalch robwalch added Works as expected and removed Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Sep 18, 2024
@robwalch robwalch changed the title Emit keySystemLicenseRequestFailed twice if we block the licnese Emit keySystemLicenseRequestFailed twice if we block the license Sep 18, 2024
@robwalch robwalch changed the title Emit keySystemLicenseRequestFailed twice if we block the license How to disable license request retries? Sep 18, 2024
@JackPu
Copy link
Contributor Author

JackPu commented Sep 19, 2024

No the issue is not about the retry config. I mean, we emit twice error with fatal: true. In fact, it should emit once. You can see the more information part:

1 reach the max retry count and reject the error
2 `renewLicense` catches the error and emits the error data once
3 `licenseStatus` emits the same error and rejects it
4 `keySessionContextPromise` catch the `licenseStatus` rejected error and emits twice

@robwalch robwalch reopened this Sep 19, 2024
@robwalch robwalch added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. and removed Question answered Works as expected labels Sep 19, 2024
@robwalch robwalch changed the title How to disable license request retries? Emit keySystemLicenseRequestFailed twice if we block the license Sep 19, 2024
@JackPu
Copy link
Contributor Author

JackPu commented Sep 19, 2024

#6703 A PR helps to describe the issue.

robwalch added a commit that referenced this issue Sep 19, 2024
…rror if no longer listening to license status as part of keyUsablePromise

Resolves #6701
Replaces #6703
@robwalch robwalch added Confirmed Bug report confirmed or reproduced. and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Sep 27, 2024
@robwalch robwalch added this to the 1.6.0 milestone Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed Bug report confirmed or reproduced.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants