fix: Lỗi không có âm thanh - quay lại ScriptProcessor vĩnh viễn (worklet push-model bị nghẽn main thread -> câm)
This commit is contained in:
@@ -86,16 +86,18 @@
|
||||
|
||||
console.log("[SonicSF] AudioCtx state:", _audioCtx.state, "sampleRate:", _audioCtx.sampleRate);
|
||||
|
||||
// Use the AudioWorklet (fluidsynth-bridge) — ScriptProcessor
|
||||
// is deprecated and logs a console warning. The worklet is
|
||||
// now mono-safe (handles 1/2/N channel outputs) and the node
|
||||
// is forced stereo, and the URL is cache-busted so the fixed
|
||||
// module always loads. Falls back to ScriptProcessor if the
|
||||
// worklet cannot be created (older browsers).
|
||||
var _useScriptNode = false;
|
||||
// ── Renderer selection ──
|
||||
// ScriptProcessor is the default and FINAL choice: it is
|
||||
// pull-based (onaudioprocess is invoked by the audio thread),
|
||||
// so it cannot starve when the main thread is busy (font
|
||||
// loading, WASM decode, UI). The AudioWorklet push model
|
||||
// (setInterval on the main thread) starves under load and
|
||||
// produces SILENCE on this machine — repeatedly confirmed.
|
||||
// The deprecation console warning is purely cosmetic.
|
||||
var _useScriptNode = true;
|
||||
try {
|
||||
await _audioCtx.audioWorklet.addModule('/static/js/worklets/fluidsynth-bridge.js?v=202608031315');
|
||||
console.log("[SonicSF] Worklet registered OK");
|
||||
await _audioCtx.audioWorklet.addModule('/static/js/worklets/fluidsynth-bridge.js?v=202608031240');
|
||||
console.log("[SonicSF] Worklet registered OK (unused)");
|
||||
} catch (e) {
|
||||
console.warn("[SonicSF] Worklet reg failed:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user