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

Safari raises InvalidStateError when audio segment is appended to SourceBuffer

Open Omar2002 opened this issue 8 years ago • 13 comments

Possible same problem in other issue https://github.com/video-dev/hls.js/issues/954

What version of Hls.js are you using?

latest

What browser and OS are you using?

safari 11.1.1 (12605.2.8) and 11.1.2 (12605.3.8.1)

The problem does not reproduce in safari 11.1.2 (12605.3.8) and other browsers

Test stream:

https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8

https://video-dev.github.io/hls.js/demo/?src=https%3A%2F%2Fbitmovin-a.akamaihd.net%2Fcontent%2Fsintel%2Fhls%2Fplaylist.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsImVuYWJsZVdvcmtlciI6dHJ1ZSwiZHVtcGZNUDQiOmZhbHNlLCJsZXZlbENhcHBpbmciOi0xLCJsaW1pdE1ldHJpY3MiOi0xLCJ3aWRldmluZUxpY2Vuc2VVcmwiOiIifQ==

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 latest reference client on https://video-dev.github.io/hls.js/demo and not just on my page
  • [ ] The issue occurs in the canary client on https://video-dev.github.io/hls.js/demo?version=canary 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. Open test stand in safari 11.1.1 (12605.2.8) or 11.1.2 (12605.3.8.1)
  2. Console mus contain this error InvalidStateError: The object is in an invalid state.

Expected behavior

Stream is playing

Actual behavior

Stream not playing

Console output

[Log] Using Hls.js config: – {debug: true, enableWorker: true, defaultAudioCodec: undefined, …} (hls-demo.js, line 337)
{debug: true, enableWorker: true, defaultAudioCodec: undefined, widevineLicenseUrl: ""}Object
[Log] [log] > loadSource:https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8 (hls.js@latest, line 1)
[Debug] [debug] > Loading playlist of type manifest, level: 0, id: null (hls.js@latest, line 1)
[Debug] [debug] > Calling internal loader delegate for URL: https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8 (hls.js@latest, line 1)
[Log] [log] > trigger BUFFER_RESET (hls.js@latest, line 1)
[Log] [log] > set autoLevelCapping:-1 (hls.js@latest, line 1)
[Log] [log] > attachMedia (hls.js@latest, line 1)
[Log] [log] > media source opened (hls.js@latest, line 1)
[Error] Failed to load resource: the server responded with a status of 404 () (hls.min.js.map, line 0)
[Log] [log] > manifest loaded,8 level(s) found, first bitrate:258157 (hls.js@latest, line 1)
[Log] [log] > 2 sourceBuffer(s) expected (hls.js@latest, line 1)
[Log] [log] > startLoad(-1) (hls.js@latest, line 1)
[Log] [log] > switching to level 0 (hls.js@latest, line 1)
[Debug] [debug] > Loading playlist of type level, level: 0, id: 0 (hls.js@latest, line 1)
[Debug] [debug] > Calling internal loader delegate for URL: https://bitmovin-a.akamaihd.net/content/sintel/hls/video/250kbit.m3u8 (hls.js@latest, line 1)
[Log] [log] > main stream:STOPPED->IDLE (hls.js@latest, line 1)
[Log] [log] > audio tracks updated (hls.js@latest, line 1)
[Log] [log] > subtitle tracks updated (hls.js@latest, line 1)
[Log] [log] > switching to subtitle track 1 (hls.js@latest, line 1)
[Log] [log] > (re)loading playlist for subtitle track 1 (hls.js@latest, line 1)
[Debug] [debug] > Loading playlist of type subtitleTrack, level: null, id: 1 (hls.js@latest, line 1)
[Debug] [debug] > Calling internal loader delegate for URL: https://bitmovin-a.akamaihd.net/content/sintel/hls/subtitles_en.m3u8 (hls.js@latest, line 1)
[Log] [log] > level 0 loaded [0,443],duration:888 (hls.js@latest, line 1)
[Log] [log] > Loading 0 of [0 ,443],level 0, currentTime:0.000,bufferEnd:0.000 (hls.js@latest, line 1)
[Log] [log] > demuxing in webworker (hls.js@latest, line 1)
[Log] [log] > main stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > Now switching to audio-track index 0 (hls.js@latest, line 1)
[Log] [log] > audio stream:STOPPED->PAUSED (hls.js@latest, line 1)
[Log] [log] > audio stream:PAUSED->IDLE (hls.js@latest, line 1)
[Log] [log] > loading audio-track playlist for id: 0 (hls.js@latest, line 1)
[Debug] [debug] > Loading playlist of type audioTrack, level: null, id: 0 (hls.js@latest, line 1)
[Debug] [debug] > Calling internal loader delegate for URL: https://bitmovin-a.akamaihd.net/content/sintel/hls/audio/stereo/en/128kbit.m3u8 (hls.js@latest, line 1)
[Log] [log] > Loaded 0 of [0 ,443],level 0 (hls.js@latest, line 1)
[Log] [log] > Parsing 0 of [0 ,443],level 0, cc 0 (hls.js@latest, line 1)
[Log] [log] > main stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > main:discontinuity detected (hls.js@latest, line 1)
[Log] [log] > main:switch detected (hls.js@latest, line 1)
[Log] [log] > track 0 loaded [0,452],duration:905 (hls.js@latest, line 1)
[Log] [log] > Loading 0, cc: 0 of [0 ,452],track 0, currentTime:0,bufferEnd:0.000 (hls.js@latest, line 1)
[Log] [log] > audio stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > audioTrack 0 loaded (hls.js@latest, line 1)
[Log] [log] > subtitle track 1 loaded (hls.js@latest, line 1)
[Log] [log] > InitPTS for cc: 0 found from video track: 7500 (hls.js@latest, line 1)
[Log] [log] > main track:video,container:video/mp4,codecs[level/parsed]=[avc1.4d400d/avc1.4d400d] (hls.js@latest, line 1)
[Log] [log] > Parsed video,PTS:[0.083,2.000],DTS:[0.000/2.000],nb:48,dropped:0 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSING->PARSED (hls.js@latest, line 1)
[Log] [log] > audio stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > demuxing in webworker (hls.js@latest, line 1)
[Log] [log] > Demuxing 0 of [0 ,452],track 0 (hls.js@latest, line 1)
[Log] [log] > audio:discontinuity detected (hls.js@latest, line 1)
[Log] [log] > audio:switch detected (hls.js@latest, line 1)
[Log] [log] > manifest codec:mp4a.40.2,ADTS data:type:2,sampleingIndex:3[48000Hz],channelConfig:2 (blob:https://video-dev.github.io/0f534c66-0082-4ff9-adbd-6a78b8e5b2e6, line 1)
[Log] [log] > parsed codec:mp4a.40.5,rate:48000,nb channel:2 (blob:https://video-dev.github.io/0f534c66-0082-4ff9-adbd-6a78b8e5b2e6, line 1)
[Log] [log] > audio sampling rate : 48000 (blob:https://video-dev.github.io/0f534c66-0082-4ff9-adbd-6a78b8e5b2e6, line 1)
[Log] [log] > creating sourceBuffer(video/mp4;codecs=avc1.4d400d) (hls.js@latest, line 1)
[Log] [log] > creating sourceBuffer(audio/mp4;codecs=mp4a.40.5) (hls.js@latest, line 1)
[Log] [log] > alternate track found, use video.buffered to schedule main fragment loading (hls.js@latest, line 1)
[Log] [log] > audio track:audio,container:audio/mp4,codecs[level/parsed]=[mp4a.40.5/mp4a.40.5] (hls.js@latest, line 1)
[Log] [log] > parsed audio,PTS:[0.002,1.879],DTS:[0.002/1.879],nb:88 (hls.js@latest, line 1)
[Log] [log] > audio stream:PARSING->PARSED (hls.js@latest, line 1)
[Log] [log] > main buffered : [0.083,2.083] (hls.js@latest, line 1)
[Log] [log] > latency/loading/parsing/append/kbps:19/0/472/133/130 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSED->IDLE (hls.js@latest, line 1)
[Log] [log] > Loading 1 of [0 ,443],level 0, currentTime:2.000,bufferEnd:2.083 (hls.js@latest, line 1)
[Log] [log] > main stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > Loaded 1 of [0 ,443],level 0 (hls.js@latest, line 1)
[Log] [log] > Parsing 1 of [0 ,443],level 0, cc 0 (hls.js@latest, line 1)
[Log] [log] > main stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > Parsed video,PTS:[2.083,4.083],DTS:[2.000/4.000],nb:48,dropped:0 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSING->PARSED (hls.js@latest, line 1)
[Error] [error] > sourceBuffer error: – Event {isTrusted: true, type: "error", target: SourceBuffer, …}
Event {isTrusted: true, type: "error", target: SourceBuffer, currentTarget: SourceBuffer, eventPhase: 2, …}Eventbubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: truereturnValue: truesrcElement: SourceBuffer {ended: false, mode: "segments", updating: false, timestampOffset: 0, audioTracks: AudioTrackList, …}SourceBuffertarget: SourceBuffer {ended: false, mode: "segments", updating: false, timestampOffset: 0, audioTracks: AudioTrackList, …}SourceBuffertimeStamp: 2835type: "error"Прототип Event
	(анонимная функция) (hls.js@latest:1:947)
	onSBUpdateError (hls.js@latest:1:171045)
	(анонимная функция)
[Warning] Error event: – {type: "mediaError", details: "bufferAppendingError", fatal: false} (hls-demo.js, line 638)
[Error] InvalidStateError: The object is in an invalid state.
	onSBUpdateEnd (hls.js@latest:1:170842)
	(анонимная функция)
[Log] [log] > media source ended (hls.js@latest, line 1)
[Log] [log] > recoverMediaError (hls.js@latest, line 1)
[Log] [log] > detachMedia (hls.js@latest, line 1)
[Log] [log] > media source detaching (hls.js@latest, line 1)
[Log] [log] > main stream:PARSED->STOPPED (hls.js@latest, line 1)
[Log] [log] > audio stream:PARSED->STOPPED (hls.js@latest, line 1)
[Log] [log] > attachMedia (hls.js@latest, line 1)
[Error] The video playback was aborted due to a corruption problem or because the video used features your browser did not support
	handleVideoEvent (hls-demo.js:836)
[Log] [log] > media source opened (hls.js@latest, line 1)
[Log] [log] > startLoad(-1) (hls.js@latest, line 1)
[Log] [log] > main stream:STOPPED->IDLE (hls.js@latest, line 1)
[Log] [log] > Loading 0 of [0 ,443],level 0, currentTime:-1.000,bufferEnd:-1.000 (hls.js@latest, line 1)
[Log] [log] > audio stream:STOPPED->STARTING (hls.js@latest, line 1)
[Log] [log] > audio stream:STARTING->WAITING_TRACK (hls.js@latest, line 1)
[Log] [log] > audio stream:WAITING_TRACK->STOPPED (hls.js@latest, line 1)
[Log] [log] > audio stream:STOPPED->STARTING (hls.js@latest, line 1)
[Log] [log] > audio stream:STARTING->WAITING_TRACK (hls.js@latest, line 1)
[Log] [log] > audio stream:WAITING_TRACK->IDLE (hls.js@latest, line 1)
[Log] [log] > Loading 1 of [0 ,443],level 0, currentTime:2.083,bufferEnd:2.083 (hls.js@latest, line 1)
[Log] [log] > demuxing in webworker (hls.js@latest, line 1)
[Log] [log] > main stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > Loaded 1 of [0 ,443],level 0 (hls.js@latest, line 1)
[Log] [log] > Parsing 1 of [0 ,443],level 0, cc 0 (hls.js@latest, line 1)
[Log] [log] > main stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > main:discontinuity detected (hls.js@latest, line 1)
[Log] [log] > main:switch detected (hls.js@latest, line 1)
[Log] [log] > InitPTS for cc: 0 found from video track: 7500 (hls.js@latest, line 1)
[Log] [log] > main track:video,container:video/mp4,codecs[level/parsed]=[avc1.4d400d/avc1.4d400d] (hls.js@latest, line 1)
[Log] [log] > Parsed video,PTS:[2.083,4.083],DTS:[2.000/4.000],nb:48,dropped:0 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSING->PARSED (hls.js@latest, line 1)
[Log] [log] > Loading 0, cc: 0 of [0 ,452],track 0, currentTime:-1,bufferEnd:-1.000 (hls.js@latest, line 1)
[Log] [log] > audio stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > audio stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > demuxing in webworker (hls.js@latest, line 1)
[Log] [log] > Demuxing 0 of [0 ,452],track 0 (hls.js@latest, line 1)
[Log] [log] > audio:discontinuity detected (hls.js@latest, line 1)
[Log] [log] > audio:switch detected (hls.js@latest, line 1)
[Log] [log] > manifest codec:mp4a.40.2,ADTS data:type:2,sampleingIndex:3[48000Hz],channelConfig:2 (blob:https://video-dev.github.io/5e0d31db-6316-44b1-a097-bdd56c8164b6, line 1)
[Log] [log] > parsed codec:mp4a.40.5,rate:48000,nb channel:2 (blob:https://video-dev.github.io/5e0d31db-6316-44b1-a097-bdd56c8164b6, line 1)
[Log] [log] > audio sampling rate : 48000 (blob:https://video-dev.github.io/5e0d31db-6316-44b1-a097-bdd56c8164b6, line 1)
[Log] [log] > creating sourceBuffer(video/mp4;codecs=avc1.4d400d) (hls.js@latest, line 1)
[Log] [log] > creating sourceBuffer(audio/mp4;codecs=mp4a.40.5) (hls.js@latest, line 1)
[Log] [log] > alternate track found, use video.buffered to schedule main fragment loading (hls.js@latest, line 1)
[Log] [log] > audio track:audio,container:audio/mp4,codecs[level/parsed]=[mp4a.40.5/mp4a.40.5] (hls.js@latest, line 1)
[Log] [log] > parsed audio,PTS:[0.002,1.879],DTS:[0.002/1.879],nb:88 (hls.js@latest, line 1)
[Log] [log] > audio stream:PARSING->PARSED (hls.js@latest, line 1)
[Log] [log] > main buffered : [2.083,4.083] (hls.js@latest, line 1)
[Log] [log] > latency/loading/parsing/append/kbps:6/0/81/457/1308 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSED->IDLE (hls.js@latest, line 1)
[Log] [log] > switching to level 2 (hls.js@latest, line 1)
[Debug] [debug] > Loading playlist of type level, level: 2, id: 0 (hls.js@latest, line 1)
[Debug] [debug] > Calling internal loader delegate for URL: https://bitmovin-a.akamaihd.net/content/sintel/hls/video/800kbit.m3u8 (hls.js@latest, line 1)
[Log] [log] > main stream:IDLE->WAITING_LEVEL (hls.js@latest, line 1)
[Error] [error] > sourceBuffer error: – Event {isTrusted: true, type: "error", target: SourceBuffer, …}
Event {isTrusted: true, type: "error", target: SourceBuffer, currentTarget: SourceBuffer, eventPhase: 2, …}Event
	(анонимная функция) (hls.js@latest:1:947)
	onSBUpdateError (hls.js@latest:1:171045)
	(анонимная функция)
[Warning] Error event: – {type: "mediaError", details: "bufferAppendingError", fatal: false} (hls-demo.js, line 638)
[Error] InvalidStateError: The object is in an invalid state.
	onSBUpdateEnd (hls.js@latest:1:170842)
	(анонимная функция)
[Log] [log] > media source ended (hls.js@latest, line 1)
[Log] [log] > recoverMediaError (hls.js@latest, line 1)
[Log] [log] > detachMedia (hls.js@latest, line 1)
[Log] [log] > media source detaching (hls.js@latest, line 1)
[Log] [log] > main stream:WAITING_LEVEL->STOPPED (hls.js@latest, line 1)
[Log] [log] > audio stream:PARSED->STOPPED (hls.js@latest, line 1)
[Log] [log] > attachMedia (hls.js@latest, line 1)
[Error] The video playback was aborted due to a corruption problem or because the video used features your browser did not support
	handleVideoEvent (hls-demo.js:836)
[Log] [log] > level 2 loaded [0,443],duration:888 (hls.js@latest, line 1, x3)
[Log] [log] > media source opened (hls.js@latest, line 1)
[Log] [log] > startLoad(-1) (hls.js@latest, line 1)
[Log] [log] > main stream:STOPPED->IDLE (hls.js@latest, line 1)
[Log] [log] > Loading 0 of [0 ,443],level 2, currentTime:-1.000,bufferEnd:-1.000 (hls.js@latest, line 1)
[Log] [log] > demuxing in webworker (hls.js@latest, line 1)
[Log] [log] > main stream:IDLE->FRAG_LOADING (hls.js@latest, line 1)
[Log] [log] > audio stream:STOPPED->STARTING (hls.js@latest, line 1)
[Log] [log] > audio stream:STARTING->WAITING_TRACK (hls.js@latest, line 1)
[Log] [log] > audio stream:WAITING_TRACK->STOPPED (hls.js@latest, line 1)
[Log] [log] > audio stream:STOPPED->STARTING (hls.js@latest, line 1)
[Log] [log] > audio stream:STARTING->WAITING_TRACK (hls.js@latest, line 1)
[Log] [log] > Loaded 0 of [0 ,443],level 2 (hls.js@latest, line 1)
[Log] [log] > Parsing 0 of [0 ,443],level 2, cc 0 (hls.js@latest, line 1)
[Log] [log] > main stream:FRAG_LOADING->PARSING (hls.js@latest, line 1)
[Log] [log] > main:discontinuity detected (hls.js@latest, line 1)
[Log] [log] > main:switch detected (hls.js@latest, line 1)
[Log] [log] > InitPTS for cc: 0 found from video track: 7500 (hls.js@latest, line 1)
[Log] [log] > main track:video,container:video/mp4,codecs[level/parsed]=[avc1.4d4015/avc1.4d4015] (hls.js@latest, line 1)
[Log] [log] > Parsed video,PTS:[0.083,2.000],DTS:[0.000/2.000],nb:48,dropped:0 (hls.js@latest, line 1)
[Log] [log] > main stream:PARSING->PARSED (hls.js@latest, line 1)
[Log] [log] > audio stream:WAITING_TRACK->IDLE (hls.js@latest, line 1)

Omar2002 avatar Aug 22 '18 12:08 Omar2002

@Omar2002 Seems to play for me in 0.11.0, can you confirm?

johnBartos avatar Aug 28 '18 22:08 johnBartos

@johnBartos it's broken on specific Safari builds we know about Safari 11.1.1 (12605.2.8) and 11.1.2 (12605.3.8.1)

on which build are you testing?

mad-gooze avatar Aug 29 '18 16:08 mad-gooze

@mad-gooze 11.1.2 (13605.3.8)

johnBartos avatar Sep 06 '18 22:09 johnBartos

@mad-gooze 11.1.2 (13605.3.8)

@johnBartos it's broken on 12605.3.8.1 Not on 13605.3.8

Omar2002 avatar Sep 07 '18 17:09 Omar2002

@Omar2002 Would updating your browser be a viable solution to this bug? I'm not sure if I can downgrade (and therefore find & fix your problem)

johnBartos avatar Sep 07 '18 18:09 johnBartos

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 Nov 06 '18 19:11 stale[bot]

@johnBartos - this issue seems to persist. After few seconds of playing the video, hls.js throws this error and stops the video from playing.

[Error] InvalidStateError: The object is in an invalid state.
	onSBUpdateEnd ([email protected]:1:175808)
	(anonymous function)
[Error] InvalidStateError: The object is in an invalid state.
	_checkBuffer ([email protected]:1:98827)
	doTick ([email protected]:1:79729)
	tick ([email protected]:1:52654)
	(anonymous function)

nutank avatar Aug 08 '19 16:08 nutank

I can't repro this on my machine with Safari 12.1.2 and 12.1.2, but In my app logs I also see a lot of this, maybe this helps somehow:

InvalidStateError
The object is in an invalid state.
./node_modules/hls.js/dist/hls.js in this at line 3096:0

and

InvalidStateError: The object is in an invalid state.
  at _checkBuffer(./node_modules/hls.js/dist/hls.js:6826:0)
  at doTick(./node_modules/hls.js/dist/hls.js:5772:0)
  at this(./node_modules/hls.js/dist/hls.js:15106:0)

^ all Safari from Mac, top is: 8.73% | Safari 10.1.2 25.30% | Safari 11.1.2 5.14% | Safari 12.1.1 46.11% | Safari 12.1.2 + also one lucky user on Ubuntu + Firefox 44.0

this says that this is reproducible on all Safari clients, percentage is only correlated with how users update their browsers

hls version is: 0.12.4

I'm not familiar with codebase, both stacks point to something similar: L3096: sourceBuffer[streamType].buffered; L6826: mediaBuffer.buffered

nemtsv avatar Aug 22 '19 07:08 nemtsv

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 09:10 stale[bot]

ping

mad-gooze avatar Oct 21 '19 15:10 mad-gooze

Same issue here

ghost avatar Nov 25 '19 11:11 ghost

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 Jan 24 '20 12:01 stale[bot]

no update? Has anyone solve this issue?

wenzelua avatar Oct 11 '22 07:10 wenzelua