v158 · web audio · enabled by default
OfflineAudioContext incremental rendering
OfflineAudioContext.startRendering() now takes an optional chunkSize argument. Each call renders at most that many sample-frames of the audio graph into a fresh AudioBuffer and resolves with it, so you can render, encode and discard audio a piece at a time instead of allocating the whole render up front. A context can also be created with length: null to render for an open-ended duration, and the new close() method stops such a render. Long exports — a two-hour stereo mix at 48 kHz is about 2.8 GB of float samples in one buffer — now fit in a few megabytes per chunk.
At a glance
| Shipped in | Chrome 158 (desktop, Android, Android WebView; no iOS milestone recorded) — filed under “Enabled by default” in the milestone=158 listing; per-platform milestones from the ChromeStatus API record |
|---|---|
| Runtime flag | OfflineAudioContextIncrementalRendering, status stable in Blink’s runtime_enabled_features.json5 (verified 2026-11-22). The flag gates startRendering(chunkSize), close() and constructing without a length. |
| Exposure | [Exposed=Window] only — not in workers (Chromium also throws NotSupportedError “Workers are not supported.”) |
| Specification | Web Audio API 1.1 — startRendering(chunkSize); added by WebAudio/web-audio-api#2675, from proposal issue #2445 |
| Explainer | MSEdgeExplainers — OfflineAudioContext incremental rendering (note: its length: Infinity sketch predates the shipped length: null design; see indefinite length) |
| Blink-dev | Intent to Prototype · Intent to Ship · TAG review #1282 |
| Tracking bug | issues.chromium.org/530596178 |
| Web platform tests | offlineaudiocontext-incremental-rendering.html · …-data-integrity.html · offlineaudiocontext-close.html |
| ChromeStatus | 5109900936085504 — OfflineAudioContext incremental rendering |
Syntax
The OfflineAudioContext interface and its options dictionary as they now read in the Editor’s Draft (IDL verbatim, fetched 2026-11-22). The three changes from Web Audio 1.0 are the chunkSize argument, the nullable length (attribute and dictionary member) and the close() method:
[Exposed=Window]
interface OfflineAudioContext : BaseAudioContext {
constructor(OfflineAudioContextOptions contextOptions);
constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate);
Promise<AudioBuffer> startRendering(optional unsigned long? chunkSize = null);
Promise<undefined> resume();
Promise<undefined> suspend(double suspendTime);
Promise<undefined> close();
readonly attribute unsigned long? length;
attribute EventHandler oncomplete;
};
dictionary OfflineAudioContextOptions {
unsigned long numberOfChannels = 1;
unsigned long? length = null;
required float sampleRate;
(AudioContextRenderSizeCategory or unsigned long) renderSizeHint = "default";
};
Chromium declares the same surface as two overloads — startRendering() and a runtime-flagged startRendering(unsigned long? chunkSize) — with a TODO to collapse them into the spec’s single optional form; script sees no difference.
| Member | What changed |
|---|---|
startRendering(chunkSize) | Optional chunkSize; may be called repeatedly; each call resolves with the next chunk of frames. Calls queue and resolve in order. |
close() | New. Stops rendering, rejects queued chunks with AbortError, moves state to "closed". |
OfflineAudioContextOptions.length | Now unsigned long?, default null: omit it for an open-ended render. |
OfflineAudioContext.length | Now nullable: null for an indefinite-length context. |
How chunked rendering works
The context keeps two counters: committed frames (frames promised to some startRendering() call) and rendered frames. Each call works out a buffer length, allocates an AudioBuffer of exactly that length, adds it to a FIFO queue and returns a promise; the rendering thread fills the queued buffers one after another and resolves each promise with its buffer. The chunk length is decided at call time:
Context length | chunkSize omitted / null | chunkSize given |
|---|---|---|
| A number (finite render) | All remaining frames — the classic one-shot render | chunkSize rounded up to a multiple of the render quantum size, trimmed to the frames still remaining |
null, indefinite | One render quantum (128 frames by default) | chunkSize rounded up to a multiple of the render quantum size |
A finite context closes itself once its final chunk has been delivered (and fires the legacy complete event with that final chunk); further startRendering() calls reject with InvalidStateError. An indefinite context never finishes on its own: you stop it with close(). Between chunks the graph does not advance, and state stays "running" — rendering simply waits for the next call. Full rules, including errors and the suspend() interaction, are on the startRendering(chunkSize) page.
Memory math. An AudioBuffer holds 32-bit floats, so a chunk costs numberOfChannels × frames × 4 bytes. Two hours of stereo at 48 kHz is 345,600,000 frames — 2,764,800,000 bytes as one buffer; ten-second chunks of 480,000 frames are 3,840,000 bytes each, and you can drop each one once it has been encoded or written.
Feature detection
Passing an extra argument to an older startRendering() is silently ignored: an old build renders the whole buffer in one go and resolves once. Detect support before relying on chunks. The explainer recommends checking for close(), which Chromium gates behind the same runtime flag as chunkSize:
const supportsIncrementalRendering =
typeof OfflineAudioContext !== 'undefined' &&
'close' in OfflineAudioContext.prototype;
Source: “It’s possible to feature detect by checking for the presence of the close method” — explainer, Proposed Approach → Pros; shared RuntimeEnabled=OfflineAudioContextIncrementalRendering in Chromium offline_audio_context.idl
Examples
Exporting a long render in fixed-size chunks
const sampleRate = 48000;
const ctx = new OfflineAudioContext({
numberOfChannels: 2,
sampleRate,
length: sampleRate * 60 * 60 * 2, // two hours, finite
});
// ...build the graph: sources, effects, ctx.destination...
const CHUNK = sampleRate * 10; // 480000 frames: a multiple of 128
let rendered = 0;
while (rendered < ctx.length) {
const chunk = await ctx.startRendering(CHUNK); // AudioBuffer
rendered += chunk.length; // last chunk is shorter
await encodeAndWrite(chunk); // your encoder / file writer
}
console.log(ctx.state); // "closed" — a finite context closes itself
Rendering until you decide to stop
// No length: an indefinite-length context (ctx.length === null)
const ctx = new OfflineAudioContext({ numberOfChannels: 1, sampleRate: 44100 });
const osc = new OscillatorNode(ctx, { frequency: 440 });
osc.connect(ctx.destination);
osc.start();
while (ctx.currentTime < 30) {
const chunk = await ctx.startRendering(4096); // 4096 frames per chunk
analyse(chunk.getChannelData(0));
}
await ctx.close(); // required: an indefinite context never closes itself
length: Infinity to the shipped length: null); the author’s own sample page is linked from ChromeStatus
Browser compatibility
BCD api/OfflineAudioContext.json records close (tagged web-features:offline-audio-context-incremental-rendering, marked experimental) but has no sub-feature for the chunkSize argument or a nullable length (checked 2026-11-22). Those two columns are therefore interim, from ChromeStatus and the shared Chromium runtime flag.
| Browser | close() (BCD) | startRendering(chunkSize) | length: null |
|---|---|---|---|
| Chrome | 158 | 158 (interim: ChromeStatus) | 158 (interim: ChromeStatus) |
| Chrome Android | 158, mirrored | 158 (interim) | 158 (interim) |
| Android WebView | 158, mirrored | 158 (interim) | 158 (interim) |
| Edge | 158, mirrored | Unknown — expected with Chromium 158, not separately recorded | Unknown |
| Firefox | No | No | No |
| Safari / iOS | No | No | No |
Standards positions: Mozilla standards-positions#1456 (ChromeStatus records “Positive”, noting Mozilla reviewed the spec change, though no formal position is posted); WebKit standards-positions#724 (“No signal”). The OfflineAudioContext interface itself is Baseline widely available, so classic one-shot startRendering() remains the cross-browser fallback.
Security and privacy
No permission, user gesture or secure context is required, and no new data reaches the page: chunks contain exactly the samples a one-shot render would have produced, only delivered in pieces. The practical effect is defensive — a page no longer needs a multi-gigabyte allocation (which the explainer notes can get the tab terminated) to render long audio. The Web Audio specification’s existing privacy considerations (fingerprinting via DSP output differences) apply unchanged to offline rendering; the sources read do not identify any new privacy surface from chunking. Member-level notes are on each child page.
Source: Web Audio API 1.1 §8 — Privacy Considerations; explainer — User-Facing ProblemSpecifications
| Specification | Sections |
|---|---|
| Web Audio API 1.1 (Editor’s Draft) | startRendering(chunkSize) · close() · length attribute · OfflineAudioContextOptions.length |
See also
- MDN: OfflineAudioContext.startRendering() — documents the one-shot form only; MDN has no
chunkSizeparameter and itsclose()page returns 404 (checked 2026-11-22) - chrome-platform-showcase: OfflineAudioContext incremental rendering (four concept demos)
- Explainer · original proposal (#2445) · spec PR #2675
- ChromeStatus — OfflineAudioContext incremental rendering (5109900936085504)