Commit Graph

1330 Commits

Author SHA1 Message Date
michellezhuo dc32bd88ba Remove extra text track generated by SimpleTextDisplayer in src= mode
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
2020-05-01 16:48:04 +00:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
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
2020-04-30 19:32:30 -07:00
Joey Parrish ba4f1d5468 Fix type info for StreamingEngine test fakes
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
2020-04-30 19:32:30 -07:00
Álvaro Velad Galván 71b129977c Parse HLS CHARACTERISTICS attribute (#2534)
Resolves #1598
2020-04-30 14:57:20 -07:00
Joey Parrish 11f3347a48 Fix static method aliases
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
2020-04-30 19:28:53 +00:00
Álvaro Velad Galván 6e7b9c363f Add liveLatency to stats (only MSE) (#2508)
Resolves #1872
2020-04-30 12:25:29 -07:00
Joey Parrish a65ef9983b Remove partial exports, broken in new compiler
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
2020-04-30 17:30:36 +00:00
Joey Parrish 286ff17361 Fix getPlayheadTimeAsDate while loading/buffering
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
2020-04-30 16:22:34 +00:00
Joey Parrish 4eefaa44cb Correct type info in tests
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
2020-04-30 16:00:17 +00:00
Joey Parrish 7ee124c2c1 Fix SegmentIndex usage and nullability in tests
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
2020-04-30 16:00:08 +00:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
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
2020-04-30 16:00:00 +00:00
Joey Parrish f15f371d20 Fix issues with nullability of strings
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
2020-04-29 22:40:49 +00:00
Joey Parrish c5b292a84e Fix cue types in tests
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
2020-04-29 22:16:47 +00:00
Joey Parrish 8200751759 Add type info for test scheme metadata types
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
2020-04-29 21:38:31 +00:00
Joey Parrish 41fd008bd3 Fix CannedIDB params
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
2020-04-29 21:15:54 +00:00
Joey Parrish df213d8c1d Fix usage of Storage API in tests
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
2020-04-29 21:08:40 +00:00
Joey Parrish fdf7bbd74c Fix compiler errors in invokeSpy
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
2020-04-29 20:31:40 +00:00
Joey Parrish e70a516228 Fix implicit string-to-number conversions in tests
This was caught by a compiler upgrade.

Issue #2528

Change-Id: Iae8c495e58347b5c4184bfcec15ff9a48abe6214
2020-04-29 11:25:16 -07:00
Joey Parrish 4dc2c65578 Add type assertions for Errors
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
2020-04-29 10:11:21 -07:00
michellezhuo fb0d819f1c Verify period flattening with multiple representations of the same
resolution

Closes #2517

Change-Id: I7102153f2df83b8ad66411e709fdaf5a5a043b53
2020-04-27 18:41:04 +00:00
Theodore Abshire 087c1ba247 Allow offline downloads to be aborted.
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 #2417
Closes #1362
Issue #1301

Change-Id: I0ba102e5bf60a063f0e2f6ecd3f135445226996f
2020-04-24 20:43:54 +00:00
Álvaro Velad Galván e246855c63 Add variable substitution support to HLS parser (#2509)
Resolves #1561
2020-04-24 12:37:11 -07:00
Joey Parrish db42d7e436 Revert "Fix bogus text track in UI with src= mode"
This partially reverts commit ad3d4604, because that fix seems to have
caused #2523.

This also adds a regression test for #2523.

Reopens #2516
Closes #2523

Change-Id: If3ed5942fff029f522e24048edcb4a04e7cc30e9
2020-04-23 21:33:28 +00:00
Álvaro Velad Galván 9104c1d68e Fix metadata tracks for live server side ad streams (#2500) 2020-04-23 14:09:54 -07:00
Sandra Lokshina 8cb5001984 Replace our skip button with the IMA's default one.
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
2020-04-22 21:03:11 +00:00
Joey Parrish 023827f7f6 Fix skipping of offline tests
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
2020-04-21 15:50:12 -07:00
Joey Parrish 318ca6511f Fix test order stability with xfilterDescribe
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
2020-04-21 22:29:31 +00:00
Joey Parrish ad3d4604af Fix bogus text track in UI with src= mode
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
2020-04-21 13:26:14 -07:00
Joey Parrish 05d1db50af Fix hung storage test
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
2020-04-20 17:35:09 -07:00
michellezhuo 030147c7f4 Avoid displaying duplicate vtt cues
Closes #2497

Change-Id: Ibc4de196f500d8685244217f9a056d8b12c05f8a
2020-04-20 22:58:45 +00:00
Joey Parrish d794b6337b Fix random test execution order
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
2020-04-20 14:51:48 -07:00
Joey Parrish f0caf4067c Fix serialization of Error objects over Cast
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
2020-04-17 21:41:01 +00:00
Joey Parrish 083099b127 Cleanup DOM after text displayer tests
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
2020-04-16 17:38:08 -07:00
michellezhuo 1f30becf13 Display nested cues in SimpleTextDisplayer
Closes #2263

Change-Id: I18af70e4ff69a1d27ef462678c0c49bacb74553c
2020-04-16 18:59:44 +00:00
Joey Parrish bca35edbe5 Fix Storage integration test failures
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
2020-04-13 21:05:59 +00:00
Joey Parrish 2f6ed0eb77 Recover from timed-out Cast connection
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
2020-04-13 18:30:43 +00:00
Joey Parrish b2c4ef5cf3 Fix flaky src= integration test on IE/Edge
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
2020-04-10 17:59:44 +00:00
Álvaro Velad Galván 2807971e4e Add creationTime to offline assets (#2406) 2020-04-10 09:58:45 -07:00
Theodore Abshire a2a988d876 Allow for multiple concurrent storage operations.
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 #1432
Closes #2432

Change-Id: I51018e170fb9ab262b5c70125a03d979c8ccfb08
2020-04-10 04:33:11 +00:00
Joey Parrish ba5d062be6 Fix missing segments in offline storage
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
2020-04-09 17:40:44 -07:00
michellezhuo 734d129fcd Add Support for HLS Discontinuity
Closes #2397
Closes #1335

Change-Id: I6f540c42c72bf0ae36239b682d4016cca3981c0f
2020-04-09 14:59:42 -07:00
Joey Parrish e24fec4b08 Flatten periods
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
2020-04-09 19:22:16 +00:00
Joey Parrish 92dcc1e243 Prefer SegmentTemplate to SegmentBase in tests
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
2020-04-09 19:22:16 +00:00
Joey Parrish 6e3dfa40ba Deduplicate key IDs with Set
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
2020-04-09 19:22:16 +00:00
Joey Parrish c4a5513ca5 Rename offline StreamDB.contentType to type
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
2020-04-09 19:22:16 +00:00
Joey Parrish e8ac57f36c Move drmInfos array to Stream
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
2020-04-09 19:22:16 +00:00
Joey Parrish 5d07b5fbb7 Fix flake in high playback rate test
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
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
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
2020-04-09 19:22:16 +00:00
michellezhuo 3b52166f56 Remove support for custom DASH ContentProtection schemas
Remove manifest.dash.customScheme callback function since it's no longer used.

Closes #2356

Change-Id: I6d08fcf97cff1bf2985e7c660d74efcd767eaed9
2020-04-09 09:11:20 -07:00
Joey Parrish fe36234951 Fix buffer check in StallDetector
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
2020-04-08 21:31:10 +00:00