howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

Volume of sound becomes NaN if passing zero length in fade.

Open nookerai opened this issue 3 years ago • 0 comments

It's possible to pass zero (0) as the len parameter (duration of fade) in fade method. This causes the volume of the sound object to become NaN, since it tries to divide by zero in the tick calculation in _startFadeInterval method.

var tick = (Date.now() - lastTick) / len;

I don't think the value being NaN causes bugs on its own but if you rely on the volume to be a value it's very easy to create bugs, for instance when trying to fade from the sound's current volume.

Solution is probably to make sure fade method handles zero duration properly.

nookerai avatar Jan 13 '22 14:01 nookerai