Bug 215625 - PannerNode's rolloffFactor should be clamped to [0, 1] internally when distanceModel is "linear"
Summary: PannerNode's rolloffFactor should be clamped to [0, 1] internally when distan...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://www.w3.org/TR/webaudio/#dom-p...
Keywords: InRadar
Depends on:
Blocks: 212611
  Show dependency treegraph
 
Reported: 2020-08-18 14:19 PDT by Chris Dumez
Modified: 2020-08-18 16:16 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.67 KB, patch)
2020-08-18 14:52 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (5.60 KB, patch)
2020-08-18 15:36 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-08-18 14:19:36 PDT
PannerNode.rolloffFactor setter should clamp value to [0, 1] when distanceModel is "linear":
- https://www.w3.org/TR/webaudio/#dom-pannernode-rollofffactor
Comment 1 Chris Dumez 2020-08-18 14:52:31 PDT
Created attachment 406814 [details]
Patch
Comment 2 Darin Adler 2020-08-18 15:03:29 PDT
Comment on attachment 406814 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406814&action=review

> Source/WebCore/platform/audio/Distance.cpp:72
> +    auto clampedRolloffFactor = std::min(m_rolloffFactor, 1.0);

This says clamped but it only does the 1.0 half of the clamping. I’d expect to see std::max or std::clamp here.
Comment 3 Darin Adler 2020-08-18 15:04:37 PDT
Comment on attachment 406814 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406814&action=review

>> Source/WebCore/platform/audio/Distance.cpp:72
>> +    auto clampedRolloffFactor = std::min(m_rolloffFactor, 1.0);
> 
> This says clamped but it only does the 1.0 half of the clamping. I’d expect to see std::max or std::clamp here.

to handle the 0.0 minimum.
Comment 4 Chris Dumez 2020-08-18 15:11:17 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 406814 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406814&action=review
> 
> >> Source/WebCore/platform/audio/Distance.cpp:72
> >> +    auto clampedRolloffFactor = std::min(m_rolloffFactor, 1.0);
> > 
> > This says clamped but it only does the 1.0 half of the clamping. I’d expect to see std::max or std::clamp here.
> 
> to handle the 0.0 minimum.

We already throw an exception in the setter if the JS tries to set a negative value. Therefore, we only need to make sure the value is no more than 1.
Comment 5 Chris Dumez 2020-08-18 15:12:23 PDT
(In reply to Chris Dumez from comment #4)
> (In reply to Darin Adler from comment #3)
> > Comment on attachment 406814 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=406814&action=review
> > 
> > >> Source/WebCore/platform/audio/Distance.cpp:72
> > >> +    auto clampedRolloffFactor = std::min(m_rolloffFactor, 1.0);
> > > 
> > > This says clamped but it only does the 1.0 half of the clamping. I’d expect to see std::max or std::clamp here.
> > 
> > to handle the 0.0 minimum.
> 
> We already throw an exception in the setter if the JS tries to set a
> negative value. Therefore, we only need to make sure the value is no more
> than 1.

From https://www.w3.org/TR/webaudio/#dom-pannernode-rollofffactor:
"A RangeError exception MUST be thrown if this is set to a negative value."
Comment 6 Chris Dumez 2020-08-18 15:15:41 PDT
Comment on attachment 406814 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406814&action=review

> Source/WebCore/Modules/webaudio/PannerNode.cpp:282
>          return Exception { RangeError, "rolloffFactor cannot be set to a negative value"_s };

Throwing happens here if value is negative.
Comment 7 Chris Dumez 2020-08-18 15:36:16 PDT
Created attachment 406819 [details]
Patch
Comment 8 EWS 2020-08-18 16:15:33 PDT
Committed r265838: <https://trac.webkit.org/changeset/265838>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 406819 [details].
Comment 9 Radar WebKit Bug Importer 2020-08-18 16:16:16 PDT
<rdar://problem/67360120>