Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fade in/out sometimes never resolves #1368

Closed
alvov opened this issue Jul 6, 2020 · 1 comment
Closed

Fade in/out sometimes never resolves #1368

alvov opened this issue Jul 6, 2020 · 1 comment

Comments

@alvov
Copy link
Contributor

alvov commented Jul 6, 2020

There can be a case when fading in/out will never resolve.

Inside _startFadeInterval method vol is first clamped to the to value, and then is rounded:

        // Make sure the volume is in the right bounds.
        if (diff < 0) {
          vol = Math.max(to, vol);
        } else {
          vol = Math.min(to, vol);
        }

        // Round to within 2 decimal points.
        vol = Math.round(vol * 100) / 100;

In case to is a float like 0.901, then vol might first be assigned with 0.901, and then rounded to 0.9. After that the vol >= to check would fail, and runtime would fall into infinite loop.

I assume this could be fixed by moving rounding higher above the clamping part.

goldfire added a commit that referenced this issue Oct 24, 2020
Fix: fading never resolves in some cases (fixes #1368)
@goldfire
Copy link
Owner

Nice catch, thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants