Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#3085): compiled lib not finding MimeUtils #3087

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -19,6 +19,7 @@ Alex Jones <alexedwardjones@gmail.com>
Alugha GmbH <*@alugha.com>
Alvaro Velad Galvan <alvaro.velad@mirada.tv>
Anthony Stansbridge <github@anthonystansbridge.co.uk>
Benjamin Wallberg <me@bwallberg.com>
Bonnier Broadcasting <*@bonnierbroadcasting.com>
Bryan Huh <bhh1988@gmail.com>
Code It <*@code-it.fr>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Expand Up @@ -28,6 +28,7 @@ Alvaro Velad Galvan <alvaro.velad@mirada.tv>
Andy Hochhaus <ahochhaus@samegoal.com>
Anthony Stansbridge <github@anthonystansbridge.co.uk>
Ashutosh Kumar Mukhiya <ashukm4@gmail.com>
Benjamin Wallberg <me@bwallberg.com>
Benjamin Wallberg <benjamin.wallberg@bonnierbroadcasting.com>
Boris Cupac <borisrt2309@gmail.com>
Bryan Huh <bhh1988@gmail.com>
Expand Down
5 changes: 2 additions & 3 deletions lib/dash/dash_parser.js
Expand Up @@ -651,13 +651,12 @@ shaka.dash.DashParser = class {
for (const normalSet of normalAdaptationSets) {
if (targetIds.includes(normalSet.id)) {
for (const stream of normalSet.streams) {
const MimeUtils = shaka.util.MimeUtils;
// There may be multiple trick mode streams, but we do not
// currently support that. Just choose one.
// TODO: https://github.com/google/shaka-player/issues/1528
stream.trickModeVideo = trickModeSet.streams.find((trickStream) =>
MimeUtils.getCodecBase(stream.codecs) ==
MimeUtils.getCodecBase(trickStream.codecs));
shaka.util.MimeUtils.getCodecBase(stream.codecs) ==
shaka.util.MimeUtils.getCodecBase(trickStream.codecs));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR: The fix looks good. I analyzed the apparent compiler bug, and we'll try to come up with a way to hunt for and prevent this issue in the future.

The old code should have been fine. To me, this looks like a compiler bug. But we can't directly fix the compiler, so workarounds are almost the best we can do.

I picked apart the compiled code for this section, and it looks like this with formatting:

// "k" is an iterator, "l" is the current position in the iterator
for(var l = k.next(); !l.done; h = { Yb: h.Yb, dc: h.dc }, l = k.next()) {
  h.dc = l.value;  // "stream"
  h.Yb = hd;  // MimeUtils??
  h.dc.trickModeVideo = e.streams.find(function(m) {
    // Called with "h", so "m" == "h" here.
    return function(n) {  // This is the "find" callback
      return m.Yb.a(m.dc.codecs) == m.Yb.a(n.codecs);
    }
  }(h));
}

If "hd" is MimeUtils, its methods have all been stripped as dead code:

function hd(){}

No static methods are ever assigned on "hd" in the compiled bundle. I expect that other static methods of MimeUtils have been inlined where they are used.

There may be other places where this compiler bug is affecting us. We will try to use eslint plugins or Closure compiler's conformance rules to catch other instances of this, since auditing the code base by hand is very time consuming and makes regressions too easy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With your fix, the m.Yb.a part is replaced by a single, non-namespaced function kd. (At least, in the build I just did. Your randomly-assigned names may vary.) This kd function is MimeUtils.getCodecBase, which has been hoisted out of the class it's in.

I've filed #3088 to track efforts to find more of these problems, if there are any.

}
}
}
Expand Down