Dash.js: Failed to set 'currentTIme' property on 'HTMLMediaElement'

Created on 28 Mar 2017  路  16Comments  路  Source: Dash-Industry-Forum/dash.js

dash.js v2.4.1

composeStream calls switchStream with a seekTime of NaN.

This falls through to setCurrentTime which results in the stream failing to play, with:

"Uncaught TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite."

I've fixed this by adding

if (isNaN(seekTime)) { seekTime = 0.0; }

to StreamController.js in the onMediaSourceOpen function, just before activateStream.

I would normally submit a pull request to fix this, but your submission rules are so convoluted I simply don't have the will to do it.

Awaiting Feedback Investigate Multiperiod

Most helpful comment

@bbcrddave I'm using 2.6.0 and can reliably reproduce this. Here's what triggers it.

const dashPlayer = MediaPlayer().create();
dashPlayer.initialize(videoElement, url, falseOrTrueDoesNotMatter); 

// Then... before the streamInitialized event is fired, do either:
dashPlayer.play();
// or:
videoElement.play();

In my experience the video still plays, you're just guaranteed to get that error.

Edit: I'm using 2.6.0, not 2.6.1

All 16 comments

The obvious question this raises is what is causing seek time to be NaN? That doesn't sound like the right behaviour.

Other questions:
Does it happen in 2.4.1?
Does it happen in the reference player?
Can you share an MPD showing the problem?

It really helps if you fill in the issue template.

Sorry, yes, I meant 2.4.1. I'm not filling out any template, I don't have time.

composeStream sets NaN explicitly..

switchStream(null, streams[0], NaN);

This isn't a troubleshooting ticket, I've already identified the issue and fixed it at my end, this is just for your information.

OK, thanks for the report.

FYI I can't reproduce the issue with any of our standard test vectors.

I believe it to be triggered by a race condition with streams switching during the loading process, if that helps.

Still, it's not something that really needs to be reproduced. You can see that seekTime is explicitly being set to NaN in composeStream, so it follows that you need to check for / deal with that NaN before it gets passed to currentTime on the MediaElement.

My test scenario is a single page using the videogular player. Five videos, one set to autoPlay, the autoPlay one fails on most attempts without this fix.

I can host a test page to exhibit the issue if you need it.

@TomMettam Understood but there is a lot of history here so we just want you to be very careful and not introduce regression. Your fix should be ok and I have seen this error before but very hard to repro. Just make sure multi period stuff works before and after the change. You will find test vectors in our ref player drop down. Post if you have any questions. Thanks

@AkamaiDASH - we know for a fact that MediaElement doesn't accept NaN as a valid value. I do not understand the need for bureaucracy in a simple sanity check. I don't work for this project, I've fixed it in my fork, if you want to fix it in this repo then that's up to you.

Adding this simple sanity check will mask the issue you are seeing but doesn't get to the bottom of why the actual correct seek time is not calculated in all cases - this may well be a race condition as you suggest.

0 will not always be a suitable value to seek to: it will certainly break multi-period content. Try playing http://dash.edgesuite.net/dash264/TestCases/5a/1/manifest.mpd with your fix applied: it will fail to play after 3m08s.

We know that something about your use case is causing this - no one else has reported this issue and it is not possible to reproduce it with our usual test vectors - so it would be really useful if you did host that test page and hopefully someone will be able to take a look.

@TomMettam No need for the last comment. No one said we think that it is OK to pass NaN to MediaElement. What I am saying is same as Dave. Seems like a bandaid and we have had LOTS of regression around this area so we wanted to understand it more. Thanks for the info PR it or not. We will fix it properly one way or the other.

No problem, leave it unfixed, it doesn't harm me.

@bbcrddave I'm using 2.6.0 and can reliably reproduce this. Here's what triggers it.

const dashPlayer = MediaPlayer().create();
dashPlayer.initialize(videoElement, url, falseOrTrueDoesNotMatter); 

// Then... before the streamInitialized event is fired, do either:
dashPlayer.play();
// or:
videoElement.play();

In my experience the video still plays, you're just guaranteed to get that error.

Edit: I'm using 2.6.0, not 2.6.1

Great stuff! @epiclabsDASH ^^

Hi @dpieri,

Do you need to use a specific browser to reproduce the issue with those lines? I right created a test following your instructions (https://codepen.io/jeoliva/pen/JrwpNP) and I don't see any error.

I will continue testing this and the solution proposed.

Hi @epiclabsDASH. Thanks for the quick response. I played around with that test you created and can't make it reproduce the issue. It must be something more specific to our usage that is causing it.

Does this console log help? (Notice the NaN)

[16] No supported version of EME detected on this user agent! - Attempts to play encrypted content will fail! 
Debug.js:143 [24] Playback Initialized 
Debug.js:143 [26] [dash.js 2.6.0] MediaPlayer has been initialized 
Debug.js:143 [144] Parsing complete: ( xml2json: 5.32ms, objectiron: 0.575ms, total: 0.00590s) 
Debug.js:143 [176] MediaSource attached to element.  Waiting on open... 
Debug.js:143 [177] Manifest has been refreshed at Wed Oct 18 2017 13:31:13 GMT-0700 (PDT)[1508358673.296]  

** This is where player.play() happens **

Debug.js:143 [208] Native video element event: play 
Debug.js:143 [249] MediaSource is open! 
Debug.js:143 [250] Duration successfully set to: 15.3 
Debug.js:143 [251] Added 0 inline events 
Debug.js:143 [254] video codec: video/mp4;codecs="avc1.4d401e" 
Debug.js:143 [266] Schedule controller stopping for video 
Debug.js:143 [274] Perform SIDX load: https://d27s23f0mgeecn.cloudfront.net/0000000-manual-uploads/Flightpath-2/1.2.mp4 
Debug.js:143 [276] Perform SIDX load: https://d27s23f0mgeecn.cloudfront.net/0000000-manual-uploads/Flightpath-2/2.4.mp4 
Debug.js:143 [281] Perform SIDX load: https://d27s23f0mgeecn.cloudfront.net/0000000-manual-uploads/Flightpath-2/4.8.mp4 
Debug.js:143 [282] No audio data. 
Debug.js:143 [283] No text data. 
Debug.js:143 [283] No fragmentedText data. 
Debug.js:143 [283] No embeddedText data. 
Debug.js:143 [283] No muxed data. 
Debug.js:143 [286] Requesting seek to time: NaN
Debug.js:143 [287] Start Event Controller 
Debug.js:143 [492] Parsing segments from SIDX. 
Debug.js:143 [595] Parsing segments from SIDX. 
Debug.js:143 [601] Parsing segments from SIDX. 
Debug.js:143 [602] AbrController (video) switch from 0 to 2/2 (buffer: 0)
undefined 
Debug.js:143 [604] Schedule controller starting for video 
Debug.js:143 [609] Top qualityvideo index has changed from undefined to 2 
Debug.js:143 [618] AbrController (video) stay on 2/2 (buffer: 0) 
Debug.js:143 [619] ScheduleController - getNextFragment 
Debug.js:143 [620] ScheduleController - quality has changed, get init request 
Debug.js:143 [634] Init fragment finished loading saving to video's init cache 
Debug.js:143 [642] Native video element event: loadedmetadata 
Debug.js:143 [643] AbrController (video) stay on 2/2 (buffer: 0) 
Debug.js:143 [644] ScheduleController - getNextFragment 
Debug.js:143 [645] Getting the request for video time : 0 
Debug.js:143 [648] SegmentBase: 0 / 15.3 
Debug.js:143 [650] ScheduleController - getNextFragment - request is https://d27s23f0mgeecn.cloudfront.net/0000000-manual-uploads/Flightpath-2/4.8.mp4 

VideoModel.js:106 Uncaught TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite.
    at VideoModel.js:106
(anonymous) @ VideoModel.js:106
setTimeout (async)
setCurrentTime @ VideoModel.js:105
seek @ PlaybackController.js:151
(anonymous) @ StreamController.js:416
activateStream @ StreamController.js:417
onMediaSourceOpen @ StreamController.js:388

Debug.js:143 [755] Buffered Range for type: video : 0  -  3.999999 
Debug.js:143 [756] Got enough buffer to start. 
Debug.js:143 [759] ThroughputRule requesting switch to index:  2 type:  video Average throughput 342716 kbps 

@dpieri Can you reproduce this error in in the latest nightly build?
http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html

@dsilhavy unfortunately I don't have access to the codebase where I was using dash.js and encountered this issue anymore.

Ok then I will close this for now please reopen if you encounter it again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

herrsiim picture herrsiim  路  3Comments

fvalleeHbbTV picture fvalleeHbbTV  路  3Comments

bbert picture bbert  路  5Comments

tony1377 picture tony1377  路  3Comments

mihaiav picture mihaiav  路  5Comments