Bug 183253 - Multiple calls to setTargetAtTime with separate timestamps has unpredictable behavior
Summary: Multiple calls to setTargetAtTime with separate timestamps has unpredictable ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-03-01 11:45 PST by ae
Modified: 2018-03-02 17:07 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ae 2018-03-01 11:45:29 PST
I've spent the last 2 days trying to make a simple ADSR envelope generator using setTargetAtTime. It's hard to isolate a testcase, but I can say that as soon as several targets are added to the timeline, for example: 0 at 1 second, 1 at 2 seconds, 0.5 at 3 seconds, and 0 at 4 seconds), the resulting curves are unpredictable, especially when interrupted with cancelScheduledValues and then re-constructed (both are necessary for making a working real-world ADSR generator). The same code works flawlessly in Chrome and Firefox... I could possibly provide a testcase if needed.
Comment 1 ae 2018-03-01 12:54:50 PST
OK, sorry for the original inaccurate report. More investigation revealed the following:

node.gain.setValueAtTime(1, timestamp)
node.gain.setTargetAtTime(0.5, timestamp, 1)

This code seems to cause a race condition when both timestamps are equal. If I use "timestamp + 0.001" in the second line, the problem goes away.
Comment 2 Radar WebKit Bug Importer 2018-03-02 17:07:15 PST
<rdar://problem/38088304>