mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-16 16:16:40 +03:00
Fix compiled release version of supportsChunkSize.
In the code for supportsChunkSize, we test to see if a given chunk size is supported by array to string conversion by trying to perform an operation on a Uint8Array of that size without throwing an error. However, the result of that operation was only ever referenced inside an assert. Because asserts are compiled out in release builds, the result of that operation was not being used... and thus, the entire call was being compiled out. This changes the return value of the function to use the result of the operation, thus preventing it from being compiled out. This also adds a unit test that will detect this problem in the future. Closes #2433 Change-Id: If3048531afc460beb16de0dda7f7fcbd5499fdaf
This commit is contained in:
@@ -201,6 +201,15 @@ shaka.util.StringUtils = class {
|
||||
static fromCharCode(array) {
|
||||
return shaka.util.StringUtils.fromCharCodeImpl_.value()(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the fromCharCode method's implementation.
|
||||
* For debug use.
|
||||
* @export
|
||||
*/
|
||||
static resetFromCharCode() {
|
||||
shaka.util.StringUtils.fromCharCodeImpl_.reset();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -219,7 +228,7 @@ shaka.util.StringUtils.fromCharCodeImpl_ = new shaka.util.Lazy(() => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const foo = String.fromCharCode.apply(null, buffer);
|
||||
goog.asserts.assert(foo, 'Should get value');
|
||||
return true;
|
||||
return foo.length > 0; // Actually use "foo", so it's not compiled out.
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user