Closed Bug 1555197 Opened 5 years ago Closed 5 years ago

[webvtt] reuse cues' display state when the amount of displaying cue changes

Categories

(Core :: Audio/Video: Playback, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: regression)

Attachments

(5 files)

During checking track-webvtt-two-cue-layout-after-first-end.html, I found that we would recompute cues' display state when the amount of displaying cue changes, which was implemented in bug1551385.

However, when the amount of displaying cue changes, if display cues have already had the display state, which are based on the amount of displaying cue we had last time, we should reuse them to keep them on the previous position.

If we recompute their display state, they would be different from the one we had last time.

EX. Cue0 [0:2], Cue1 [1:5]

  [playing at 1s]  
*-------------------*
|        Cue1       |                  
|        Cue0       |   
*-------------------*

  [playing at 3s]  (cue0 disappears, cue1 stays in the same position)
*-------------------*
|        Cue1       |               
|                   |      
*-------------------*

Cue's display state is a DIV element with corresponding CSS style to display cue on the screen. When the cue is being displayed first time, we will compute its display state.

After that, we could reuse its state until following conditions happen.
(1) control changes : it means the rendering area changes so we should recompute cues' position.
(2) cue's hasBeenReset flag is true : it means cues' line or position property has been modified, we also need to recompute cues' position.
(3) the amount of showing cues changes : it means some cue would disappear but other cues should stay at the same place without recomputing, so we can resume their display state.

The new state includes REUSE, REUSE AND CLEAR and COMPUTE AND CLEAR, our current behavior doesn't handle `REUSE AND CLEAR, which would be implemented in next patch.

According to the spec [1] step 13, if we won't reset cues' display state, we should reuse them.

If the amount of displaying cues changes, which means some cues should disappear from the screen and some of them should still be showed, we have to clear the screen and resume displaying cues' display state.

As the amount of displaying cues might affect the computed result of cues' display state, if we recompute cues' display state in this situaion, the result would be different from the one we had last time.

For example, there are two cues, Cue0 [0:2], Cue1 [1:5]. When Cue0 disappears, Cue1 should stay in the same position.

  [playing at 1s]
*-------------------*
|        Cue1       |
|        Cue0       |
*-------------------*

  [playing at 3s] (correct)
*-------------------*
|        Cue1       |
|                   |
*-------------------*

  [playing at 3s] (incorrect)
*-------------------*
|                   |
|        Cue1       |
*-------------------*

[1] https://w3c.github.io/webvtt/#rules-for-updating-the-display-of-webvtt-text-tracks

Add and modify some log content in order to help debugging.

For track-webvtt-two-cue-layout-after-first-end.html

(1) modify cue1's start time

According to the text track cue order [1], "cues must be sorted by their start time, earliest first; then, any cues with the same start time must be sorted by their end time, latest first".

This order also decides which cue we would display first. As this test would like show cue1 at top and show another cue at bottom, we should modify cue1's start in order to put it before cue [0:3].

[1] https://html.spec.whatwg.org/multipage/media.html#text-track-cue-order

(2) listen for cue1's exit

As this cue would like to stop when the first cue ends, it should listen exit event.


For track-webvtt-two-cue-layout-after-first-end-ref.html, we should call video.play() in order to clear show-poster flag [2] and run TimeMarchesOn to show the cue.

If we didn't call it to reset the flag, we won't display any cue.

[2] https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:show-poster-flag

Attachment #9068242 - Attachment description: Bug 1555197 - part1 : introduce new state to distinguish the different situation for showing cues' display state. → Bug 1555197 - part1 : introduce new state to distinguish different situations for showing cues' display state.
Summary: Reuse cues' display state when the amount of displaying cue changes → [webvtt] reuse cues' display state when the amount of displaying cue changes
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2fd0da098622
part1 : introduce new state to distinguish different situations for showing cues' display state. r=heycam
https://hg.mozilla.org/integration/autoland/rev/c94e1169e00e
part2 : handle state `REUSE AND CLEAR`. r=heycam
https://hg.mozilla.org/integration/autoland/rev/4a93da5a440d
part3 : modify log. r=jya
https://hg.mozilla.org/integration/autoland/rev/323c42c5c377
part4 : modify wpt 'track-webvtt-two-cue-layout-after-first-end.html' and 'track-webvtt-two-cue-layout-after-first-end-ref.html'. r=jya
https://hg.mozilla.org/integration/autoland/rev/b8809dc8740c
part5 : enable wpt 'track-webvtt-two-cue-layout-after-first-end.html'. r=jya
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/17318 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Has Regression Range: --- → yes
Keywords: regression
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: