Follow-up from #536's final review (Important #2).
renderToneOffline swaps Tone's global context (setContext(offlineContext)) for the whole offline graph build. Since #536 the build awaits real async work per WAM entry (ensureWamHost worklet load + cloneInstanceInto), so the window where app code creating Tone nodes (track add, effect-chain mutation, recording arm) lands on the offline context grew from ~1 microtask (upstream Tone.Offline) to 100ms–1s. Exports themselves are serialized (module-level queue in renderToneOffline), and the docs carry a don't-mutate-mid-export caveat, but the structural fix is:
Two-phase buildOfflineChain: clone all WAM entries against the raw OfflineAudioContext before the setContext swap — ensureWamHost/cloneInstanceInto take the context explicitly and don't need the global swap; only the synchronous Tone-node creation does. That shrinks the swapped window back to roughly upstream's exposure.
Refs: packages/browser/src/utils/renderToneOffline.ts, packages/browser/src/effects/offlineChain.ts, packages/browser/src/hooks/useExportWav.ts (renderOffline).
Follow-up from #536's final review (Important #2).
renderToneOfflineswaps Tone's global context (setContext(offlineContext)) for the whole offline graph build. Since #536 the build awaits real async work per WAM entry (ensureWamHostworklet load +cloneInstanceInto), so the window where app code creating Tone nodes (track add, effect-chain mutation, recording arm) lands on the offline context grew from ~1 microtask (upstreamTone.Offline) to 100ms–1s. Exports themselves are serialized (module-level queue inrenderToneOffline), and the docs carry a don't-mutate-mid-export caveat, but the structural fix is:Two-phase
buildOfflineChain: clone all WAM entries against the rawOfflineAudioContextbefore thesetContextswap —ensureWamHost/cloneInstanceIntotake the context explicitly and don't need the global swap; only the synchronous Tone-node creation does. That shrinks the swapped window back to roughly upstream's exposure.Refs:
packages/browser/src/utils/renderToneOffline.ts,packages/browser/src/effects/offlineChain.ts,packages/browser/src/hooks/useExportWav.ts(renderOffline).