heygen-com/hyperframes · error · Error

audio FX runtime failed to load

Error message

audio FX runtime failed to load

What it means

Thrown inside page.evaluate() when window.__HF_AUDIO_FX is undefined after page.addScriptTag() injected the audio FX runtime script. The runtime is expected to register a global object with a render(planes, sampleRate, chainJson) method. If the script failed to parse, threw during execution, or didn't set the global, the API surface is absent.

Source

Thrown at packages/engine/src/services/audioFxRender.ts:244

      await page.goto(pathToFileURL(hostPage).href, { waitUntil: "domcontentloaded" });
      await page.addScriptTag({ content: getAudioFxRuntimeScript() });

      const rendered = (await page.evaluate(
        async ([channelB64, rate, chainJson]: [string[], number, string]) => {
          const decode = (b64: string): Float32Array => {
            const bin = atob(b64);
            const bytes = new Uint8Array(bin.length);
            for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
            return new Float32Array(bytes.buffer);
          };
          const api = (
            window as unknown as {
              __HF_AUDIO_FX?: {
                render(p: Float32Array[], r: number, c: string): Promise<Float32Array[]>;
              };
            }
          ).__HF_AUDIO_FX;
          if (!api) throw new Error("audio FX runtime failed to load");
          const out = await api.render(channelB64.map(decode), rate, chainJson);
          const encode = (plane: Float32Array): string => {
            const u8 = new Uint8Array(plane.buffer, plane.byteOffset, plane.length * 4);
            let s = "";
            const CHUNK = 0x8000;
            for (let i = 0; i < u8.length; i += CHUNK) {
              s += String.fromCharCode.apply(null, Array.from(u8.subarray(i, i + CHUNK)));
            }
            return btoa(s);
          };
          return out.map(encode);
        },
        [
          planes.map((plane) =>
            Buffer.from(plane.buffer, plane.byteOffset, plane.length * 4).toString("base64"),
          ),
          sampleRate,
          JSON.stringify(chain),

View on GitHub (pinned to c2996c8626)

Solutions

  1. Verify getAudioFxRuntimeScript() returns non-empty, valid JavaScript by logging its length and first 200 chars.
  2. Check the Chrome version supports AudioWorklet (Chrome 66+) and that the file:// page loaded (waitUntil: 'domcontentloaded' is used).
  3. Run the runtime script in a standalone HTML file in a browser and check the console for parse/runtime errors.
  4. If using a custom Chrome build, ensure JavaScript is not disabled (--disable-javascript flag must NOT be present).
Defensive patterns

Strategy: validation

Validate before calling

const script = getAudioFxRuntimeScript();
if (!script || script.length < 100) {
  throw new Error('Audio FX runtime script is empty or truncated');
}
// verify the script registers the global
if (!script.includes('__HF_AUDIO_FX')) {
  throw new Error('Audio FX runtime script does not register __HF_AUDIO_FX');
}

Try / catch

try {
  await applyAudioFxChain(inputWav, chain, outWav, opts);
} catch (err) {
  if (err instanceof AudioFxRenderError && err.message.includes('runtime failed to load')) {
    // check Chrome version, CSP, or bundle integrity
  }
  throw err;
}

Prevention

When it happens

Trigger: applyAudioFxChain() calls page.addScriptTag({ content: getAudioFxRuntimeScript() }) then page.evaluate() which dereferences window.__HF_AUDIO_FX. If addScriptTag silently failed (e.g., the page navigated away, the script content was empty/malformed, or a Content Security Policy blocked inline scripts), __HF_AUDIO_FX is never set.

Common situations: The getAudioFxRuntimeScript() function returned an empty or truncated string due to a bundling issue. A browser extension or CSP header blocked inline script evaluation. The headless Chrome version doesn't support AudioWorklet (the script may depend on it). The file:// host page didn't load before addScriptTag ran.

Related errors


AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12). Data as JSON: /api/errors/3e1ec3ab4fe49bd4. Report an issue: GitHub.