When SimpleTextDisplayer is constructed, a TextTrack is created,
and that cannot be removed. This introduces an extra TextTrack when the
content is played in src= mode.
This is the straight-forward solution to filter the extra TextTrack out
by the label in src= mode.
Issue #2516
Change-Id: I8c417f837e4ad2f90ec779b533c8484de9e22b11
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo. This also updates both the library and compiler
to the latest version: 20200406.
We still have a fork of the Closure Library's URI parser. The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.
Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.
Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.
A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.
The script-loader in load.js had to be updated for compatibility with
the new Closure Library. If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.
Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.
A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.
Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler. This allows us to type a
variable as a class defined elsewhere. For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player". The compiler can then type-check all uses
of it in the tests.
Closes#2528 (bad polyfill code generated by the old compiler)
Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
The StreamingEngine tests use various fakes that did not have strong
type info before. The new Closure Compiler won't allow this, and for
good reason. Cleaning up the type info exposed a few ways that we had
left out important things or failed to remove methods that are no
longer on the types we're faking.
We also had some fakes for StreamingEngine tests that were redundant
with strongly-typed fakes that already existed in shaka.test. This
deduplicates them. The fakes for StreamingEngine are now just
instances of the other fakes with specific behavior attached.
Issue #2528
Change-Id: I0da67bea462e855fcfcb1b391fe83027ffa70702
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
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 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
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
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
This partially reverts commit ad3d4604, because that fix seems to have
caused #2523.
This also adds a regression test for #2523.
Reopens#2516Closes#2523
Change-Id: If3ed5942fff029f522e24048edcb4a04e7cc30e9
According to the agreement with the IMA team, we will
no longer hide their UI during ads. Instead we will
incorporate their elements into our layout.
(Some of the elements they expose are legally required
or business critical for partners for certain types of
ads).
This change replaces our skip button with the IMA one
and tweaks our layout to make it fit better.
We are keeping our ad counter and the 'Ad X of Y'
element.
Our skip button will stay in the library, and we will
use it for other (non IMA) ad integrations.
Change-Id: I648c6c65a34607685a409a264c2a03d74cc4d461
Some tests in test/offline/storage_integration.js would manipulate
StorageMuxer to test what happens when storage is unsupported. The
support was overridden in beforeEach and restored in afterEach.
However, all of this was wrapped in filterDescribe, which shims
jasmine's methods to run support checks and abort those methods if the
support check fails. This meant that the test itself could be skipped
by filterShim onec beforeEach ran. In fact, the shim would check for
support again before running afterEach. So the cleanup in afterEach
was also skipped, leading to all future offline tests being skipped.
This, combined with the recently-fixed test bug where tests would run
in a random order, meant that in some cases, none of the storage tests
were actually running.
With the random ordering bug fixed, we were still skipping 25 tests on
the Linux version of Chrome, 19 of which were storage tests that
shouldn't have been skipped. With --random, we were sometimes
skipping 30-45 tests in the same environment. With the fix, we are
always skipping exactly 6, 3 of which are disabled for everyone and 3
of which require Widevine persistent licenses not currently available
on Linux.
Change-Id: I22f76d47b89ce52997278f5fe402af056c89f4c0
When running tests with --random --seed, the test order should be
stable. However, xfilterDescribe (the version of filterDescribe which
temporarily disables tests) was not actually defining the tests
inside, which led to a change in the order of the tests run.
This makes xfilterDescribe define the tests, but disable them all,
which makes the shuffled order with --seed stable again.
Change-Id: I382f1f719a5b9f846bcb23761cc63f96abf17759
When the non-UI TextDisplayer is constructed, it creates an extra
TextTrack that can never be removed. This leads to a bogus text track
showing up in the UI when content is played in src= mode.
This changes the TextDisplayer to disable the extra TextTrack (since
there is no API to remove it) and changes the Player to ignore
disabled TextTracks when generating a track list for src= playbacks.
Closes#2516
Change-Id: I2e651f737445049da5fa46a798a2bc0751de2822
The test was blocking a network request, then letting it continue.
However, another change that landed around the same time introduced a
request cache inside Storage. So the blocked request was cached and
shared between the test's two storage operations, leading to both
operations being blocked.
This was missed because the test order was accidentally randomized,
leading to an as-yet-unfound bug that caused this buggy storage test
to get skipped in some cases, and timeout or disconnect in others.
Fixed: 154522761
Change-Id: I657b0d4d4edb5142bd159f567e7bd2a80e1687f2
Jasmine 3+ defaults to random test order. Since we own our own boot
file, we have to explicitly disable this if we want a predictable
order. The unpredictable order has been uncovering some instability
and possible pollution between test suites lately, but before we can
address that, we need to stabilize our nightly test runs. Then, when
hunting down these instabilities, we can explicitly use --random and
log the seed we used to get consistent failures once the failure is
identified.
This behavior was introduced to Jasmine in
https://github.com/jasmine/jasmine/commit/e31db20e and we unknowingly
adopted it in Shaka Player in
https://github.com/google/shaka-player/commit/b042a819 .
Bug: 154522761
Change-Id: I1b8b7b7f4e3d64746d61f019b1bd1d928d489f1b
When the Cast receiver throws an Error or rejects a Promise with a
non-Shaka Error, we need to represent it to the sender in a reasonable
way. Otherwise, it can be very difficult to debug.
Related to the investigation of #2487
Change-Id: Ia58dd1e1e56ee93bea9afc9d368084d53c381db3
These tests added a container to the DOM which was never cleaned up.
There is no impact to Shaka Player, and no performance impact to the
tests, but we should clean up after ourselves.
I found this by running the Karma/Jasmine tests in a foreground
browser tab at http://localhost:9876/debug.html . After the tests
completed, I looked at the "Elements" panel in Chrome's dev tools.
Change-Id: Id81dddcb82b01eeb6445ddd701d2d3907c322a0d
In Change-Id If885e828b4761528e40abdbc601a11cf13849a1e, I fixed a
memory leak, but broke offline storage.
In Change-Id I88b86d250b4407cc0740d35eaf4a7ef3d5a67798, I fixed some
of the test failures, but not others. The tests passed on Chrome on
Linux, but later failed on other platforms. It is not clear why they
passed some of the time.
When I changed offline storage to keep the parser alive until after
the storage operation is complete, this broke some test assumptions.
For example, the tests assumed that overriding manifest parsing would
be sufficient to make the URI irrelevant. That is not true any more,
since the parser is created earlier in the process.
This changes the Storage integration tests to always invoke the fake
parser by using its registered MIME type, rather than relying on an
override of the parsing step.
The Storage integration tests are now passing on all supported
platforms.
Change-Id: I1ec0b186516d35156c761554ec2e610f784e254d
When a mobile device goes idle, the Cast connection can be terminated
without explicitly closing it. When this happens, the Cast session is
unusable and throws exceptions.
This changes CastSender to correctly detect and recover from such a
problem by disconnecting explicitly and dispatching an Error to the
application.
This also fixes the disconnection process so that playback can be
correctly resumed on the local device.
Closes#2446
Change-Id: I59f51a1e911199eee22693e7db4ab39855de0298
For some reason, on Edge and IE, starting this particular piece of
content at time 5 results in playback beginning at 4.9. It could be
that the number is rounded to a keyframe or something.
This changes the test to expect the start time to be within 200ms of
the requested start time.
Change-Id: I5399a1eaf8a84b57a88359db2584f043e4a11e81
In the process, this removes the in-progress flag, which should fix
issues where the storage instance can't be re-used after an error.
Closes#1432Closes#2432
Change-Id: I51018e170fb9ab262b5c70125a03d979c8ccfb08
In Change-Id If885e828b4761528e40abdbc601a11cf13849a1e, I fixed a
memory leak, but broke offline storage.
The fix for the memory leak was to release SegmentIndexes and
SegmentReferences when the DASH parser stops, but offline storage was
stopping the parser before making use of the parsed manifest.
This changes offline storage to keep the parser alive until after the
storage operation is complete.
This bug did not affect any release versions.
Change-Id: I88b86d250b4407cc0740d35eaf4a7ef3d5a67798
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods. This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player. This also makes the
Tracks stable across Periods.
Closes#1339 (flatten periods)
Closes#1698 (rapid period transitions issue)
Closes#856 (audio change causes bitrate change)
Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
In these tests, SegmentBase referred to init segments that did not
exist. In period-flattening, we will be fetching segment indexes in
advance during parsing, so these bogus init segments would be fetched
and cause an exception. Using SegmentTemplate avoids this for tests
are not concerned with SegmentBase specifically.
Issue #1339
Change-Id: I54990e95480dfbb59154fca72f12d277eca25701
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.
This changes keyIds in the manifest and offline structures from Array
to Set.
Issue #1339
Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
This brings the field name in line with the Stream objects from the
manifest types, allowing for more general processing of Stream and
StreamDB for period-flattening.
Issue #1339
Change-Id: Ic5d0e5d69a6560d475a19f5d3ecb0b1b40b8d271
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.
Issue #1339
Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
Something weird happens on some platforms (variously Chromecast, IE,
legacy Edge, and Safari) where the playhead can go past duration. To
cope with this, don't fail on timeout. If the video never got flagged
as "ended", check for the playhead to be near or past the end.
Also, wait for playback to begin before increasing the playback rate.
This improves test reliability on slow platforms like Chromecast.
Change-Id: If7d70de95b75e602853ec77ad1c285c118875db4
This removes periods from the internal manifest structure and cleans
up code and tests accordingly. This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.
Three test cases have been disabled for the moment.
Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.
Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes#892 (refactor StreamingEngine)
Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
mediaElement.buffered can never be null. If nothing is buffered,
buffered.length will be 0.
The bug has been in this file since it was created in January 2019.
This affects all v2.5.x releases up to v2.5.10.
Hopefully this will address some seeking issues on Chromecast, though
that has not yet been confirmed.
Closes#1809
Change-Id: Iccc49d299cdac9fccdafdfc2d35e5b2376cff644