videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
38.1k stars 7.45k forks source link

Extra return in minified JS causing "unreachable code after return statement" #8684

Open lipupini opened 7 months ago

lipupini commented 7 months ago

Description

There appears to be an odd issue with the minification process. An extra return statement is causing "unreachable code after return statement," reported to me at video.min.js:38:146220

image

You can find it here: http://vjs.zencdn.net/8.10.0/video.min.js By searching for the string return Vl(o);return}}setDuration

I believe the specific setDuration reference is from around line 57,340 in the unminified version and perhaps it's getting mixed up in the buffered() method that comes directly before it. When I remove the extra return manually from a bundled minified version it works perfectly without error or warning.

Reduced test case

https://jsfiddle.net/7bhg3j68/

Steps to reproduce

  1. Include https://vjs.zencdn.net/8.10.0/video.min.js
  2. Load page in Firefox and check console

Errors

No response

What version of Video.js are you using?

8.10.0

Video.js plugins used.

None

What browser(s) including version(s) does this occur with?

Firefox 124

What OS(es) and version(s) does this occur with?

Linux

welcome[bot] commented 7 months ago

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

mister-ben commented 6 months ago

It's at this line, bufferIntersection in minified and inlined https://github.com/videojs/http-streaming/blob/ceb780aa8558b1bee63c94cc7991b511eda64967/src/source-updater.js#L653. It's benign in this case as it's only a return statement that is unreachable.

buffered() {
  var e = ou(this.mediaSource, this.videoBuffer) ? this.videoBuffer : null,
    t = ou(this.mediaSource, this.audioBuffer) ? this.audioBuffer : null;
  if (t && !e) return this.audioBuffered();
  if (e && !t) return this.videoBuffered();
  {
    var r = this.audioBuffered();
    var n = this.videoBuffered();
    let e = null,
      t = null,
      i = 0;
    var a = [],
      o = [];
    if (!(r && r.length && n && n.length)) return Vl();
    let s = r.length;
    for (; s--; ) a.push({ time: r.start(s), type: "start" }), a.push({ time: r.end(s), type: "end" });
    for (s = n.length; s--; ) a.push({ time: n.start(s), type: "start" }), a.push({ time: n.end(s), type: "end" });
    for (
      a.sort(function (e, t) {
        return e.time - t.time;
      }),
        s = 0;
      s < a.length;
      s++
    )
      "start" === a[s].type ? 2 === ++i && (e = a[s].time) : "end" === a[s].type && 1 === --i && (t = a[s].time), null !== e && null !== t && (o.push([e, t]), (e = null), (t = null));
    return Vl(o);
    return;
  }
}
setDuration(e, t = tu) {
  du({ type: "mediaSource", sourceUpdater: this, action: lu.duration(e), name: "duration", doneFn: t });
}
lipupini commented 6 months ago

It's benign, but does cause a warning in the console and I wonder why it would add the extra return statement

mister-ben commented 6 months ago

We need to look at switching the minifier we are using.