Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 209f4da7d1692a001fc85e902a4df489e973e544
      
https://github.com/WebKit/WebKit/commit/209f4da7d1692a001fc85e902a4df489e973e544
  Author: Chris Dumez <[email protected]>
  Date:   2026-08-05 (Wed, 05 Aug 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-lifetime.https-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-lifetime.https.html
    A 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/lifetime-processor.js
    M Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp
    M Source/WebCore/Modules/webaudio/AudioWorkletNode.h

  Log Message:
  -----------
  AudioWorkletProcessor is torn down too early when process() returns false
https://bugs.webkit.org/show_bug.cgi?id=320973

Reviewed by Darin Adler.

WebKit destroyed an AudioWorkletProcessor as soon as its process() method
returned false, regardless of whether the node still had active inputs. The
Web Audio spec (and Blink/Firefox) require that returning false only stops
processing once the node also has no active inputs; as long as an upstream
node is still producing audio, process() must keep being called.

This is observable when an actively-playing source feeds a worklet whose
process() returns false: the processor should keep running (and its output
reflect the processing) until the source stops, then go silent. WebKit instead
went silent one render quantum after the first process() call.

Fix this by introducing an m_isActiveSource flag, set to the return value of
process() on each render quantum (initially true). The processor is only
finished once it is no longer an active source and has no active inputs (or if
process() threw). An input is considered active while it is connected to a node
that is still producing audio, i.e. its input bus is not silent; a source that
has finished playback outputs silence.

Test: 
imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-lifetime.https.html

* 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-lifetime.https-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-lifetime.https.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/lifetime-processor.js:
 Added.
(LifetimeProcessor.prototype.process):
(LifetimeProcessor):
Import WPT test from upstream. It was failing in shipping Safari but passing
in both Firefox and Chrome.

* Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp:
(WebCore::AudioWorkletNode::process):
(WebCore::AudioWorkletNode::~AudioWorkletNode):
(WebCore::AudioWorkletNode::setProcessor):
Track whether the node has active inputs and only finish the processor when it
is no longer an active source and has no active inputs.

* Source/WebCore/Modules/webaudio/AudioWorkletNode.h:
Add m_isActiveSource, only used on the rendering thread.

Canonical link: https://commits.webkit.org/318621@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to