Skip to content

Fix logic for clearing held peaks#3

Merged
jlnstrk merged 2 commits into
mainfrom
jlnstrk/clear-peaks-race
Jul 8, 2025
Merged

Fix logic for clearing held peaks#3
jlnstrk merged 2 commits into
mainfrom
jlnstrk/clear-peaks-race

Conversation

@jlnstrk

@jlnstrk jlnstrk commented Jul 3, 2025

Copy link
Copy Markdown

Fixes some logic errors where held peaks are reset

  1. never: if the peakHoldDuraton (or the corresponding setTimeout) expires before new peaks are received from the worklet, effectively resetting to the same value. With this, the output value could only ever increase, but never decrease.
  2. only once (otherwise): When a new peak is reached, a single setTimeout was scheduled, in the callback of which we set the held peaks equal to the current peaks. But the value after reset (the current peaks) did not get a corresponding setTimeout. As a result, it also could only be superseded by a larger one.

This is quite likely the same bug mentioned in #1 (review).

@jlnstrk
jlnstrk requested a review from rksm July 3, 2025 19:22
@jlnstrk jlnstrk added the bug Something isn't working label Jul 3, 2025
@jlnstrk jlnstrk changed the title Fix race condition when clearing held peaks Fix logic for clearing held peaks Jul 3, 2025
@jlnstrk
jlnstrk requested a review from pablosichert July 3, 2025 21:33
@jlnstrk

jlnstrk commented Jul 3, 2025

Copy link
Copy Markdown
Author

@pablosichert This needs another look. There was more wrong with the code than I first realized. I updated the PR description with some context.

Base automatically changed from jlnstrk/cleanup to main July 3, 2025 21:35
@jlnstrk
jlnstrk force-pushed the jlnstrk/clear-peaks-race branch from c3cf102 to 2129b32 Compare July 7, 2025 10:48
@jlnstrk
jlnstrk merged commit a9ac9c1 into main Jul 8, 2025
1 check passed
@jlnstrk
jlnstrk deleted the jlnstrk/clear-peaks-race branch July 8, 2025 15:41
@rksm

rksm commented Jul 12, 2025

Copy link
Copy Markdown

Without publishing a new release these changes will have no effect as the transpiled sources aren't updated. In particular just referencing a git commit like in https://github.com/hypervideo/hyper.video/pull/3174/files#r2202509104 will still use the old version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants