fix: delay appending vtt subtitles depending on presence of discontinuity sequence and timestamp offset#9676
fix: delay appending vtt subtitles depending on presence of discontinuity sequence and timestamp offset#9676gkatsev wants to merge 6 commits intoshaka-project:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…uity sequence and timestamp offset Fixes shaka-project#9470
f542c1a to
2cb6d85
Compare
|
the PR build is failing because there's a leading space character but seems like I can't edit the PR title. |
|
@shaka-bot test |
|
@avelad: Lab tests started with arguments:
|
|
Bundle Size Report for PR #9676
|
|
Incremental code coverage: 90.77% |
|
It seems that fails in some platforms... can you review it? Thanks! |
lib/text/text_engine.js
Outdated
| return inside; | ||
| }; | ||
|
|
||
| if (!this.deferredAppends_) { |
There was a problem hiding this comment.
deferredAppends_ seems always truthy, making this condition dead code?
There was a problem hiding this comment.
Good catch! It must've stayed from an earlier version where it wasn't always set.
|
So, I think the test failures happen if the subtitles take a while to load and the second video segment ends up loading first, which changes the timestamp offset when they're parsed. During my testing previously, this is basically the same behavior as shaka had before this change. |
That sounds like a hack with a magic number... I think the ideal solution is to find the root cause and fix it. Modifying the test to wait a certain amount of time is also a solution. |
|
Oh, yeah, I didn't mean it was a solution but rather a way to reliably trigger the conditions for the test failure. I'll continue investigating this today. |
|
ok, I think the root cause is the change in media source engine where previously the promise only got reset in |
|
It seems like having the timestamp offset only get set once per discontinuity makes the tests pass. Potentially, would need a way to unset it in the case of a resync call. |
|
ok, I added a check for whether the timestamp offset should get updated or not. In my testing it seems to be working fine for both multiperiod DASH and HLS content with discontinuities. One thing to thing I noticed is that in DASH, when seeking back across a period, shaka inserts the init segment from the period we seeked away from resulting in the captions being offset. It doesn't always happen but it isn't hard to reproduce. This PR doesn't address that issue. While it may be possible to work around it on the text engine/MSE side, it might be nice to figure out why the incorrect init segments gets appended. |
lib/text/text_engine.js
Outdated
| * @param {shaka.extern.TextDisplayer} displayer | ||
| * @param {string=} manifestType | ||
| */ | ||
| constructor(displayer, manifestType = shaka.media.ManifestParser.DASH) { |
There was a problem hiding this comment.
now that the manifest type is passed here, we technically don't need to pass it in initParser below. I didn't make that change yet, but happy to do so.
|
@shaka-bot test |
|
@avelad: Lab tests started with arguments:
|
|
looks like there's stil more work for me https://github.com/shaka-project/shaka-player/actions/runs/22002953987/job/63583998586?pr=9676#step:13:365 😭 |
|
running the test locally in safari via karma's debug page seems to pass. It's off by exactly the first timestamp offset still. |
|
I can reproduce when running karma on safari directly, so, I guess I'll take another look at it next week. |
| /** @private {Map<number, number>} */ | ||
| this.timestampOffsetMap_ = new Map(); | ||
| // default timestamp offset for no discontinuities to 0 | ||
| this.timestampOffsetMap_.set(-1, 0); |
There was a problem hiding this comment.
i think the root cause of the new failure is this change. While it seems to work for the most part, it means that there's a chance that we get text segments appended before a proper timestamp offset is set from the media source engine. It was initially added because a bunch of tests were failing and that worked around it. Instead, probably need to remove it and fixup the tests.
This PR changes the way that timestamp offsets are stored in the media source engine. Instead of a single value, it now has a map of values. For DASH, it should contain a single value, which is the last timestamp offset available. For HLS, it'll keep track of the timestamp offsets per discontinuity sequence. If content is appended and we don't yet have a timestamp offset for that discontinuity sequence number, it'll defer creating the cues until the timestamp offset is set, otherwise, the times for the cues may not be correct.
Fixes #9470