Skip to content

onPollWindow_: use startTime when currentTime is not ready yet (fixes #2848)#2849

Merged
joeyparrish merged 1 commit intoshaka-project:masterfrom
nangutv:bug-2848-availability-window
Sep 21, 2020
Merged

onPollWindow_: use startTime when currentTime is not ready yet (fixes #2848)#2849
joeyparrish merged 1 commit intoshaka-project:masterfrom
nangutv:bug-2848-availability-window

Conversation

@JakubRimal
Copy link
Contributor

There is a race condition: it could happen that onPollWindow_ checks falling outside the availability window before videoElement returns the currentTime correctly (it returns 0 instead) so the following calculation leads to incorrect jump forward. Now it will use this.videoWrapper_.getTime() which returns startTime in that case instead.

@google-cla
Copy link

google-cla bot commented Sep 15, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@JakubRimal JakubRimal force-pushed the bug-2848-availability-window branch from d9fc7d7 to ebdea3e Compare September 15, 2020 08:17
@JakubRimal
Copy link
Contributor Author

@googlebot I fixed it.

@joeyparrish
Copy link
Member

@JakubRimal, thanks! Is there a particular issue associated with this fix? Do all the tests still pass?

@joeyparrish
Copy link
Member

Doh, it's there in the title. I overlooked it!

@JakubRimal
Copy link
Contributor Author

Do all the tests still pass?

./build/all.py – yes
./build/test.py – actually it does not pass because it does not pass even without my commit but the result (please see the following output) is completely the same for the last commit from master (67a49d4) and for my comit (ebdea3e) which means my commit did not break it.

[WARNING] Using default browsers: ['Chrome', 'Firefox']
[INFO] Generating Closure dependencies...
[INFO] Compiling the library (ui, release)...
[WARNING] No changes detected, skipping. Use --force to override.
[INFO] Running test (1 / 1, 0 failed so far)...
Chrome 85.0.4183.83 (Fedora 0.0.0) CastUtils serialize/deserialize TimeRanges deserialize into equivalent objects FAILED
    Error: Failed: Type negotiation should happen before MediaSourceEngine.init!
        at <Jasmine>
        at Function.jasmineAssert (test/test/boot.js:38:7 <- test/test/boot.js:41:7)
        at _loop (lib/media/media_source_engine.js:296:20 <- lib/media/media_source_engine.js:7145:32)
        at _class._callee2$ (lib/media/media_source_engine.js:294:53 <- lib/media/media_source_engine.js:7197:19)
        at tryCatch (node_modules/babel-polyfill/dist/polyfill.js:6900:40)
    NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp4; codecs="avc1.42c01e"') is unsupported.
    error properties: Object({ INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25, code: 9 })
    Error: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp4; codecs="avc1.42c01e"') is unsupported.
        at _loop (lib/media/media_source_engine.js:311:48 <- lib/media/media_source_engine.js:7168:85)
        at _class._callee2$ (lib/media/media_source_engine.js:294:53 <- lib/media/media_source_engine.js:7197:19)
        at tryCatch (node_modules/babel-polyfill/dist/polyfill.js:6900:40)
        at Generator.invoke [as _invoke] (node_modules/babel-polyfill/dist/polyfill.js:7138:22)
        at Generator.prototype.<computed> [as next] (node_modules/babel-polyfill/dist/polyfill.js:6952:21)
        at step (lib/media/media_source_engine.js:6705:191)
        at lib/media/media_source_engine.js:6705:361
    Error: Expected 0 to be greater than 0.
        at <Jasmine>
        at UserContext.<anonymous> (test/cast/cast_utils_unit.js:251:33 <- test/cast/cast_utils_unit.js:363:33)
        at <Jasmine>
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls overflow menu allows picture-in-picture only when the content has video FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls resolutions menu clears the buffer when changing resolutions FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls resolutions menu displays resolutions based on current stream FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) CastReceiver sends update messages every stage of loading FAILED
        [object Object] thrown
Chrome 85.0.4183.83 (Fedora 0.0.0) ERROR
  An error was thrown in afterAll
  Failed: Unhandled rejection in Promise: shaka.util.Error {
    "severity": 2,
    "category": 4,
    "code": 4032,
    "data": [],
    "handled": false,
    "message": "Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()"
  }
  Error: Failed: Unhandled rejection in Promise: shaka.util.Error {
    "severity": 2,
    "category": 4,
    "code": 4032,
    "data": [],
    "handled": false,
    "message": "Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()"
  }
      at <Jasmine>
      at test/test/boot.js:56:5 <- test/test/boot.js:59:5
Chrome 85.0.4183.83 (Fedora 0.0.0) ERROR
  Disconnected, because no message in 300000 ms.
Chrome 85.0.4183.83 (Fedora 0.0.0) CastUtils serialize/deserialize TimeRanges deserialize into equivalent objects FAILED
        Error: Failed: Type negotiation should happen before MediaSourceEngine.init!
            at <Jasmine>
        at Function.jasmineAssert (test/test/boot.js:38:7 <- test/test/boot.js:41:7)
        at _loop (lib/media/media_source_engine.js:296:20 <- lib/media/media_source_engine.js:7145:32)
        at _class._callee2$ (lib/media/media_source_engine.js:294:53 <- lib/media/media_source_engine.js:7197:19)
        at tryCatch (node_modules/babel-polyfill/dist/polyfill.js:6900:40)
    NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp4; codecs="avc1.42c01e"') is unsupported.
    error properties: Object({ INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25, code: 9 })
    Error: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp4; codecs="avc1.42c01e"') is unsupported.
        at _loop (lib/media/media_source_engine.js:311:48 <- lib/media/media_source_engine.js:7168:85)
        at _class._callee2$ (lib/media/media_source_engine.js:294:53 <- lib/media/media_source_engine.js:7197:19)
        at tryCatch (node_modules/babel-polyfill/dist/polyfill.js:6900:40)
        at Generator.invoke [as _invoke] (node_modules/babel-polyfill/dist/polyfill.js:7138:22)
        at Generator.prototype.<computed> [as next] (node_modules/babel-polyfill/dist/polyfill.js:6952:21)
        at step (lib/media/media_source_engine.js:6705:191)
        at lib/media/media_source_engine.js:6705:361
    Error: Expected 0 to be greater than 0.
        at <Jasmine>
        at UserContext.<anonymous> (test/cast/cast_utils_unit.js:251:33 <- test/cast/cast_utils_unit.js:363:33)
        at <Jasmine>
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls overflow menu allows picture-in-picture only when the content has video FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls resolutions menu clears the buffer when changing resolutions FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) UI controls resolutions menu displays resolutions based on current stream FAILED
        Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()
Chrome 85.0.4183.83 (Fedora 0.0.0) CastReceiver sends update messages every stage of loading FAILED
        [object Object] thrown
Chrome 85.0.4183.83 (Fedora 0.0.0) ERROR
  An error was thrown in afterAll
  Failed: Unhandled rejection in Promise: shaka.util.Error {
    "severity": 2,
    "category": 4,
    "code": 4032,
    "data": [],
    "handled": false,
    "message": "Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()"
  }
  Error: Failed: Unhandled rejection in Promise: shaka.util.Error {
    "severity": 2,
    "category": 4,
    "code": 4032,
    "data": [],
    "handled": false,
    "message": "Shaka Error MANIFEST.CONTENT_UNSUPPORTED_BY_BROWSER ()"
  }
      at <Jasmine>
      at test/test/boot.js:56:5 <- test/test/boot.js:59:5
Chrome 85.0.4183.83 (Fedora 0.0.0): Executed 1744 of 1988 (5 FAILED) (skipped 30) ERROR (24.181 secs / 21.252 secs)
Firefox 80.0 (Fedora 0.0.0): Executed 1905 of 1988 (skipped 83) SUCCESS (6 mins 3.424 secs / 5 mins 58.52 secs)
Chrome 85.0.4183.83 (Fedora 0.0.0): Executed 1744 of 1988 (5 FAILED) (skipped 30) ERROR (24.181 secs / 21.252 secs)
[INFO] Run complete
[INFO] Result (exit code): 1

@joeyparrish
Copy link
Member

Those test failures are concerning because we don't see the same failures. I would be interested to find out what is different about your environment so that we could improve our tests. Can you please file a new issue about that so that we can discuss?

My only concern with your PR is that I would prefer to have a regression test or conformance rule (see build/conformance.textproto) to make sure we don't make this mistake again in the future. Looking at the code, thought, I'm not sure if we can use a conformance rule for this, given that SrcEqualsPlayhead in the same file needs to use mediaElement_.currentTime, as there is nothing else in that context. So I think a regression test would be best.

@shaka-bot
Copy link
Collaborator

All tests passed!

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go ahead and submit this, then follow up with a regression test myself. I think it can be done fairly easily in the Playhead unit tests. Thanks!

@JakubRimal
Copy link
Contributor Author

Those test failures are concerning because we don't see the same failures. I would be interested to find out what is different about your environment so that we could improve our tests. Can you please file a new issue about that so that we can discuss?

Yes, please see #2865

I will go ahead and submit this, then follow up with a regression test myself. I think it can be done fairly easily in the Playhead unit tests. Thanks!

Thank you very much, I was going to write you that I am afraid that I am not familiar with tests enough to be able to write it for this scenario so I am happy to hear that you'll do it and that it could be "fairly easily". 🙂

shaka-bot pushed a commit that referenced this pull request Sep 22, 2020
PR #2849 landed without a regression test.  The test is a bit tricky,
since it requires us to simulate a very odd set of circumstances which
nonetheless occur on smart TVs.

The video must be:
 - in a HAVE_METADATA state
 - unpaused
 - with currentTime set to 0
 - with the initial seek ignored by the platform

Furthermore, we want to suppress the seek retry behavior of the
VideoWrapper class, since that makes it more difficult to detect the
seek-range-related seeks in the original bug.  This involves access to
private members, which means we need to suppress access controls in
the compiler during part of the test.

Issue #2848
Issue #2748
PR #2849

Change-Id: I0427d4b6b4161cd2a147a5c297dfaf9b424c92b7
@joeyparrish
Copy link
Member

The regression test was added in d20b9f0 if you are interested to see how it works. "Easy" is relative, I suppose. It required us to emulate a very specific scenario and then suppress some other internal mechanisms to more easily measure the effect of the bug.

matEhickey pushed a commit to matEhickey/shaka-player that referenced this pull request Sep 25, 2020
…ject#2849)

Up until we load some content and seek to the start time, we should avoid applying the seek range.  Otherwise, for a slow-loading live stream, we could end up seeking to the beginning of the seek range while waiting to begin playback at the end of the range.  This doesn't seem to happen on desktops, but on some smart TVs, setting video.currentTime will not be immediately reflected, leaving a race condition that only VideoWrapper will properly resolve.

Closes shaka-project#2848 
Closes shaka-project#2748
matEhickey pushed a commit to matEhickey/shaka-player that referenced this pull request Sep 25, 2020
PR shaka-project#2849 landed without a regression test.  The test is a bit tricky,
since it requires us to simulate a very odd set of circumstances which
nonetheless occur on smart TVs.

The video must be:
 - in a HAVE_METADATA state
 - unpaused
 - with currentTime set to 0
 - with the initial seek ignored by the platform

Furthermore, we want to suppress the seek retry behavior of the
VideoWrapper class, since that makes it more difficult to detect the
seek-range-related seeks in the original bug.  This involves access to
private members, which means we need to suppress access controls in
the compiler during part of the test.

Issue shaka-project#2848
Issue shaka-project#2748
PR shaka-project#2849

Change-Id: I0427d4b6b4161cd2a147a5c297dfaf9b424c92b7
matEhickey pushed a commit to matEhickey/shaka-player that referenced this pull request Sep 25, 2020
…ject#2849)

Up until we load some content and seek to the start time, we should avoid applying the seek range.  Otherwise, for a slow-loading live stream, we could end up seeking to the beginning of the seek range while waiting to begin playback at the end of the range.  This doesn't seem to happen on desktops, but on some smart TVs, setting video.currentTime will not be immediately reflected, leaving a race condition that only VideoWrapper will properly resolve.

Closes shaka-project#2848 
Closes shaka-project#2748
matEhickey pushed a commit to matEhickey/shaka-player that referenced this pull request Sep 25, 2020
PR shaka-project#2849 landed without a regression test.  The test is a bit tricky,
since it requires us to simulate a very odd set of circumstances which
nonetheless occur on smart TVs.

The video must be:
 - in a HAVE_METADATA state
 - unpaused
 - with currentTime set to 0
 - with the initial seek ignored by the platform

Furthermore, we want to suppress the seek retry behavior of the
VideoWrapper class, since that makes it more difficult to detect the
seek-range-related seeks in the original bug.  This involves access to
private members, which means we need to suppress access controls in
the compiler during part of the test.

Issue shaka-project#2848
Issue shaka-project#2748
PR shaka-project#2849

Change-Id: I0427d4b6b4161cd2a147a5c297dfaf9b424c92b7
joeyparrish pushed a commit that referenced this pull request Sep 29, 2020
Up until we load some content and seek to the start time, we should avoid applying the seek range.  Otherwise, for a slow-loading live stream, we could end up seeking to the beginning of the seek range while waiting to begin playback at the end of the range.  This doesn't seem to happen on desktops, but on some smart TVs, setting video.currentTime will not be immediately reflected, leaving a race condition that only VideoWrapper will properly resolve.

Closes #2848 
Closes #2748
joeyparrish added a commit that referenced this pull request Sep 29, 2020
PR #2849 landed without a regression test.  The test is a bit tricky,
since it requires us to simulate a very odd set of circumstances which
nonetheless occur on smart TVs.

The video must be:
 - in a HAVE_METADATA state
 - unpaused
 - with currentTime set to 0
 - with the initial seek ignored by the platform

Furthermore, we want to suppress the seek retry behavior of the
VideoWrapper class, since that makes it more difficult to detect the
seek-range-related seeks in the original bug.  This involves access to
private members, which means we need to suppress access controls in
the compiler during part of the test.

Issue #2848
Issue #2748
PR #2849

Change-Id: I0427d4b6b4161cd2a147a5c297dfaf9b424c92b7
joeyparrish pushed a commit that referenced this pull request Oct 1, 2020
Up until we load some content and seek to the start time, we should avoid applying the seek range.  Otherwise, for a slow-loading live stream, we could end up seeking to the beginning of the seek range while waiting to begin playback at the end of the range.  This doesn't seem to happen on desktops, but on some smart TVs, setting video.currentTime will not be immediately reflected, leaving a race condition that only VideoWrapper will properly resolve.

Closes #2848
Closes #2748

Backported to v2.5.x

Change-Id: Id2259278ba99dfd99b17a93a94504ed0a1400238
joeyparrish added a commit that referenced this pull request Oct 1, 2020
PR #2849 landed without a regression test.  The test is a bit tricky,
since it requires us to simulate a very odd set of circumstances which
nonetheless occur on smart TVs.

The video must be:
 - in a HAVE_METADATA state
 - unpaused
 - with currentTime set to 0
 - with the initial seek ignored by the platform

Furthermore, we want to suppress the seek retry behavior of the
VideoWrapper class, since that makes it more difficult to detect the
seek-range-related seeks in the original bug.  This involves access to
private members, which means we need to suppress access controls in
the compiler during part of the test.

Issue #2848
Issue #2748
PR #2849

Backported to v2.5.x

Change-Id: I0427d4b6b4161cd2a147a5c297dfaf9b424c92b7
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: archived Archived and locked; will not be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants