We used to alias static utility methods by assigning the method itself
to a local variable. This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.
The old compiler did not understand the use of "this" in static
methods, but the new one does. And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.
When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks. However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.
The fix is to always alias the class instead of the method. The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.
Issue #2528 (compiler upgrade)
Issue #2532 (static "this")
Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
The old compiler would let us export a static method on a class
without exporting the whole class and its constructor. The new
compiler silently ignores `@export` for any methods of a non-exported
class.
This means that for the latest Closure Compiler, we must export any
class with exported static methods. In some cases, these are
non-utility classes with constructors we'd rather not export, but the
constructor is implicitly exported by exporting the class itself.
This was initially caught by the integration tests. The error wasn't
especially helpful, so I added a try/catch to loadShaka that makes the
error more apparent:
TypeError: Cannot read property 'registerParserByMime' of undefined
To make sure we do not make this mistake again, I've added a check to
the extern generator, which was already able to detect these types of
classes. I don't know a compiler-based way to do it, since the
compiler silently ignores the export annotations in these cases.
Issue #2528
Change-Id: I797c75a8098b0bb3cf837588569f878253dec2cf
Before we buffer a segment, video.currentTime will be 0, even for live
streams. So this should not be used in getPlayheadTimeAsDate().
Instead, we should use the Playhead time or the time that will be used
later once content is loaded.
Bug: 149549467
Change-Id: I585fd2364003021839bc16724f41510637489326
In many places in the tests, we used "Object" or "*" or just no type
at all for various fakes. These were all flagged by the new Closure
Compiler version we are adopting.
In some other places, we mixed up similar types or had the wrong
nullability on a type.
In still others, types were missing fields.
These issues were caught by a compiler upgrade.
Issue #2528
Change-Id: I324e0b28f7e30a4102aa26ec2c9901fa9732211b
The usage of SegmentIndex in tests was correct, but the latest Closure
Compiler is more strict about nullability. We need to add assertions
and refactor to avoid nullable numbers where a non-nullable number is
required. We also need to add assertions for the nullability of
Stream.segmentIndex after createSegmentIndex() is called.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I5615ffa27b878f86739d507f993c2b66ae8eb61a
Various issues with the nullability of number types led to various
fixes, including:
- defaulting a nullable number to 0 to avoid propagating a null value
through calculations
- adding an assertion or runtime check that something is not null
- moving an existing null check to before the calculation
- returning early on null during an iteration
- changing a nullable number to non-nullable
- defaulting to NaN instead of null
These issues were caught by a compiler upgrade.
Issue #2528
Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
The built-in externs for IndexedDB in Closure Compiler are missing
some type info. This overrides them to add what's missing.
This also tweaks type information in a few places in lib/offline/ to
match.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I97096656f53b426067219e2d4e3aa16f32b87188
Various issues with the nullability of string types led to various
fixes, including:
- adding an assertion or runtime check that something is not null
- moving an existing null check to before a calculation
- converting a test expectation into an assertion that the compiler
understands (which will still fail the test if the assertion
fails)
These issues were caught by a compiler upgrade.
Issue #2528
Change-Id: I11da091c9e7974c8bea84b3b584cbd29d1e320e2
The new Closure Compiler complains that a number|string union from a
map in MpdUtils is used in a calculation. In practice, we know that
this specific value is always a number, so we add an assertion to
satisfy the newer compiler's type checks.
Issue #2528
Change-Id: Id12de47d2dd4a12f9cc35879bee8da5ee25cdd70
The tests for shaka.ui.TextDisplayer created some Cue objects to
verify their rendering. These used string literals where they should
have been enums, and the newer compiler didn't like that. It also
complained that we had assigned a number where there should have been
a string. This fixes both issues.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: Ie3f1e79ca1ed2745f55b270e13411966940cdf62
These metadata types were never defined, and the old compiler would
allow this. The newer compiler is more strict, so this adds typedefs
for the metadata we use to generate manifests and streams for tests.
This also fixes a bug where we didn't correctly set the mimeType field
of the resulting streams.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: Id16606b5c118793ee17dcf28942bf04d0ee22ba9
We were passing an extra parameter to this.dump(), but the older
compiler version didn't understand the use of "this" in static
methods, so it didn't catch the mistake. This removes the extra
parameter.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I15fcd79dff270bde2dbb35f5da02a9c9a4173407
We recently updated the Storage API to return AbortableOperation
instead of Promise. These tests did not get updated at that time.
The runtime backward compatibility kept the tests from failing.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I05f75a5e4443b111c63d7969950777db78133626
In "Remove extraneous exports" (Change-Id
Iaf142397f31bd927bf942499a79da595f77361d5), I removed an export that
was actually required in the newer compiler. This replaces the
missing export.
Issue #2528
Change-Id: I3e9ec7085d813365dab917b4712571585d2286c8
In "Fix missing or bad type info" (Change-Id
I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5), I added a bad assertion
that failed at runtime. The placement was wrong and the type I was
asserting was too strict. This fixes both mistakes.
Issue #2528
Change-Id: I297f8c846bf13775a4a59fd43349c96cfcaf3729
The built-in externs for DOMStringList in Closure Compiler do not seem
to list it as Iterable. This overrides them to fix it.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I5a404f2502fce8fc3e956f68f6a51728d68f0654
The invokeSpy utility is meant to work around an issue where the
compiler doesn't understand that jasmine.Spy is a callable function.
That workaround needed to be updated for the newest Closure Compiler
release.
That said, it's not clear why we should need this utility at all. We
should be able to inform the compiler that this type is a callable
function. This change also adds notes about possible future cleanup
and relevant issues filed against the compiler.
Issue #2528
Change-Id: I0e9a0e9821bd9a81fcf1349aaba6039ca59dbeeb
In many places, we check error codes on shaka.util.Error. But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.
In some cases, we know that other types may also be thrown, so there
are also some runtime checks. Some of these had to be refactored to
allow the compiler to correctly infer types.
Change-Id: I053bd7e96213c689aae3889315052dd402124690
The receiver app is attached to the window so it can be debugged.
This should use square brackets, since "receiver" is not defined on
"window".
Issue #2528
Change-Id: I8e725bb8292cdcb88ffccd3bc65d6d54181affa6
The error display in the demo app contains a link to the documentation
for a given error code. We were previously abusing that object to
hold the error severity, as well. This should be stored separately in
its own member variable.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: Ie7fede5fba72e2d28d201dc3e7437eafa87dc38a
The Storage API just changed to return an AbortableOperation instead
of a Promise. The demo did not adopt this new API at the same time.
The runtime backward compatibility provided by the Storage API was
working, so the demo was not broken. But we should be using the API
as defined.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I2d427ffb0400739c5d2de17a06c5fd79de3d39b2
The demo listens for shaka.Player.ErrorEvent, but it doesn't have type
information for that type. This is because the type is defined only
in the docs, and not in the externs. There is no actual class defined
for the event types.
The extern generator should be improved to handle this, but in the
meantime, we will use square brackets.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I55fc5fcc7f391f3155c1edc712064c5091fa363e
In many places, the implicit type info was insufficient. For example,
document.createElement returns Element, but the actual return is
always a subclass of Element. In many cases, we need the compiler to
know that a specific subclass is in use, so that it can correctly
check our use of subclass-specific properties. Another common pattern
is confusion between Node and Element (which is a subclass of Node).
Almost all of the changes in the demo and UI are Element-related.
In some places, we referred to HTMLMediaElement, used in the Player
API, instead of the more specific HTMLVideoElement in use in our demo.
Since the demo uses video-specific properties, we must use the more
specific type.
Another case is the use of document.createEvent, which returns Event
according to the compiler, but in reality always returns a subclass,
like CustomEvent.
In one case in NetworkingEngine, correcting the type of an
AbortableOperation led to the discovery that we had been incorrectly
accessing a private method of that type.
In goog.Uri, there were several instances of "*" for a type, which the
newer compiler won't accept. These have all been corrected.
Finally, in some places, we had the wrong nullability on a type.
These were all caught by a compiler upgrade.
Issue #2528
Change-Id: I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5
The latest Closure Compiler initially complained about "initData" not
being a known property of "Event". Correcting the type to
MediaEncryptedEvent exposed a potential bug, which is that we were
assigning Uint8Array in some cases instead of the correct ArrayBuffer.
This fixes both the type of the event and converts the Uint8Arrays to
ArrayBuffers.
This also works around a complaint about "code" on "Error". We use
"Error" objects as look-alikes for DOMException because there is no
exposed constructor for DOMExceptions. To satisfy the compiler, we
use square brackets now to set the "code" field on these DOMException
look-alikes.
Finally, this removes the "method" field on certain Errors in the
WebKit EME polyfill. These must have been leftover from some
debugging, and are not used at all.
Issue #2528
Change-Id: I32c4617b14a30c412d5bc532ec17a46fdc1fea1a
These classes were over-idented, making formatting more challenging.
I wanted to fix this before making compiler-upgrade-related changes in
these files.
Issue #2528
Change-Id: Ic44448760161a3e724d8c92f41f07c1a0babfa72
This adds or augments type info for TextTrack, Cue, and related types.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I233e46eeaed8d6503702e181c3380d674ddbb499
This adds an annotation to suppress a bogus compiler error in
StreamingEngine. In this method, we set updateTimer to null, then
await some async operation, then check to see if it's still null. The
latest Closure Compiler thinks this is a useless check, but we know
better. The updateTimer could have been created while the async
operation was in progress.
Issue #2528
Change-Id: I9a28b7dac1d7cb8bcfd836847507454030af52c6
The latest Closure Compiler is more picky about Event types, and
complained about the use of "key" on Event. This updates the Event
types so that the compiler has the correct type info.
This also stops using "keyCode", which is deprecated, and only uses
the current "key" property, which is even supported on IE, and should
not create any compatibility issues.
Issue #2528
Change-Id: Ic565772b1cc9597e358df015a73c40ac245edd6a
The compiler is very picky about the use of the "disabled" property on
HTMLElement, since it is only defined on certain subclasses of that.
This adds a method to create a button with the correct type to satisfy
the compiler.
Issue #2528
Change-Id: I31cacd62a35acc87b245ab362dbab55d791cf34d
When CastProxy refers to a proxy object, the type is necessarily
merely "Object". This isn't specific enough for the compiler to check
access to this.videoProxy_.paused, so we convert this to use square
brackets.
Issue #2528
Change-Id: Ic51fa9fdd20b8ac494fea1e844a945fba319f3c8
These polyfills don't have the exact same type as the thing they are
polyfilling. Instead of being constructors for VTTCue (which doesn't
exist if we are using the polyfill), they are functions that return
TextTrackCue (the base class of VTTCue and the closest thing we have
on some platforms).
Because the types don't match, the latest Closure Compiler complains.
To get around this, we use square brackets.
Issue #2528
Change-Id: Ie1e3f13dc51f2145f7d3c9d510b64d9a8d7b1f64
DrmEngine is adding an extra property to MediaKeySystemConfiguration
objects, knowing that EME will ignore it. The latest Closure Compiler
won't allow this.
In the future, we should refactor DrmEngine and consider tracking this
in some other way. For now, this changes the dot to square brackets.
Issue #2528
Change-Id: I544c93dfa2534e9d62ac5ea47e20a6dc3cb79e3a
We had made some mistakes in these prefixed names. The corrections
were made after consulting both MDN and Apple's docs.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I80994569b04a14b26b3e2fbb2673992ca7e68f50
When we changed the constructors for the V2 cells with the
introduction of V5 format, these call sites didn't get updated. This
doesn't seem to be a user-facing bug, and did not affect any releases.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I77228d17631ef44a6b85a81b88054790461617bc
This is only defined on Stream, not Variant. This bug has was
introduced in PR #2332 and the v2.5.8 release and affects v2.5.8 -
v2.5.10. The corresponding feature (frameRate restrictions) has
actually never worked.
This was caught by a compiler upgrade which is still in progress.
Change-Id: I0409d9be8d3f6eb0794775ca29f28b98208bab4f
This method (shaka.util.Uint8ArrayUtils.equal) was removed between
v2.5.0 and v2.6, but could be in use by applications. This change
adds the utility method back, with a deprecation warning.
Change-Id: Ifd780759ae389e766c1889a83545cfda8969e76b
These exports are not needed by the application. Some of them may
have been added to work around the extern generator's lack of support
for partially-exported classes.
Change-Id: Iaf142397f31bd927bf942499a79da595f77361d5
In v2.5, we had some classes which were not exported, but which had
certain individual methods which were exported. This is still true in
v2.6, except that we're using ES6 classes everywhere instead of mostly
using .prototype.
The extern generator had support for exporting individual .prototype
methods, but not for exporting individual class methods (unless the
class itself was exported already).
This adds support in the extern generator for these "partially
exported" classes, to correct missing externs in preparation for the
v2.6 launch.
Change-Id: I17ef377980ce771d74fab78afe26aa36ba3cce90
For webOS TV 2020 platform, like for Tizen, key IDs should not be
transformed to big-endian UUIDs, it causes `4012
RESTRICTIONS_CANNOT_BE_MET` error.
Closes#2512
You can either abort downloads one at a time, using the
AbortableOperation interface, or you can implicitly abort them all at
once by destroying the storage instance.
Closes#2417Closes#1362
Issue #1301
Change-Id: I0ba102e5bf60a063f0e2f6ecd3f135445226996f