Closed Bug 1488673 Opened 6 years ago Closed 5 years ago

[webvtt] HTML5 Video track/subtitles do not scale when using css transform scale on parent elements

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: michael.jo.kling, Assigned: alwu)

References

(Blocks 2 open bugs)

Details

Attachments

(12 files, 2 obsolete files)

1.00 MB, application/x-zip-compressed
Details
387.95 KB, image/png
Details
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Steps to reproduce:

A video with track (subtitles) is placed in an html element which is transformed via css transform:scale.





Actual results:

The subtitles do scale in size, but their position is off. For scale < 1 the subtitles are getting into the video, for scale > 1 subtitles are even displayed outside of the video. 


Expected results:

The subtitles do scale together with the video and stay at the same relative position.
Picture showing the issue.
Blocks: webvtt
Status: UNCONFIRMED → NEW
Component: Untriaged → Audio/Video: Playback
Ever confirmed: true
Product: Firefox → Core
Version: 61 Branch → Trunk
It looks like the transform is being applied twice.
Priority: -- → P2
See Also: → 1451747

Is there an update on this bug? Will it be fixed anytime soon?

I can reproduce this issue on Nightly 67.0a1 (2019-02-06), OSX 10.13.5.

I'm going to take a look for this bug, but it might take some time.

Assignee: nobody → alwu
Summary: HTML5 Video track/subtitles do not scale when using css transform scale on parent elements → [webvtt] HTML5 Video track/subtitles do not scale when using css transform scale on parent elements

Follow the spec 7.2.10 to adjust cue's position.

Depends on: 1277437

When calculating font size, we should use the original bounding box as a reference, or it would cause incorrect font size scale.

Attachment #9043484 - Attachment description: Bug 1488673 - part2 : remove unused functions. → Bug 1488673 - part3 : remove unused functions and variable.

In order to keep the local variable only visible inside the function scope, we should only use 'let' for those variables.

These wpt tests are using the wrong ref html which always assume the cue should be on the bottom of the video element.

However, according to the spec, the result of cue's position is calulated by rendering area and it won't always be on the bottom of the video.

It's anoying that the result of wpt reftest is not very stable, last time when I pushed my patches to try server, some certain tests would only pass on Windows so that I had to disable them on other platforms.

However, I pushed my patches to try server again today, those tests are magically pass...

Bounding box would be affected by CSS transformation, using its width and height would result in calculating the incorrect position.

Therefore, we should always use non-transformed attributes for its width, height, top and left, and then we can use those properties to get the correct right and bottom.

Attachment #9043483 - Attachment description: Bug 1488673 - part1 : adjust cue's position by following the latest spec. → Bug 1488673 - part3 : adjust cue's position.

According to the spec 7.2.10 [1], the step13 to step21 (snap-to-line is true) and the step3 to step5 (snap-to-line is false), we need to find the best position where the cue box has least overlap with other cue boxes.

In addition, in order not to be affected by CSS transformation, use non-tranformed attribute in BoxPosition.

[1]
https://w3c.github.io/webvtt/#ref-for-webvtt-cue-snap-to-lines-flag-12
https://w3c.github.io/webvtt/#ref-for-webvtt-cue-snap-to-lines-flag-13

Attachment #9043484 - Attachment description: Bug 1488673 - part3 : remove unused functions and variable. → Bug 1488673 - part5 : remove unused functions.
Attachment #9044344 - Attachment description: Bug 1488673 - part4 : huge replacement of 'var' by 'let'. → Bug 1488673 - part6 : huge replacement of 'var' by 'let'.
Attachment #9044345 - Attachment description: Bug 1488673 - part5 : remove unnecessary anonymous function. → Bug 1488673 - part7 : remove unnecessary anonymous function.
Attachment #9044346 - Attachment description: Bug 1488673 - part6 : disable vtt wpt rendering tests. → Bug 1488673 - part8 : disable vtt wpt rendering tests.
Attachment #9045811 - Attachment is obsolete: true
Attachment #9045811 - Attachment is obsolete: false
Attachment #9045811 - Attachment description: Bug 1488673 - part7 : enable wpt tests. → Bug 1488673 - part9 : enable wpt 'line_1_wrapped_cue_grow_downwards.html'.
Attachment #9049307 - Attachment description: Bug 1488673 - part1 : always use non-transformed attributes in 'getSimpleBox()'. → Bug 1488673 - part1 : always use non-transformed attributes in 'getSimpleBoxPosition()'.
Attachment #9045811 - Attachment is obsolete: true
Blocks: 1305732

According to the spec [1], we have calculated the size in step 7.3 and then we should use that for calculating x-position and y-position, instead of using cue's size.

[1] https://w3c.github.io/webvtt/#apply-webvtt-cue-settings

Attachment #9049307 - Attachment is obsolete: true

It's confused that we have both simpleBoxPosition object and BoxPosition object, we should only use one format to perform all box related operations.

Therefore, BoxPosition should be able to be initiaized by StyleBox, HTMLElement or BoxPosition.

In addition, as right and bottom can be calculated from other attributes, we remove these two attributes from BoxPosition, and use getter to get the correct value, which can reduce some unnessary modification when we changes the height or width.

Attachment #9043483 - Attachment description: Bug 1488673 - part3 : adjust cue's position. → Bug 1488673 - part4 : adjust cue's position.
Attachment #9049308 - Attachment description: Bug 1488673 - part4 : find the best position for the cue box in order not to overlap it with other cue boxes. → Bug 1488673 - part5 : find the best position for the cue box in order not to overlap it with other cue boxes.
Attachment #9043484 - Attachment description: Bug 1488673 - part5 : remove unused functions. → Bug 1488673 - part6 : remove unused functions.
Attachment #9044344 - Attachment description: Bug 1488673 - part6 : huge replacement of 'var' by 'let'. → Bug 1488673 - part7 : huge replacement of 'var' by 'let'.
Attachment #9044345 - Attachment description: Bug 1488673 - part7 : remove unnecessary anonymous function. → Bug 1488673 - part8 : remove unnecessary anonymous function.
Attachment #9044346 - Attachment description: Bug 1488673 - part8 : disable vtt wpt rendering tests. → Bug 1488673 - part9 : disable vtt wpt rendering tests.
Blocks: 1534888
Blocks: 1534904
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ca1266e7fbad
part1 : use correct size to calculate position. r=heycam
https://hg.mozilla.org/integration/autoland/rev/9206cafa8778
part2 : keep font size consistent even if applying CSS transform scale on the parent element r=heycam
https://hg.mozilla.org/integration/autoland/rev/e5030bf46846
part3 : only use BoxPosition format for position calculation r=heycam
https://hg.mozilla.org/integration/autoland/rev/d18858a1fe8b
part4 : adjust cue's position. r=heycam
https://hg.mozilla.org/integration/autoland/rev/9fa072a4b67d
part5 : find the best position for the cue box in order not to overlap it with other cue boxes. r=heycam
https://hg.mozilla.org/integration/autoland/rev/5b3ae7eb7842
part6 : remove unused functions. r=heycam
https://hg.mozilla.org/integration/autoland/rev/f264bc709b32
part7 : huge replacement of 'var' by 'let'. r=heycam
https://hg.mozilla.org/integration/autoland/rev/b7cea852fc6b
part8 : remove unnecessary anonymous function. r=heycam
https://hg.mozilla.org/integration/autoland/rev/faa494b301b9
part9 : disable vtt wpt rendering tests. r=heycam
https://hg.mozilla.org/integration/autoland/rev/58bd4444d2c5
part10 : enable wpt tests. r=heycam
Backout by shindli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2e3d01a1b848
Backed out 10 changesets for permafailing wpt tests in  /html/semantics/embedded-content/media-elements/track/track-element/track-cue-rendering-line-doesnt-fit.html CLOSED TREE

Can we fix the WPT tests instead of disabling them pretty please?

Can we fix the WPT tests instead of disabling them pretty please?

These patches are the basic alogirithm which is used to render cue, so I don't want those fail tests blocking it. In addition, this module hasn't been maintained for a while, so there are still some other problems need to be fixed. I've filed another bug1534862, which is used to investigate the fail reason of each wpt test and then enable them.

Flags: needinfo?(alwu)
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/93cb5631f24b
part1 : use correct size to calculate position. r=heycam
https://hg.mozilla.org/integration/autoland/rev/367a2a68fb2d
part2 : keep font size consistent even if applying CSS transform scale on the parent element r=heycam
https://hg.mozilla.org/integration/autoland/rev/e89cf185fc33
part3 : only use BoxPosition format for position calculation r=heycam
https://hg.mozilla.org/integration/autoland/rev/9e2f80f5ec79
part4 : adjust cue's position. r=heycam
https://hg.mozilla.org/integration/autoland/rev/a1841a4aa3f1
part5 : find the best position for the cue box in order not to overlap it with other cue boxes. r=heycam
https://hg.mozilla.org/integration/autoland/rev/3f6a9b725f21
part6 : remove unused functions. r=heycam
https://hg.mozilla.org/integration/autoland/rev/5934ef641056
part7 : huge replacement of 'var' by 'let'. r=heycam
https://hg.mozilla.org/integration/autoland/rev/c2aad16bf544
part8 : remove unnecessary anonymous function. r=heycam
https://hg.mozilla.org/integration/autoland/rev/2a0158d3e47c
part9 : disable vtt wpt rendering tests. r=heycam
https://hg.mozilla.org/integration/autoland/rev/7626a0df2e26
part10 : enable wpt tests. r=heycam

FTR even when we can't fix wpt tests right away — which itself should be considered a problem — we should never mark them as disabled, but set the expectation to FAIL, unless the test is causing instability in CI.

For those tests which were disabled, they were sometime unexpected passed when I pushed them on try server.
Now I'm investigating all intermittent fail test and those disable tests, and will reopen them later.

Regressions: 1557882
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: