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:
2026-08-03 12:13:26 +07:00
parent 36edc9daca
commit 6018263044
3 changed files with 17 additions and 10 deletions
+11 -9
View File
@@ -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);
}
+1 -1
View File
@@ -16,7 +16,7 @@
<script src="/static/js/services/audioEngine.js?v=202607271016"></script>
<script src="/static/js/services/storage.js?v=202607271016"></script>
<script src="/static/js/services/soundfontStorage.js?v=202607271016"></script>
<script src="/static/js/services/soundfontPlayer.js?v=202608031330"></script>
<script src="/static/js/services/soundfontPlayer.js?v=202608031340"></script>
<script src="/static/js/services/aiGateway.js?v=202607271016"></script>
<script src="/static/js/services/dawCommandDispatcher.js?v=202607271016"></script>
<script src="/static/js/services/pianoRollTabService.js?v=202607272044"></script>