-
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
Changes from 6 commits
3630bf9
9b5d520
1879842
452865e
bdacea1
00d7421
ee43967
674ce79
5b1c417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,7 @@ import Event from '../events'; | |
import { getSelfScope } from '../utils/get-self-scope'; | ||
|
||
// see https://stackoverflow.com/a/11237259/589493 | ||
/* eslint-disable-next-line no-undef */ | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or this is what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
|
||
class Decrypter { | ||
constructor (observer, config, { removePKCS7Padding = true } = {}) { | ||
|
@@ -24,8 +21,10 @@ class Decrypter { | |
// built in decryptor expects PKCS7 padding | ||
if (removePKCS7Padding) { | ||
try { | ||
const browserCrypto = crypto || window.crypto; | ||
this.subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; | ||
const browserCrypto = global.crypto; | ||
if (browserCrypto) { | ||
this.subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; | ||
} | ||
} catch (e) {} | ||
} | ||
this.disableWebCrypto = !this.subtle; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
*/ | ||
|
||
// import Hex from '../utils/hex'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this import isn't needed we should remove it |
||
import { makeArrayFromArrayLike } from '../utils/make-array-from-array-like'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
const UINT32_MAX = Math.pow(2, 32) - 1; | ||
|
||
|
@@ -335,7 +334,13 @@ class MP4 { | |
len = data.byteLength; | ||
sps.push((len >>> 8) & 0xFF); | ||
sps.push((len & 0xFF)); | ||
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 commentThe 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 ( 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 commentThe reason will be displayed to describe this comment to others. Learn more. update: see my proposed fix further down |
||
sps = sps.concat(Array.from(data)); | ||
} else { | ||
sps = sps.concat(Array.prototype.slice.call(data)); | ||
} | ||
} | ||
|
||
// assemble the PPSs | ||
|
@@ -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 commentThe 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:
and you can use it without changes the exact same way. IE11 seems to have a bug in exporting native prototype members :) |
||
pps = pps.concat(Array.from(data)); | ||
} else { | ||
pps = pps.concat(Array.prototype.slice.call(data)); | ||
} | ||
} | ||
|
||
let avcc = MP4.box(MP4.types.avcC, new Uint8Array([ | ||
|
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