mozilla / vtt.js

A JavaScript implementation of the WebVTT specification
http://dev.w3.org/html5/webvtt/
Apache License 2.0
484 stars 94 forks source link

Safari 10.1 throws Error: The provided value is non-finite #364

Open ChristiaanScheermeijer opened 7 years ago

ChristiaanScheermeijer commented 7 years ago

When using vtt.js in Safari it throws Error: The provided value is non-finite on this part cue.line = settings.get("line", "auto");.

I think this is an issue in the Safari VTTCue implementation, but I hope to find a workaround in this polyfill.

Below the stacktrace:

consumeCueSettings@http://localhost:9000/bower_components/vtt.js/lib/vtt.js:269:10
parseCue@http://localhost:9000/bower_components/vtt.js/lib/vtt.js:303:23
parse@http://localhost:9000/bower_components/vtt.js/lib/vtt.js:1268:23
johnBartos commented 7 years ago

Here's what we do in jwplayer:

var line = settings.get('line', 'auto');
if (line === 'auto' && defaults.line === -1) {
    // set numeric line number for Safari
    line = -1;
}
cue.line = line;
aligon commented 7 years ago

Here's how we worked around it:

const oldVTTCue = global.VTTCue;

try {
    global.VTTCue = VTTCue;

    parser.parse(vtt);
    parser.flush();
} finally {
    global.VTTCue = oldVTTCue;
}

The VTTCue in scope is the one from vtt.js

jsg2021 commented 7 years ago

The spec clearly allows for 'auto' :| https://w3c.github.io/webvtt/#webvtt-cue-line

Apple's native VTTCue is not spec compliant.

ChristiaanScheermeijer commented 7 years ago

Agreed, but why not solving it in the polyfill?

ChristiaanScheermeijer commented 7 years ago

Thanks, cue.position also throws this error.

jsg2021 commented 7 years ago

I added position to my PR

jsg2021 commented 7 years ago

Apparently the travis build failed with that change... :/ position wasn't 'auto'?

jsg2021 commented 7 years ago

Ugh... apparently that breaks the tests. cue.position is auto by default (in chrome & ff...in safari its 50) and I'm just using the default if set... and falling back to what was there... :/

ChristiaanScheermeijer commented 7 years ago

Im using cue.line !== "auto" ? cue.line : "auto" for line and position which seem to work. Not sure if they pass the test though.

jsg2021 commented 7 years ago

This is not really resolved yet...

jsg2021 commented 7 years ago

my PR should fix it

ChristiaanScheermeijer commented 7 years ago

Oops wrong button!

ondrejpar commented 7 years ago

Hi, is there any progress on this? Or maybe a workaround?

jsg2021 commented 7 years ago

Just waiting for the pr to be merged.

Decad commented 4 years ago

We are still getting this issue in Safari 13.0.3 (15608.3.10.1.4). Any news on the PR being merged?

gkatsev commented 4 years ago

I believe this is fixed or will soon (in the next release) be fixed in the videojs fork of vtt.js. It's probably the only currently maintained version of vtt.js: https://github.com/videojs/vtt.js (videojs-vtt.js on npm)