Alert HN: legacy WebAudio content will break (again) in Chrome 70

Heads up: Chrome 70 (due in October) will restore a content policy that breaks most/all WebAudio content that hasn't been fixed to follow the policy.

If you maintain any WebAudio code the fix is below. For any code that hasn't been fixed and isn't maintained, expect it to stop working soon in Chrome. :(

--

Background:

This is part of the "no autoplaying" policy that rolled out in Chrome 66, and was reverted for WebAudio a few days later because it broke everything (including Chrome's own webaudio demos). Chrome 70 apparently restores the same implementation, so any content that broke before will break again, unless patched.

Past HN discussion: https://ift.tt/2IGxphx

Policy info: https://ift.tt/2jXClAO

--

Fix and tech details:

The easiest fix is to add a redundant `ctx.resume()` call to any user input event handler. Once that fires, the audioContext will work normally.

Basically Chrome's implementation of the policy doesn't look at when an audioContext plays sounds, it only cares when (a) the context is created, and (b) `context.resume()` is called. If either of those happens inside a user event handler, that context can play sounds. But if you create a context at startup and never call `resume` (like most WebAudio demos), the context will be muted regardless of whether it waits for user input.


Comments URL: https://news.ycombinator.com/item?id=18066474

Points: 3

# Comments: 0



from Hacker News: Front Page https://ift.tt/2Dt07kx
via

Comments

Popular posts from this blog