fix: round playback speed readback to fix floating-point display (#3460)#3602
Open
DukeDeSouth wants to merge 1 commit intocode-charity:masterfrom
Open
fix: round playback speed readback to fix floating-point display (#3460)#3602DukeDeSouth wants to merge 1 commit intocode-charity:masterfrom
DukeDeSouth wants to merge 1 commit intocode-charity:masterfrom
Conversation
…e-charity#3460) The `playbackSpeed()` function was returning raw `video.playbackRate` values after setting speed, leading to IEEE 754 floating-point artifacts like "1.1500000000000001x" in the speed indicator. The read path (line 111) already rounds with `Number(x.toFixed(2))`, but the write-and-readback path (lines 123, 126) did not. When callers concatenated the raw return value with 'x' (e.g. `showStatus(speed + 'x')`), the result was a string that bypassed `showStatus()`'s `typeof number` → `toFixed(2)` guard. Fix: apply the same `Number(x.toFixed(2))` rounding pattern to the readback values at lines 123 and 126, consistent with line 111. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3460 — Playback Speed indicator shows too many digits (e.g.
"1.1500000000000001x"instead of"1.15x").Root Cause
The
playbackSpeed()function inplayer.jswas returning rawvideo.playbackRatevalues after setting speed. Due to IEEE 754 floating-point arithmetic (1.1 + 0.05 = 1.1500000000000001), the return value had excessive precision.The read path (line 111) already rounds with
Number(x.toFixed(2)), but the write-and-readback path (lines 123, 126) did not. When callers concatenated this raw value with'x'(e.g.showStatus(speed + 'x')), it produced strings like"1.1500000000000001x"that bypassedshowStatus()'stypeof number→toFixed(2)guard.Fix
Apply the same
Number(x.toFixed(2))rounding to the readback values at lines 123 and 126 — consistent with the existing pattern at line 111.2 lines changed in 1 file.
Testing
(1.1500000000000001).toFixed(2)returns"1.15"playbackSpeed()return value for displayvideo.playbackRatevalues set on the elementBrowsers
Affects all browsers (IEEE 754 is universal), reported on Firefox.
Made with Cursor