-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 exceptions in IE #1786
Fix exceptions in IE #1786
Conversation
#1769 could work in place of some of these commits. Understand if we'd rather hold that back for now though and get a new version out |
@tjenkinson Would like to take a closer look at that one. I think we need to get this in & cut a release asap |
src/remux/mp4-generator.js
Outdated
@@ -3,7 +3,6 @@ | |||
*/ | |||
|
|||
// import Hex from '../utils/hex'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this import isn't needed we should remove it
src/remux/mp4-generator.js
Outdated
sps = sps.concat(makeArrayFromArrayLike(data)); // SPS | ||
|
||
// SPS | ||
if (typeof Array.from === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what is broken in there, but: why don't you fix the util function (makeArrayFromArrayLike
)?
the way you did it here, we will have more code-size if this functionnality is needed somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: see my proposed fix further down
const window = getSelfScope(); // safeguard for code that might run both on worker and main thread | ||
|
||
const { performance, crypto } = window; | ||
const global = getSelfScope(); // safeguard for code that might run both on worker and main thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a problem on IE11, can we add a linter setting that forbids the variable name window
? it would be the way to avoid regression in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or this is what no-global-assign
does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah no-global-assign
does that
.eslintrc.js
Outdated
@@ -83,6 +83,7 @@ module.exports = { | |||
'no-irregular-whitespace': 1, | |||
'no-self-assign': 1, | |||
'new-cap': 1, | |||
'no-undefined': 1 | |||
'no-undefined': 1, | |||
'no-global-assign': 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a critical issue, you shouldn't make it a warning, but an error (2
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks. Will address
src/remux/mp4-generator.js
Outdated
@@ -344,7 +349,12 @@ class MP4 { | |||
len = data.byteLength; | |||
pps.push((len >>> 8) & 0xFF); | |||
pps.push((len & 0xFF)); | |||
pps = pps.concat(makeArrayFromArrayLike(data)); | |||
|
|||
if (typeof Array.from === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this is actually redundant code really growing the package, isn't it?
it seems more intuitive to rather fix the issue here: https://github.com/video-dev/hls.js/blob/master/src/utils/make-array-from-array-like.js#L1
if the current state doesn't work...I guess you need to change it to something like:
export function makeArrayFromArrayLike(arrayLike) {
return (typeof Array.from === 'function' ? Array.from(arrayLike) : Array.prototype.slice.call(arrayLike));
}
and you can use it without changes the exact same way.
IE11 seems to have a bug in exporting native prototype members :)
@tjenkinson let's first get this fixed based on the status quo, and after that merge your PR asap. |
src/remux/mp4-generator.js
Outdated
@@ -3,7 +3,6 @@ | |||
*/ | |||
|
|||
// import Hex from '../utils/hex'; | |||
import { makeArrayFromArrayLike } from '../utils/make-array-from-array-like'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you wanted to remove it, we should have deleted the module as well. but imo we should definitely keep it.
@johnBartos it seems you fixed this without completely understanding what the issue was :) i hope my suggestion may help! |
@tchakabam Ah looks like I reverted the wrong commit. Will fix |
@tchakabam Fixed. That's what I get for rushing 😅 |
@johnBartos Awesome work! Also I need to admit that I found out: This util function was a wrong thing to do in the first place the way it was done. One can't export a Sorry, my bad :/ |
or something like this would have worked: |
This PR will...
Array.from
changesWhy is this Pull Request needed?
Array.from
changes cause IE to fail with an unhandled exception:These changes are not valuable so they have been reverted.
Makes it a bit easier to debug when the
all exceptions
flag does not get triggered due to a caught exception.It is a bad practice to reassign globals.
Are there any points in the code the reviewer needs to double check?
I don't think so. I did a spot check on IE/Edge/Chrome/FF and everything looks fine.
Resolves issues:
Reported via video-dev slack
Checklist