Test page: https://rednoize.su/vtt-bug/index2.html 1. Start video playing and enable subtitles 2. Ensure that subtitle track is displayed (after 0:00:05 time position) 3. Click on "Next subtitle track" - track URL will be changed 4. You will see the old subtitle track and the new subtitle track in the same time. 5. Click on "Next subtitle track" one more time - the first track URL will be set again. 6. You will see one more clone of the first subtitle track I cannot find anything in the standards about it. As I can see, it is not prohibited to change 'src' attribute of the <track> element, and I logically suppose that on 'src' change event the old subtitle track should be deleted from the media and hidden from the screen. Tested on Midori 0.5.11. Chromium has the same problem, Firefox handles it well.
"Whenever a track element has its src attribute set, changed, or removed, the user agent must immediately empty the element's text track's text track list of cues. (This also causes the algorithm above to stop adding cues from the resource being obtained using the previously given URL, if any.)" https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks:text-track-list-of-cues-5
<rdar://problem/33666796>
Created attachment 317229 [details] Patch
Attachment 317229 [details] did not pass style-queue: ERROR: Source/WebCore/ChangeLog:8: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Created attachment 317231 [details] Patch
Comment on attachment 317231 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=317231&action=review Thank you for the patch! Marking r- for now because of the manual test. > ManualTests/media-track-src-change.html:18 > + <title>HTML5 Video Subtitle refresh bug test</title> > + <script> > + var vtts = ["https://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/track/captions-webvtt/captions-long.vtt", > + "https://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/track/captions-webvtt/captions.vtt"]; > + var actualSub = 0; > + document.addEventListener("DOMContentLoaded", function () { > + document.getElementById('vid').play(); > + document.getElementById('nextSub').addEventListener('click', function () { > + actualSub++; > + var subtitlesSrc = vtts[actualSub % vtts.length]; > + document.getElementById('vid').children[0].setAttribute("src", subtitlesSrc); > + }, false); > + }); Manual tests are not run frequently, so they are generally used for changes that can only be verified manually. This would be much better as a regular layout test, so it will be run automatically every time someone submits a patch. Because this bug results in a track with both the old and new cues, a test can check the number of cues before and after changing .src. Existing vtt tests are in LayoutTests/media/track/. Something like track-text-track-cue-list.html could be modified to test your change if you wish.
Created attachment 317697 [details] Patch
Thank you for your feedback and advice! I prepared a new patch with layout auto-test.
Comment on attachment 317697 [details] Patch Thank you for the fix! If you don't have commit privileges, make the bug cq? and any committer can have the commit bot do it.
Comment on attachment 317697 [details] Patch Clearing flags on attachment: 317697 Committed r220472: <http://trac.webkit.org/changeset/220472>
All reviewed patches have been landed. Closing bug.