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

Conversation

bwallberg
Copy link
Contributor

There's probably some closure config somewhere that would fix this but I don't know closure what so ever, this does however align more with how the rest of the code references imports.

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.

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit 9ec5cb1 into shaka-project:master Jan 11, 2021
joeyparrish pushed a commit that referenced this pull request Feb 4, 2021
Closes #3085

Backported to v2.5.x

Change-Id: I3765ecc0a5f71c8ac01ae5b64a6c0191d0d3dff0
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants