Skip to content

Commit

Permalink
test: Deflake demo tests (#5467)
Browse files Browse the repository at this point in the history
The demo tests occasionally timeout, in spite of being synchronous test
cases. This is because of an async teardown process between tests, which
can sometimes hang.

This may indicate some condition in which player.destroy() could hang,
though I have been unable to replicate that hypothetical condition in an
explicit unit test.

The hang goes away if we don't attach to the video element. Since the
tests don't use the video element directly or attempt to load any
content, we can just skip the video element attachment.

Another thing that appears to resolve the hang is to await attach(), so
a comment has been left to warn anyone modifying the code in the future
not to use the constructor argument to attach a video element.
  • Loading branch information
joeyparrish authored Aug 8, 2023
1 parent f010535 commit b4dbb28
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/test/util/fake_demo_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
*/
shaka.test.FakeDemoMain = class {
constructor() {
this.video = /** @type {!HTMLVideoElement} */ (
document.createElement('video'));
this.player = new shaka.Player(this.video);
// Using the player's constructor argument to attach a video element seems
// to cause flaky timeouts on teardown. If a video element is needed in
// the future, please explicitly call attach(video) and await the result
// during the test setup.
/** @type {!shaka.Player} */
this.player = new shaka.Player();

this.config_ = this.player.getConfiguration();
this.selectedAsset = null;

Expand Down

0 comments on commit b4dbb28

Please sign in to comment.