⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267367 in webkit


Ignore:
Timestamp:
Sep 21, 2020, 2:17:46 PM (6 years ago)
Author:
Chris Dumez
Message:

AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
https://bugs.webkit.org/show_bug.cgi?id=216790

Reviewed by Eric Carlson.

Source/WebCore:

AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values.
The specification [1] says:
"If V0 and V1 have opposite signs or if V0 is zero, then v(t) = V0 for T0 <= t < T1."

Our implementation did not match the specification and would just special-case if either
V0 or V1 was negative.

[1] https://www.w3.org/TR/webaudio/#dom-audioparam-exponentialramptovalueattime

No new tests, rebaselined existing test.

  • Modules/webaudio/AudioParamTimeline.cpp:

(WebCore::AudioParamTimeline::valuesForTimeRangeImpl):

LayoutTests:

Rebaseline test that is now passing.

  • webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267366 r267367  
     12020-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
     4        https://bugs.webkit.org/show_bug.cgi?id=216790
     5
     6        Reviewed by Eric Carlson.
     7
     8        Rebaseline test that is now passing.
     9
     10        * webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt:
     11
    1122020-09-21  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt

    r267357 r267367  
    77PASS Audit report
    88PASS > [both negative values] 
    9 FAIL X Negative exponential ramp from -1 to -2 expected to be equal to the array [-1,-1.0001155138015747,-1.0002310276031494,-1.0003465414047241,-1.0004620552062988,-1.0005775690078735,-1.0006932020187378,-1.000808835029602,-1.0009244680404663,-1.0010401010513306,-1.0011557340621948,-1.001271367073059,-1.0013870000839233,-1.0015026330947876,-1.0016182661056519,-1.0017340183258057...] but differs in 6000 places:
    10         Index   Actual                  Expected
    11         [0]     1.0000000000000000e+0   -1.0000000000000000e+0
    12         [1]     1.0000000000000000e+0   -1.0001155138015747e+0
    13         [2]     1.0000000000000000e+0   -1.0002310276031494e+0
    14         [3]     1.0000000000000000e+0   -1.0003465414047241e+0
    15         ...and 5996 more errors. assert_true: expected true got false
    16 FAIL < [both negative values] 1 out of 1 assertions were failed. assert_true: expected true got false
     9PASS   Negative exponential ramp from -1 to -2 is identical to the array [expected array].
     10PASS < [both negative values] All assertions passed. (total 1 assertions)
    1711PASS > [negative-end] 
    18 FAIL X Exponential ramp from 2 to -1: Expected 2 for all values but found 6000 unexpected values:
    19         Index   Actual
    20         [0]     1
    21         [1]     1
    22         [2]     1
    23         [3]     1
    24         ...and 5996 more errors. assert_true: expected true got false
    25 FAIL < [negative-end] 1 out of 1 assertions were failed. assert_true: expected true got false
     12PASS   Exponential ramp from 2 to -1 contains only the constant 2.
     13PASS < [negative-end] All assertions passed. (total 1 assertions)
    2614PASS > [positive-end] 
    27 FAIL X Exponential ramp from -1 to 1: Expected -1 for all values but found 6000 unexpected values:
    28         Index   Actual
    29         [0]     1
    30         [1]     1
    31         [2]     1
    32         [3]     1
    33         ...and 5996 more errors. assert_true: expected true got false
    34 FAIL < [positive-end] 1 out of 1 assertions were failed. assert_true: expected true got false
     15PASS   Exponential ramp from -1 to 1 contains only the constant -1.
     16PASS < [positive-end] All assertions passed. (total 1 assertions)
    3517PASS > [propagate] 
    36 FAIL X Exponential ramp from -1 to 1 after the end of the linear ramp: Expected -1 for all values but found 1500 unexpected values:
    37         Index   Actual
    38         [0]     -0.9980001449584961
    39         [1]     -0.9980001449584961
    40         [2]     -0.9980001449584961
    41         [3]     -0.9980001449584961
    42         ...and 1496 more errors. assert_true: expected true got false
     18PASS   Exponential ramp from -1 to 1 after the end of the linear ramp contains only the constant -1.
    4319PASS   Exponential ramp after end of ramp contains only the constant 1.
    44 FAIL < [propagate] 1 out of 2 assertions were failed. assert_true: expected true got false
    45 FAIL # AUDIT TASK RUNNER FINISHED: 4 out of 4 tasks were failed. assert_true: expected true got false
     20PASS < [propagate] All assertions passed. (total 2 assertions)
     21PASS # AUDIT TASK RUNNER FINISHED: 4 tasks ran successfully.
    4622
  • trunk/LayoutTests/webaudio/AudioParam/audioparam-setTargetAtTime-continuous-expected.txt

    r267357 r267367  
    4343FAIL X Exponential ramp does not equal [1,1.00030517578125,1.0006103515625,1.0009156465530396,1.0012210607528687,1.0015265941619873,1.001832127571106,1.0021378993988037,1.0024436712265015,1.0027495622634888,1.003055453300476,1.0033615827560425,1.0036677122116089,1.0039739608764648,1.0042803287506104,1.0045866966247559...] with an element-wise tolerance of {"absoluteThreshold":0.0000114441,"relativeThreshold":0}.
    4444        Index   Actual                  Expected                AbsError                RelError                Test threshold
    45         [1]     1.0000000000000000e+0   1.0003051757812500e+0   3.0517578125000000e-4   3.0508267740557692e-4   1.1444099999999999e-5
    46         [2]     1.0000000000000000e+0   1.0006103515625000e+0   6.1035156250000000e-4   6.0997926070513605e-4   1.1444099999999999e-5
    47         [3]     1.0000000000000000e+0   1.0009156465530396e+0   9.1564655303955078e-4   9.1480891141312545e-4   1.1444099999999999e-5
    48         [4]     1.0000000000000000e+0   1.0012210607528687e+0   1.2210607528686523e-3   1.2195715818747112e-3   1.1444099999999999e-5
    49         [5]     1.0000000000000000e+0   1.0015265941619873e+0   1.5265941619873047e-3   1.5242672245410118e-3   1.1444099999999999e-5
    50         ...and 2266 more errors.
    51         Max AbsError of 9.9938988685607910e-1 at index of 2271.
    52         [2271]  1.0000000000000000e+0   1.9993898868560791e+0   9.9938988685607910e-1   4.9984742517006520e-1   1.1444099999999999e-5
    53         Max RelError of 4.9984742517006520e-1 at index of 2271.
    54         [2271]  1.0000000000000000e+0   1.9993898868560791e+0   9.9938988685607910e-1   4.9984742517006520e-1   1.1444099999999999e-5
     45        [0]     0.0000000000000000e+0   1.0000000000000000e+0   1.0000000000000000e+0   1.0000000000000000e+0   1.1444099999999999e-5
     46        [1]     0.0000000000000000e+0   1.0003051757812500e+0   1.0003051757812500e+0   1.0000000000000000e+0   1.1444099999999999e-5
     47        [2]     0.0000000000000000e+0   1.0006103515625000e+0   1.0006103515625000e+0   1.0000000000000000e+0   1.1444099999999999e-5
     48        [3]     0.0000000000000000e+0   1.0009156465530396e+0   1.0009156465530396e+0   1.0000000000000000e+0   1.1444099999999999e-5
     49        [4]     0.0000000000000000e+0   1.0012210607528687e+0   1.0012210607528687e+0   1.0000000000000000e+0   1.1444099999999999e-5
     50        ...and 2267 more errors.
     51        Max AbsError of 1.9993898868560791e+0 at index of 2271.
     52        [2271]  0.0000000000000000e+0   1.9993898868560791e+0   1.9993898868560791e+0   1.0000000000000000e+0   1.1444099999999999e-5
     53        Max RelError of 1.0000000000000000e+0 at index of 0.
    5554 assert_true: expected true got false
    5655PASS   Exponential ramp: Tail part equals [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}.
     
    6160FAIL X Delayed exponential ramp does not equal [0.4493289589881897,0.4496844708919525,0.45004022121429443,0.4503962993621826,0.4507526457309723,0.45110926032066345,0.4514661729335785,0.451823353767395,0.4521808326244354,0.4525385797023773,0.4528966248035431,0.45325493812561035,0.4536135494709015,0.4539724290370941,0.4543316066265106,0.4546910524368286...] with an element-wise tolerance of {"absoluteThreshold":0.00000429154,"relativeThreshold":0}.
    6261        Index   Actual                  Expected                AbsError                RelError                Test threshold
    63         [0]     4.5026594400405884e-1   4.4932895898818970e-1   9.3698501586914063e-4   2.0852985260043492e-3   4.2915399999999997e-6
    64         [1]     4.5026594400405884e-1   4.4968447089195251e-1   5.8147311210632324e-4   1.2930691401305608e-3   4.2915399999999997e-6
    65         [2]     4.5026594400405884e-1   4.5004022121429443e-1   2.2572278976440430e-4   5.0156136968238332e-4   4.2915399999999997e-6
    66         [3]     4.5026594400405884e-1   4.5039629936218262e-1   1.3035535812377930e-4   2.8942368822385700e-4   4.2915399999999997e-6
    67         [4]     4.5026594400405884e-1   4.5075264573097229e-1   4.8670172691345215e-4   1.0797534557432987e-3   4.2915399999999997e-6
     62        [0]     0.0000000000000000e+0   4.4932895898818970e-1   4.4932895898818970e-1   1.0000000000000000e+0   4.2915399999999997e-6
     63        [1]     0.0000000000000000e+0   4.4968447089195251e-1   4.4968447089195251e-1   1.0000000000000000e+0   4.2915399999999997e-6
     64        [2]     0.0000000000000000e+0   4.5004022121429443e-1   4.5004022121429443e-1   1.0000000000000000e+0   4.2915399999999997e-6
     65        [3]     0.0000000000000000e+0   4.5039629936218262e-1   4.5039629936218262e-1   1.0000000000000000e+0   4.2915399999999997e-6
     66        [4]     0.0000000000000000e+0   4.5075264573097229e-1   4.5075264573097229e-1   1.0000000000000000e+0   4.2915399999999997e-6
    6867        ...and 1883 more errors.
    69         Max AbsError of 1.5481528639793396e+0 at index of 1887.
    70         [1887]  4.5026594400405884e-1   1.9984188079833984e+0   1.5481528639793396e+0   7.7468889794005613e-1   4.2915399999999997e-6
    71         Max RelError of 7.7468889794005613e-1 at index of 1887.
    72         [1887]  4.5026594400405884e-1   1.9984188079833984e+0   1.5481528639793396e+0   7.7468889794005613e-1   4.2915399999999997e-6
     68        Max AbsError of 1.9984188079833984e+0 at index of 1887.
     69        [1887]  0.0000000000000000e+0   1.9984188079833984e+0   1.9984188079833984e+0   1.0000000000000000e+0   4.2915399999999997e-6
     70        Max RelError of 1.0000000000000000e+0 at index of 0.
    7371 assert_true: expected true got false
    7472PASS   Delayed exponential ramp: Tail part equals [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}.
  • trunk/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end-expected.txt

    r267253 r267367  
    1515FAIL < [1: linearRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
    1616PASS > [2: exponentialRampToValueAtTime] 
    17 FAIL X setValueCurve(..., 0, 0.01).exponentialRampToValueAtTime(2, 0.02): value at time 0.01 is not close to 0.3 within a relative error of 3.9737e-8 (RelErr=2.3333333333333335). Got 1. assert_true: expected true got false
     17FAIL X setValueCurve(..., 0, 0.01).exponentialRampToValueAtTime(2, 0.02): value at time 0.01 is not close to 0.3 within a relative error of 3.9737e-8 (RelErr=1). Got 0. assert_true: expected true got false
    1818FAIL < [2: exponentialRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
    1919PASS > [3: exponentialRampToValueAtTime] 
    20 FAIL X setValueCurve(..., 0, 0.0100390625).exponentialRampToValueAtTime(2, 0.02): value at time 0.010078125 is not close to 0.30224022883150364 within a relative error of 7.8294e-8 (RelErr=2.308626399159761). Got 1. assert_true: expected true got false
     20FAIL X setValueCurve(..., 0, 0.0100390625).exponentialRampToValueAtTime(2, 0.02): value at time 0.010078125 is not close to 0.30224022883150364 within a relative error of 7.8294e-8 (RelErr=1). Got 0. assert_true: expected true got false
    2121FAIL < [3: exponentialRampToValueAtTime] 1 out of 1 assertions were failed. assert_true: expected true got false
    2222PASS > [4: setTargetAtTime] 
  • trunk/Source/WebCore/ChangeLog

    r267366 r267367  
     12020-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values
     4        https://bugs.webkit.org/show_bug.cgi?id=216790
     5
     6        Reviewed by Eric Carlson.
     7
     8        AudioParam.exponentialRampToValueAtTime() does not properly deal with negative values.
     9        The specification [1] says:
     10        "If V0 and V1 have opposite signs or if V0 is zero, then v(t) = V0 for T0 <= t < T1."
     11
     12        Our implementation did not match the specification and would just special-case if either
     13        V0 or V1 was negative.
     14
     15        [1] https://www.w3.org/TR/webaudio/#dom-audioparam-exponentialramptovalueattime
     16
     17        No new tests, rebaselined existing test.
     18
     19        * Modules/webaudio/AudioParamTimeline.cpp:
     20        (WebCore::AudioParamTimeline::valuesForTimeRangeImpl):
     21
    1222020-09-21  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp

    r267357 r267367  
    421421            processLinearRamp(values, writeIndex, fillToFrame, value, value1, value2, deltaTime, time1, samplingPeriod, currentFrame);
    422422        else if (nextEventType == ParamEvent::ExponentialRampToValue) {
    423             if (value1 <= 0 || value2 <= 0) {
    424                 // Handle negative values error case by propagating previous value.
     423            if (!value1 || value1 * value2 < 0) {
     424                // Per the specification:
     425                // If value1 and value2 have opposite signs or if value1 is zero, then v(t) = value1 for T0 <= t < T1.
     426                value = value1;
    425427                for (; writeIndex < fillToFrame; ++writeIndex)
    426428                    values[writeIndex] = value;
Note: See TracChangeset for help on using the changeset viewer.