hls.js icon indicating copy to clipboard operation
hls.js copied to clipboard

SourceBuffer parent being removed

Open kilmc opened this issue 6 years ago • 8 comments

Prior issues

I read through a bunch of issues and while I found some similar ones, none of them contained an actual resolution to the issue so I'm opening this one rather than re-opening a stale one.

What version of Hls.js are you using?

12.4

What browser and OS are you using?

Chrome 75.0.3770.101 Android 8.1.0; Nexus 6P

Test stream:

https://v.kickstarter.com/1565036810_efa996fac721429ad9226f1b710098f955a2e828/projects/3736754/video-974347-hls_playlist.m3u8

Checklist

  • [x] The issue observed is not already reported by searching on Github under https://github.com/video-dev/hls.js/issues
  • [x] The issue occurs in the stable client on https://hls-js.netlify.com/demo and not just on my page
  • [x] The issue occurs in the latest client on https://hls-js-latest.netlify.com/demo and not just on my page
  • [x] The stream has correct Access-Control-Allow-Origin headers (CORS)
  • [x] There are no network errors such as 404s in the browser console when trying to play the stream

Steps to reproduce

  1. Visit the following stream URL in the hls.js tester on an Android device, using Chrome: https://v.kickstarter.com/1565036810_efa996fac721429ad9226f1b710098f955a2e828/projects/3736754/video-974347-hls_playlist.m3u8
  2. Paste in the url and use the Remote Device dev tools to view console errors on the device

Expected behavior

The video should play

Actual behavior

It doesn't play

Console output

0.12.4

[log] > destroy
logger.js:40 [log] > detachMedia
logger.js:40 [log] > media source detaching
logger.js:40 [log] > main stream:PARSED->STOPPED
logger.js:40 [log] > audio stream:WAITING_TRACK->STOPPED
main.js:231 Using Hls.js config: {debug: true, enableWorker: true, defaultAudioCodec: undefined, widevineLicenseUrl: ""}
logger.js:40 [log] > loadSource:https://v.kickstarter.com/1563910592_4d0a38c4998bb04c88ebbf4917feccd4af52a2fe/projects/3736754/video-974347-hls_playlist.m3u8
logger.js:40 [log] > trigger BUFFER_RESET
logger.js:40 [log] > set autoLevelCapping:-1
logger.js:40 [log] > attachMedia
logger.js:40 [log] > media source opened
logger.js:40 [log] > manifest loaded,2 level(s) found, first bitrate:4030570
logger.js:40 [log] > 1 bufferCodec event(s) expected
logger.js:40 [log] > startLoad(-1)
logger.js:40 [log] > switching to level 1
logger.js:40 [log] > main stream:STOPPED->IDLE
logger.js:40 [log] > audio tracks updated
logger.js:40 [log] > subtitle tracks updated
logger.js:40 [log] > level 1 loaded [0,0],duration:10
logger.js:40 [log] > Loading 0 of [0 ,0],level 1, currentTime:0.000,bufferEnd:0.000
logger.js:40 [log] > demuxing in webworker
logger.js:40 [log] > main stream:IDLE->FRAG_LOADING
logger.js:40 [log] > Loaded 0 of [0 ,0],level 1
logger.js:40 [log] > Parsing 0 of [0 ,0],level 1, cc 0
logger.js:40 [log] > main stream:FRAG_LOADING->PARSING
logger.js:40 [log] > main:discontinuity detected
logger.js:40 [log] > main:switch detected
89817066-135c-4bec-8d9f-330764e1f29e:499 [log] > manifest codec:mp4a.40.2,ADTS data:type:2,sampleingIndex:4[44100Hz],channelConfig:1
89817066-135c-4bec-8d9f-330764e1f29e:499 [log] > parsed codec:mp4a.40.2,rate:44100,nb channel:1
89817066-135c-4bec-8d9f-330764e1f29e:499 [log] > audio sampling rate : 44100
logger.js:40 [log] > InitPTS for cc: 0 found from video track: 900000
logger.js:40 [log] > Android: force audio codec to mp4a.40.2
logger.js:40 [log] > creating sourceBuffer(audio/mp4;codecs=mp4a.40.2)
logger.js:40 [log] > creating sourceBuffer(video/mp4;codecs=avc1.640032)
logger.js:40 [log] > main track:audio,container:audio/mp4,codecs[level/parsed]=[mp4a.40.2/mp4a.40.2]
logger.js:40 [log] > main track:video,container:video/mp4,codecs[level/parsed]=[avc1.640032/avc1.640032]
logger.js:40 [log] > Parsed audio,PTS:[0.000,10.588],DTS:[0.000/10.588],nb:456,dropped:0
logger.js:40 [log] > Parsed video,PTS:[0.000,10.480],DTS:[0.000/10.480],nb:262,dropped:0
logger.js:40 [log] > main stream:PARSING->PARSED
main.js:755 The video could not be loaded, either because the server or network failed or because the format is not supported - DECODER_ERROR_NOT_SUPPORTED: video decoder initialization failed
handleVideoEvent @ main.js:755
buffer-controller.js:224 Uncaught DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at BufferController../src/controller/buffer-controller.js.BufferController.onSBUpdateEnd (https://hls-js.netlify.com/dist/hls.js:3096:63)
./src/controller/buffer-controller.js.BufferController.onSBUpdateEnd @ buffer-controller.js:224
logger.js:40 [log] > media source closed

0.12.3-canary

[log] > media source opened
logger.js:40 [log] > destroy
logger.js:40 [log] > detachMedia
logger.js:40 [log] > media source detaching
main.js:215 Using Hls.js config: {debug: true, enableWorker: true}
logger.js:40 [log] > loadSource:https://v.kickstarter.com/1563910592_4d0a38c4998bb04c88ebbf4917feccd4af52a2fe/projects/3736754/video-974347-hls_playlist.m3u8
logger.js:40 [log] > trigger BUFFER_RESET
logger.js:40 [log] > set autoLevelCapping:-1
logger.js:40 [log] > attachMedia
logger.js:40 [log] > manifest loaded,2 level(s) found, first bitrate:4030570
logger.js:40 [log] > 1 bufferCodec event(s) expected
logger.js:40 [log] > startLoad(-1)
logger.js:40 [log] > switching to level 1
logger.js:40 [log] > main stream:STOPPED->IDLE
logger.js:40 [log] > audio tracks updated
logger.js:40 [log] > subtitle tracks updated
logger.js:40 [log] > media source opened
logger.js:40 [log] > startLoad(-1)
logger.js:40 [log] > main stream:IDLE->STOPPED
logger.js:40 [log] > main stream:STOPPED->IDLE
logger.js:40 [log] > audio stream:STOPPED->STARTING
logger.js:40 [log] > audio stream:STARTING->WAITING_TRACK
logger.js:40 [log] > audio stream:WAITING_TRACK->STOPPED
logger.js:40 [log] > audio stream:STOPPED->STARTING
logger.js:40 [log] > audio stream:STARTING->WAITING_TRACK
logger.js:40 [log] > level 1 loaded [0,0],duration:10
logger.js:40 [log] > Loading 0 of [0 ,0],level 1, currentTime:0.000,bufferEnd:0.000
logger.js:40 [log] > demuxing in webworker
logger.js:40 [log] > main stream:IDLE->FRAG_LOADING
logger.js:40 [log] > Loaded 0 of [0 ,0],level 1
logger.js:40 [log] > Parsing 0 of [0 ,0],level 1, cc 0
logger.js:40 [log] > main stream:FRAG_LOADING->PARSING
logger.js:40 [log] > main:discontinuity detected
logger.js:40 [log] > main:switch detected
8e816b99-837b-4575-977f-4a63e9fe56d3:562 [log] > manifest codec:mp4a.40.2,ADTS data:type:2,sampleingIndex:4[44100Hz],channelConfig:1
8e816b99-837b-4575-977f-4a63e9fe56d3:562 [log] > parsed codec:mp4a.40.2,rate:44100,nb channel:1
8e816b99-837b-4575-977f-4a63e9fe56d3:562 [log] > audio sampling rate : 44100
logger.js:40 [log] > InitPTS for cc: 0 found from video track: 900000
logger.js:40 [log] > Android: force audio codec to mp4a.40.2
logger.js:40 [log] > creating sourceBuffer(audio/mp4;codecs=mp4a.40.2)
logger.js:40 [log] > creating sourceBuffer(video/mp4;codecs=avc1.640032)
logger.js:40 [log] > main track:audio,container:audio/mp4,codecs[level/parsed]=[mp4a.40.2/mp4a.40.2]
logger.js:40 [log] > main track:video,container:video/mp4,codecs[level/parsed]=[avc1.640032/avc1.640032]
logger.js:40 [log] > Parsed audio,PTS:[0.000,10.588],DTS:[0.000/10.588],nb:456,dropped:0
buffer-controller.ts:283 Uncaught DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at SourceBuffer.BufferController._this._onSBUpdateEnd (https://hls-js-latest.netlify.com/dist/hls.js:13019:37)
BufferController._this._onSBUpdateEnd @ buffer-controller.ts:283
main.js:739 The video could not be loaded, either because the server or network failed or because the format is not supported - DECODER_ERROR_NOT_SUPPORTED: video decoder initialization failed
handleVideoEvent @ main.js:739
error (async)
loadSelectedStream @ main.js:673
(anonymous) @ main.js:117
j @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
I @ jquery.min.js:2
logger.js:40 [log] > media source closed
logger.js:40 [log] > Parsed video,PTS:[0.000,10.480],DTS:[0.000/10.480],nb:262,dropped:0
2logger.js:40 [error] > trying to append although a media error occured, flush segment and abort
(anonymous) @ logger.js:40
doAppending @ buffer-controller.ts:595
onBufferAppending @ buffer-controller.ts:391
onEventGeneric @ event-handler.ts:81
onEvent @ event-handler.ts:68
emit @ index.js:203
trigger @ observer.ts:13
(anonymous) @ stream-controller.js:1029
onFragParsingData @ stream-controller.js:1022
onEventGeneric @ event-handler.ts:81
onEvent @ event-handler.ts:68
emit @ index.js:203
trigger @ observer.ts:13
onWorkerMessage @ demuxer.js:145
logger.js:40 [error] > An internal error happened while handling event hlsFragParsingUserdata. Error message: "Cannot read property '0' of undefined". Here is a stacktrace: TypeError: Cannot read property '0' of undefined
    at TimelineController.extractCea608Data (timeline-controller.js:342)
    at TimelineController.onFragParsingUserdata (timeline-controller.js:335)
    at TimelineController.onEventGeneric (event-handler.ts:81)
    at TimelineController.onEvent (event-handler.ts:68)
    at Hls.emit (index.js:182)
    at Hls.trigger (observer.ts:13)
    at Demuxer.onWorkerMessage (demuxer.js:145)
(anonymous) @ logger.js:40
onEventGeneric @ event-handler.ts:83
onEvent @ event-handler.ts:68
emit @ index.js:182
trigger @ observer.ts:13
onWorkerMessage @ demuxer.js:145
main.js:538 Error event: {type: "otherError", details: "internalException", fatal: false, event: "hlsFragParsingUserdata", err: TypeError: Cannot read property '0' of undefined
    at TimelineController.extractCea608Data (https…}
(anonymous) @ main.js:538
emit @ index.js:203
trigger @ observer.ts:13
onEventGeneric @ event-handler.ts:84
onEvent @ event-handler.ts:68
emit @ index.js:182
trigger @ observer.ts:13
onWorkerMessage @ demuxer.js:145
logger.js:40 [log] > main stream:PARSING->PARSED

For media errors reported on Chrome browser, please also paste the output of chrome://media-internals 

kilmc avatar Jul 22 '19 20:07 kilmc

Is there any chance someone could take a look at this?

kilmc avatar Aug 08 '19 15:08 kilmc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 21 '19 23:10 stale[bot]

Does anyone know the workaround to fix this?

bhawnaparasher avatar Jul 06 '20 23:07 bhawnaparasher

@bhawnaparasher this error can be thrown for example when in your level list exists 4k video and system trying to play that video on a device which not support it for this case, you can handle the error and remove 4k level from the level list. Example code:

import HLS from 'hls.js/dist/hls.light';
import last from 'lodash/last';


const hls = new HLS();


hls.on(HLS.Events.ERROR, (event, data) => {
  console.log('HLS.Events.ERROR: ', event, data);
  if (data.fatal) {
    switch (data.type) {
      case HLS.ErrorTypes.NETWORK_ERROR:
        // try to recover network error
        hls.startLoad();
        break;
      case HLS.ErrorTypes.MEDIA_ERROR:
        hls.recoverMediaError();
        break;
      default:
        // cannot recover
        hls.destroy();
        break;
    }
  } else if (data.details === 'internalException' && data.type === 'otherError' && isMobile()) {
    const level = last(this.getLevels());

    hls.removeLevel(level?.level, level?.urlId);

    hls.startLoad();
  }
});

khlevon avatar Jul 09 '20 14:07 khlevon

Hi @kilmc,

Can you please provide a new test stream?

robwalch avatar Jul 25 '20 19:07 robwalch

If the issue is related to 4k levels or other rendition features that some Android devices are unable to play, I would appreciate other users filing new issues, making sure to include:

  • Test stream/page (if possible)
  • Steps to reproduce
  • Expected behavior
  • Actual behavior

If the issue is related to your stream, and you cannot share the stream, please include all the information we would need to reproduce the issue. This includes how generate a stream that reproduces the issue.

Ignoring renditions based on device capabilities is a job for the Media Capabilities API so calling this out with a Feature Request and test streams and use cases would be very helpful.

Thanks!

robwalch avatar Jul 25 '20 19:07 robwalch

@bhawnaparasher this error can be thrown for example when in your level list exists 4k video and system trying to play that video on a device which not support it for this case, you can handle the error and remove 4k level from the level list. Example code:

import HLS from 'hls.js/dist/hls.light';
import last from 'lodash/last';


const hls = new HLS();


hls.on(HLS.Events.ERROR, (event, data) => {
  console.log('HLS.Events.ERROR: ', event, data);
  if (data.fatal) {
    switch (data.type) {
      case HLS.ErrorTypes.NETWORK_ERROR:
        // try to recover network error
        hls.startLoad();
        break;
      case HLS.ErrorTypes.MEDIA_ERROR:
        hls.recoverMediaError();
        break;
      default:
        // cannot recover
        hls.destroy();
        break;
    }
  } else if (data.details === 'internalException' && data.type === 'otherError' && isMobile()) {
    const level = last(this.getLevels());

    hls.removeLevel(level?.level, level?.urlId);

    hls.startLoad();
  }
});

Thanks much @khlevon98

bhawnaparasher avatar Jul 25 '20 23:07 bhawnaparasher

@robwalch I found an audio stream that throws this exception

zorro avatar Dec 04 '21 07:12 zorro

@zorro,

I found an audio stream that throws this exception

That is not a valid sample. There are duplicate CODECS attributes on each variant, instead of one per stream (AAC-HEv2/hlspbaudio00532kbps.m3u8 and AAC-HE/hlspbaudio00564kbps.m3u8).

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,AVERAGE-BANDWIDTH=32000,BANDWIDTH=32000,CODECS="mp4a.40.29",CODECS="mp4a.40.5"
hlspbaudio00532kbps.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,AVERAGE-BANDWIDTH=64000,BANDWIDTH=64000,CODECS="mp4a.40.29",CODECS="mp4a.40.5"
hlspbaudio00564kbps.m3u8

robwalch avatar Jun 01 '23 15:06 robwalch

Closing as a stream issue. No valid sample has been provided for triaging. AAC/Android specific decoding issues should be reported to the device/platform manufacturer.

robwalch avatar Jun 01 '23 15:06 robwalch