Skip to content

Conversation

@Prospero23
Copy link
Contributor

@Prospero23 Prospero23 commented Jan 24, 2026

This PR introduces a basic offline rendering loop to process audio for the WebAudio API, based on the work of @jonbgamble.

Description

We cannot access GC allocated objects off the main thread, so this PR creates a render thread friendly snapshot of the audio graph using snapshot_render_graph(). This snapshot is represented as a RenderGraphDescription that is then consumed by RenderGraph / RenderGraphImpl to construct and process a graph of RenderNodes on the rendering thread via OfflineAudioRenderThread.

Follows the Web Audio API rendering loop specification and adds relevant spec steps as needed.

Only implements processing for ConstantSourceNode to keep the scope minimal.

Does not handle AudioParam processing/automation, suspend/resume, mixing, or graph updates.

Testing

  • TestWebAudioRenderGraph.cpp to test basic quantum rendering.
  • TestOfflineAudioRenderThread.cpp to test basic helper thread API.
  • 32 passing WPT to test basic rendering behavior of ConstantSourceNodes and currentTime incrementing.

@Prospero23 Prospero23 force-pushed the rendergraph-pr branch 4 times, most recently from 0780513 to e585366 Compare January 25, 2026 20:25
@Prospero23 Prospero23 changed the title LibWeb/WebAudio: Implement basic rendering loop LibWeb/WebAudio: Implement basic offline rendering loop Jan 26, 2026
@Prospero23 Prospero23 force-pushed the rendergraph-pr branch 3 times, most recently from 57ecdb9 to 34d1a14 Compare January 26, 2026 17:58
@Prospero23 Prospero23 marked this pull request as ready for review January 26, 2026 19:12
This adds graph construction, topology ordering, and per-quantum
processing based on the Web Audio rendering loop specification.
A minimal set of render nodes is supported, including Destination
and ConstantSource, with a fallback for unsupported node types.

Does not handle audio params, scheduling, or suspend/resume logic.

ConstantSource is used as a minimal probe node to validate graph
wiring, ordering, and per-quantum behavior.

Adds LibTest coverage exercising render graph behavior across
render quanta.
Creates a minimal snapshot of the WebAudio graph to avoid
accessing GC-managed AudioNode objects on the render thread.

This snapshot captures the destination node, supported source nodes
(ConstantSourceNode), and their connections.
AudioParam connections and rendering behavior are intentionally
not handled yet.
Introduce OfflineAudioRenderThread, a minimal helper for
offline rendering that runs a RenderGraphDescription snapshot
on a dedicated thread and writes the rendered samples into
per-channel buffers.

Render loop logic from spec is handled in render_a_quantum().

Adds a small unit test that verifies the thread completes
and publishes a result for a constant source graph.
Connects the render-thread infrastructure to OfflineAudioContext and
enables end-to-end offline rendering for simple graphs.

Adds 32 passing WPT covering basic offline rendering behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants