[webvtt] Video element does not load subtitles track if initialized with preload attribute set to none
Categories
(Core :: Audio/Video: Playback, defect, P3)
Tracking
()
People
(Reporter: marek.raida, Assigned: alwu)
References
(Blocks 1 open bug)
Details
(Keywords: regression)
Attachments
(8 files)
622 bytes,
text/html
|
Details | |
1.08 KB,
text/html
|
Details | |
607 bytes,
text/html
|
Details | |
376 bytes,
text/html
|
Details | |
331 bytes,
text/html
|
Details | |
222.30 KB,
image/jpeg
|
Details | |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta-
|
Details | Review |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta-
|
Details | Review |
Reporter | ||
Comment 1•7 years ago
|
||
Reporter | ||
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Comment 3•7 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 5•5 years ago
|
||
Hey!
Some additional notes about this bug:
- With "preload=none", all subtitle tracks are loaded.
- With "preload=none", the subtitle button doesn't appear until the user starts playing the video.
I am attaching a test file. As subtitles seem to be subject to CORS restriction, I am using a fake name for the subtitles. Check in the network monitor the file is attempted to load right on load.
Comment 6•5 years ago
|
||
Comment 7•5 years ago
|
||
Same file, but with a "local" subtitle file.
Assignee | ||
Comment 8•5 years ago
|
||
Hi, Vincent,
Sorry I'm little confused right now, which test is the one you would like us to investigate?
The tests in comment6 and 7 looks good to me, I didn't see any problem.
For the test in comment6, because we didn't start loading anything, we can't know whether this video has any subtitle or not, so we won't show the caption button before playing. For the test in comment7, it seems the file was blocking by COR, and which seems reasonable.
Thank you.
Comment 9•5 years ago
|
||
For the first test, there is no need to load anything to know if there are subtitles as they are specified as tracks directly in the <video>
element with all the required infos to have a menu.
To make the second test easier to understand, I have modified it this way:
<html>
<body>
<video preload="none" controls crossorigin="anonymous">
<source src="https://thv1.uloz.to/3/a/c/3ac76bf4c0477c1919e4934c6a611c5a.240.mp4?fileId=212959490">
<track src="subtitles1.vtt" srclang="cz" label="České" kind="subtitles">
<track src="subtitles2.vtt" srclang="fr" label="français" kind="subtitles">
<track src="subtitles3.vtt" srclang="de" label="Deutsch" kind="subtitles">
<track src="subtitles4.vtt" srclang="en" label="English" kind="subtitles">
</video>
</body>
</html>
In the network monitor, I can see Firefox loading the 4 subtitle files while I didn't select any subtitle (and I can't select one before playing the video as the widget is not available yet).
As a comparison, Chromium is displaying the subtitle widget without loading the video and doesn't download a subtitle file before the user select a track.
Comment 10•5 years ago
|
||
Assignee | ||
Comment 11•5 years ago
|
||
Could you try to use latest Nightly to see if the problem still exists?
Now we won't start loading any track which mode is disabled
after landing Bug1550633, so I think those tracks won't be downloaded in this situation.
But for your another problem, showing subtitle selection in video control, it seems an enhencement for the video control, if that is your main problem, I would switch this bug to another component to which video control related bugs should belong.
Thank you.
Comment 12•5 years ago
|
||
The problem about all the subtitles being loaded is not present in the latest Nightly. So only the subtitle selector being absent with "preload=none" is a problem now.
Thanks!
Assignee | ||
Comment 13•5 years ago
|
||
I checked the comment0 again, so this bug should be used for solving the problem that the track couldn't be loaded successfully when setting preload=none
for media element.
The reason we failed to download the resource is because we use GetCORSMode()
[1] to query media element's CORS mode, which hasn't been set when setting preload=none
. It would only be set when media element starts loading resource [2].
According to the spec [3], if track element's parent is media element and then we should check media element's crossorigin
content attribute to decide the corsAttributeState
. We should directly check its crossorigin
attribue, instead of calling GetCORSMode()
.
[1] https://searchfox.org/mozilla-central/rev/c606cdd6d014fee4034da1702d484c0d41b604c9/dom/html/HTMLTrackElement.cpp#316
[2] https://searchfox.org/mozilla-central/rev/c606cdd6d014fee4034da1702d484c0d41b604c9/dom/html/HTMLMediaElement.cpp#2507
[3] https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks:attr-media-crossorigin
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 14•5 years ago
|
||
As GetCORSMode()
would only be valid after media element starts loading, so we would fail to get the CORS mode if media's preload is none
.
Therefore, according to the spec [1], we should directly check parent media element's crossorigin
attribute in order to decide the corsAttributeState
.
Assignee | ||
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
Comment 17•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/105df24836a9
https://hg.mozilla.org/mozilla-central/rev/8c4a3e9cc5ed
Comment 18•5 years ago
|
||
Is this worth considering for Beta backport ahead of the next ESR or can it ride the trains with 69?
Assignee | ||
Comment 19•5 years ago
•
|
||
Comment on attachment 9071677 [details]
Bug 1464012 - part1 : directly check media element's crossorigin attribute.
Beta/Release Uplift Approval Request
- User impact if declined: The CORS video subtitle couldn't be loaded correctly when user set video's prelod to
none
. It's a regression caused by bug 1313711. - Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: Yes
- If yes, steps to reproduce: Visit the page in comment0 to see if subtitle can be showed correctly.
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): This change is only affected on those video with preload
none
and its child track element has CORS resouce, it's not a common case. In addition, we have added an automation test for that. - String changes made/needed:
Assignee | ||
Updated•5 years ago
|
Comment 20•5 years ago
|
||
Comment on attachment 9071677 [details]
Bug 1464012 - part1 : directly check media element's crossorigin attribute.
this is a longstanding issue, for a corner case, I'd rather let it ride the trains
Updated•5 years ago
|
Updated•5 years ago
|
Comment 21•5 years ago
|
||
Alastor, thank you for fixing this. Given the lack of testing for compliance with fetch & security, I think we also need a test case for the invert, where the server does not respond with the correct CORS headers. Could you please take this as a follow-up?
Assignee | ||
Comment 22•5 years ago
|
||
Hi, I'm happy to help, but I'm not sure what kinds of test you were mentioning, because we have media test for it in patch2 already. Could you tell me more about the test you want?
Thank you.
Comment 23•5 years ago
|
||
I think he means a similar test but with the video and track looking like the below instead, such that the server doesn't respond with cors headers for the cross-origin request, and the media element shouldn't be allowed access to the vtt file.
<video preload="none" crossorigin="anonymous">
<track src="http://example.com/tests/dom/media/test/basic.vtt" kind="subtitles" id="default" default>
</video>
Comment 24•5 years ago
|
||
Thanks Andreas.
Yeah, though we want a testcase with values auto
and metadata
for the preload
attribute, don't we?
Comment 25•5 years ago
|
||
For me, it still doesn't work with the latest Nightly. Is is expected?
My test case:
<div>
<video width="480" height="201" controls preload="none" crossorigin="anonymous">
<source src="https://media.luffy.cx/videos/2019-self-hosted-videos-subtitles/progressive.mp4" type='video/mp4; codecs="avc1.4d401f, mp4a.40.2"'>
<track src="2019-self-hosted-videos-subtitles.de.vtt" kind="subtitles" srclang="de" label="Deutsch">
<track src="2019-self-hosted-videos-subtitles.en.vtt" kind="subtitles" srclang="en" label="English">
</video>
</div>
<div>
<video width="480" height="201" controls crossorigin="anonymous">
<source src="https://media.luffy.cx/videos/2019-self-hosted-videos-subtitles/progressive.mp4" type='video/mp4; codecs="avc1.4d401f, mp4a.40.2"'>
<track src="2019-self-hosted-videos-subtitles.de.vtt" kind="subtitles" srclang="de" label="Deutsch">
<track src="2019-self-hosted-videos-subtitles.en.vtt" kind="subtitles" srclang="en" label="English">
</video>
</div>
The difference between the first and second video is preload="none"
. The first video doesn't have the subtitle selection widget. The second one has it. The first video will get the subtitle selection widget when you press play. Also, the second video doesn't request the subtitles unless you select one.
Comment 26•5 years ago
|
||
Adding default
to one of the track in the first video downloads the track even with preload="none"
, but still no subtitle selection widget until we press play. So, it seems to be purely a bug with how the track selection widget is displayed.
Assignee | ||
Comment 27•5 years ago
|
||
(In reply to Vincent Bernat from comment #25)
The difference between the first and second video is
preload="none"
. The first video doesn't have the subtitle selection widget. The second one has it. The first video will get the subtitle selection widget when you press play. Also, the second video doesn't request the subtitles unless you select one.
As you didn't set any default track for the second video, none of tracks would be automatically selected.
(In reply to Vincent Bernat from comment #26)
Adding
default
to one of the track in the first video downloads the track even withpreload="none"
, but still no subtitle selection widget until we press play. So, it seems to be purely a bug with how the track selection widget is displayed.
preload
is only controlling how media element loads its media resource, that doesn't mean it would stop loading text resource for another element. It seems that the video control listens addtrack
[2] event to show the caption control widget, in the second video, we indeed dispatch this event, so I guess maybe we initialize video too late which results in missing the event?
You can file another bug under Toolkit :: Video/Audio Controls
component, because it seems a different issue from the origin one we solved.
Thank you.
[1] https://html.spec.whatwg.org/multipage/media.html#attr-media-preload
[2] https://searchfox.org/mozilla-central/rev/1097f59d0bc17f6f8f805325c2f607e60cf0d26b/toolkit/content/widgets/videocontrols.js#1954
Description
•