fix: run iOS audio primer synchronously in gesture handler, not in .then()

This commit is contained in:
Sterling Archer
2026-05-31 14:18:57 -07:00
parent 5f5507b538
commit d972122e27
+3 -2
View File
@@ -195,7 +195,7 @@ const SFX = (() => {
function primer() {
if (!ctx) ctx = new (window.AudioContext || window.webkitAudioContext)();
ctx.resume().then(() => {
try {
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.connect(gain);
@@ -203,7 +203,8 @@ const SFX = (() => {
gain.gain.setValueAtTime(0.0001, ctx.currentTime);
osc.start(ctx.currentTime);
osc.stop(ctx.currentTime + 0.001);
}).catch(() => {});
} catch(e) {}
if (ctx.state === 'suspended') ctx.resume().catch(() => {});
}
function unlock() {
if (!ctx) ctx = new (window.AudioContext || window.webkitAudioContext)();