Spotted in my completely unrelated trypush - [log link](https://treeherder.mozilla.org/logviewer?job_id=400629977&repo=try&lineNumber=38476), [job link](https://treeherder.mozilla.org/jobs?repo=try&revision=4f0ab0053d5ee3dbab705e5a2bc34a2d724e0fb2&selectedTaskRun=CMxONXOtT6GDXyqBl8QmTQ.0) ``` [task 2022-12-23T14:52:39.928Z] 14:52:39 INFO - GECKO(26233) | JavaScript warning: chrome://global/content/elements/videocontrols.js, line 1283: Script terminated by timeout at: [task 2022-12-23T14:52:39.929Z] 14:52:39 INFO - GECKO(26233) | showPosition@chrome://global/content/elements/videocontrols.js:1283:19 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | setupInitialState@chrome://global/content/elements/videocontrols.js:407:14 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | init@chrome://global/content/elements/videocontrols.js:2609:14 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | onsetup@chrome://global/content/elements/videocontrols.js:2830:16 [task 2022-12-23T14:52:39.932Z] 14:52:39 INFO - GECKO(26233) | switchImpl@chrome://global/content/elements/videocontrols.js:87:17 [task 2022-12-23T14:52:39.932Z] 14:52:39 INFO - GECKO(26233) | onchange@chrome://global/content/elements/videocontrols.js:36:10 [task 2022-12-23T14:52:39.933Z] 14:52:39 INFO - GECKO(26233) | [Child 30959, Main Thread] WARNING: NS_ENSURE_TRUE(JS_Stringify(aCx, &value, nullptr, JS::NullHandleValue, JSONCreator, &serializedValue)) failed: file /builds/worker/checkouts/gecko/dom/base/nsContentUtils.cpp:10627 [task 2022-12-23T14:52:39.971Z] 14:52:39 INFO - GECKO(26233) | Fluent error, the argument "$position" was not provided a value. [task 2022-12-23T14:52:39.973Z] 14:52:39 INFO - GECKO(26233) | This error happened while formatting the following messages: [task 2022-12-23T14:52:39.974Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-aborted" [task 2022-12-23T14:52:39.975Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-network" [task 2022-12-23T14:52:39.980Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-decode" [task 2022-12-23T14:52:39.981Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-src-not-supported" [task 2022-12-23T14:52:39.982Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-no-source" [task 2022-12-23T14:52:39.983Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-generic" [task 2022-12-23T14:52:39.984Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-status-picture-in-picture" [task 2022-12-23T14:52:39.985Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-picture-in-picture-toggle-label2" [task 2022-12-23T14:52:39.986Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-picture-in-picture-explainer3" [task 2022-12-23T14:52:39.987Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-buffer-bar-label" [task 2022-12-23T14:52:39.988Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-scrubber" [task 2022-12-23T14:52:39.989Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-volume-control" [task 2022-12-23T14:52:39.990Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-casting-button-label" [task 2022-12-23T14:52:39.991Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-closed-caption-button" [task 2022-12-23T14:52:39.991Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-closed-caption-off" [task 2022-12-23T14:52:39.992Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-enterfullscreen-button" [task 2022-12-23T14:52:39.993Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-play-button" [task 2022-12-23T14:52:39.994Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-play-button" [task 2022-12-23T14:52:39.995Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-position-and-duration-labels" [task 2022-12-23T14:52:39.996Z] 14:52:39 INFO - GECKO(26233) | Hit MOZ_CRASH(Resolver error: Unknown variable: $position) at intl/l10n/rust/localization-ffi/src/lib.rs:620 ``` with a rust stack trace (which is not much use - we want to know where the information came from that broke). The JS stack points to [this code](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1283-1290) which does: ```js let positionTime = this.formatTime(currentTime, this.showHours); this.scrubber.value = currentTime; this.positionDurationBox.position = positionTime; this.l10n.setAttributes( this.positionDurationBox, "videocontrols-position-and-duration-labels", { position: positionTime, duration: this.positionDurationBox.duration, } ); ``` But AFAICT [`this.formatTime()`](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1149-1168) always returns a non-undefined value: ```js formatTime(aTime, showHours = false) { // Format the duration as "h:mm:ss" or "m:ss" aTime = Math.round(aTime / 1000); let hours = Math.floor(aTime / 3600); let mins = Math.floor((aTime % 3600) / 60); let secs = Math.floor(aTime % 60); let timeString; if (secs < 10) { secs = "0" + secs; } if (hours || showHours) { if (mins < 10) { mins = "0" + mins; } timeString = hours + ":" + mins + ":" + secs; } else { timeString = mins + ":" + secs; } return timeString; }, ``` (because by the end of the function `timeString` must be a string) However, it seems possible that [this code](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1195-1204): ```js let timeString = isInfinite ? "" : this.formatTime(duration); this.positionDurationBox.duration = timeString; this.l10n.setAttributes( this.positionDurationBox, "videocontrols-position-and-duration-labels", { position: this.positionDurationBox.position, duration: timeString, } ); ``` which reuses `this.positionDurationBox.position` could grab `undefined` at that point. In particular, it looks like `showDuration` has exactly ` caller which is in fact `showPosition`, which is also responsible for setting `this.positionDurationBox.position` -- but only does so _after_ calling `showDuration`, right before also overwriting the l10n stuff again. I think this means that in practice this shouldn't normally hurt users because the JS code is all sync, but it does look like it's... oddly structured. We should probably be setting the duration + position and associated l10n label just once, instead of twice with potentially wrong/undefined variables.
Bug 1807249 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Spotted in my completely unrelated trypush - [log link](https://treeherder.mozilla.org/logviewer?job_id=400629977&repo=try&lineNumber=38476), [job link](https://treeherder.mozilla.org/jobs?repo=try&revision=4f0ab0053d5ee3dbab705e5a2bc34a2d724e0fb2&selectedTaskRun=CMxONXOtT6GDXyqBl8QmTQ.0) ``` [task 2022-12-23T14:52:39.928Z] 14:52:39 INFO - GECKO(26233) | JavaScript warning: chrome://global/content/elements/videocontrols.js, line 1283: Script terminated by timeout at: [task 2022-12-23T14:52:39.929Z] 14:52:39 INFO - GECKO(26233) | showPosition@chrome://global/content/elements/videocontrols.js:1283:19 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | setupInitialState@chrome://global/content/elements/videocontrols.js:407:14 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | init@chrome://global/content/elements/videocontrols.js:2609:14 [task 2022-12-23T14:52:39.931Z] 14:52:39 INFO - GECKO(26233) | onsetup@chrome://global/content/elements/videocontrols.js:2830:16 [task 2022-12-23T14:52:39.932Z] 14:52:39 INFO - GECKO(26233) | switchImpl@chrome://global/content/elements/videocontrols.js:87:17 [task 2022-12-23T14:52:39.932Z] 14:52:39 INFO - GECKO(26233) | onchange@chrome://global/content/elements/videocontrols.js:36:10 [task 2022-12-23T14:52:39.933Z] 14:52:39 INFO - GECKO(26233) | [Child 30959, Main Thread] WARNING: NS_ENSURE_TRUE(JS_Stringify(aCx, &value, nullptr, JS::NullHandleValue, JSONCreator, &serializedValue)) failed: file /builds/worker/checkouts/gecko/dom/base/nsContentUtils.cpp:10627 [task 2022-12-23T14:52:39.971Z] 14:52:39 INFO - GECKO(26233) | Fluent error, the argument "$position" was not provided a value. [task 2022-12-23T14:52:39.973Z] 14:52:39 INFO - GECKO(26233) | This error happened while formatting the following messages: [task 2022-12-23T14:52:39.974Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-aborted" [task 2022-12-23T14:52:39.975Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-network" [task 2022-12-23T14:52:39.980Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-decode" [task 2022-12-23T14:52:39.981Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-src-not-supported" [task 2022-12-23T14:52:39.982Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-no-source" [task 2022-12-23T14:52:39.983Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-error-generic" [task 2022-12-23T14:52:39.984Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-status-picture-in-picture" [task 2022-12-23T14:52:39.985Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-picture-in-picture-toggle-label2" [task 2022-12-23T14:52:39.986Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-picture-in-picture-explainer3" [task 2022-12-23T14:52:39.987Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-buffer-bar-label" [task 2022-12-23T14:52:39.988Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-scrubber" [task 2022-12-23T14:52:39.989Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-volume-control" [task 2022-12-23T14:52:39.990Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-casting-button-label" [task 2022-12-23T14:52:39.991Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-closed-caption-button" [task 2022-12-23T14:52:39.991Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-closed-caption-off" [task 2022-12-23T14:52:39.992Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-enterfullscreen-button" [task 2022-12-23T14:52:39.993Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-play-button" [task 2022-12-23T14:52:39.994Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-play-button" [task 2022-12-23T14:52:39.995Z] 14:52:39 INFO - GECKO(26233) | "videocontrols-position-and-duration-labels" [task 2022-12-23T14:52:39.996Z] 14:52:39 INFO - GECKO(26233) | Hit MOZ_CRASH(Resolver error: Unknown variable: $position) at intl/l10n/rust/localization-ffi/src/lib.rs:620 ``` with a rust stack trace (which is not much use - we want to know where the information came from that broke). The JS stack points to [this code](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1283-1290) which does: ```js let positionTime = this.formatTime(currentTime, this.showHours); this.scrubber.value = currentTime; this.positionDurationBox.position = positionTime; this.l10n.setAttributes( this.positionDurationBox, "videocontrols-position-and-duration-labels", { position: positionTime, duration: this.positionDurationBox.duration, } ); ``` But AFAICT [`this.formatTime()`](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1149-1168) always returns a non-undefined value: ```js formatTime(aTime, showHours = false) { // Format the duration as "h:mm:ss" or "m:ss" aTime = Math.round(aTime / 1000); let hours = Math.floor(aTime / 3600); let mins = Math.floor((aTime % 3600) / 60); let secs = Math.floor(aTime % 60); let timeString; if (secs < 10) { secs = "0" + secs; } if (hours || showHours) { if (mins < 10) { mins = "0" + mins; } timeString = hours + ":" + mins + ":" + secs; } else { timeString = mins + ":" + secs; } return timeString; }, ``` (because by the end of the function `timeString` must be a string) However, it seems possible that [this code](https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/toolkit/content/widgets/videocontrols.js#1195-1204): ```js let timeString = isInfinite ? "" : this.formatTime(duration); this.positionDurationBox.duration = timeString; this.l10n.setAttributes( this.positionDurationBox, "videocontrols-position-and-duration-labels", { position: this.positionDurationBox.position, duration: timeString, } ); ``` which reuses `this.positionDurationBox.position` could grab `undefined` at that point. In particular, it looks like `showDuration` has exactly 1 caller which is in fact `showPosition`, which is also responsible for setting `this.positionDurationBox.position` -- but only does so _after_ calling `showDuration`, right before also overwriting the l10n stuff again. I think this means that in practice this shouldn't normally hurt users because the JS code is all sync, but it does look like it's... oddly structured. We should probably be setting the duration + position and associated l10n label just once, instead of twice with potentially wrong/undefined variables.