Make WebVTT.processCues robust to exceptions with try/finally
Categories
(Core :: Audio/Video: Playback, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox155 | --- | fixed |
People
(Reporter: alwu, Assigned: munawiki)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, Whiteboard: [lang=js])
Attachments
(1 file)
Filing as a good first bug to learn workflows.
WebVTT.processCues in dom/media/webvtt/vtt.sys.mjs guards against re-entrancy with an isProcessingCues flag, but it has no try/finally. It sets the flag to true, calls processCuesInternal(), then sets it back to false:
WebVTT.processCues = function(window, cues, overlay, controls) {
if (this.isProcessingCues) {
return;
}
this.isProcessingCues = true;
processCuesInternal(window, cues, overlay, controls);
this.isProcessingCues = false;
};
If processCuesInternal() throws, isProcessingCues is left stuck at true, and every later call to processCues() returns early at the guard, permanently disabling WebVTT cue (subtitle/caption) rendering for that document.
Please wrap the call in try/finally so the flag is always reset:
this.isProcessingCues = true;
try {
processCuesInternal(window, cues, overlay, controls);
} finally {
this.isProcessingCues = false;
}
Link to the code:
https://searchfox.org/mozilla-central/source/dom/media/webvtt/vtt.sys.mjs#1352
To verify the fix:
./mach mochitest dom/media/webvtt/test/mochitest/
./mach wpt testing/web-platform/tests/webvtt/
A regression test that makes processCuesInternal throw once and asserts that a later cue still renders would be a welcome addition, but is optional.
This was surfaced while investigating bug 2047835 (a duplicate of bug 2047708), where an exception thrown inside processCuesInternal turned a single-cue failure into a total, persistent caption blackout.
Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html
Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.
Updated•20 days ago
|
Updated•2 days ago
|
Description
•