From 9bc604bdd0359cae6c8f43bc6a6ad8b96bff4433 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 21:42:58 -0700 Subject: No speaker pop on opening the app: the zap sound decodes in an OfflineAudioContext and makes its real AudioContext on the first tap (one made at load ran at once in the installed app, re-opening the phone's audio output on every open/refocus), suspended again after the sound and when the app is hidden Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PCGjEEMD23CweKrefbTDJp --- tools/zap-feedback-test.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools') diff --git a/tools/zap-feedback-test.js b/tools/zap-feedback-test.js index 3fdd3bc..adc7663 100644 --- a/tools/zap-feedback-test.js +++ b/tools/zap-feedback-test.js @@ -110,6 +110,10 @@ try { await page.setViewport({ width: 390, height: 844 }); await page.goto(server.url.href); await page.waitForSelector('.note-zap'); + await pause(600); + // a live AudioContext opens the phone's speaker path (a pop on every open + // or refocus of the installed app) — none may exist before a tap + check('no audio context is opened before the first tap', await page.evaluate(() => zapAudio.context === null)); await page.click('.note-zap'); let s = await state(); check('tap starts effect and adds amount before payment settles', s.effects === 1 && s.tally === '121' && s.flying && s.calls === 1); @@ -204,6 +208,9 @@ try { await page.click('.note-zap'); await pause(100); check('with the sound off a tap still strikes and counts, silently', await page.evaluate((n, c) => zapAudio.starts === n && test.calls === c + 2 && !!document.querySelector('.zap-fx'), starts, calls)); await page.evaluate(() => test.finishArk(true)); await pause(100); + // the last sound was a while ago: the speaker path is closed again + await page.waitForFunction(() => zapAudio.context.state === 'suspended', { timeout: 6000 }).catch(() => {}); + check('the audio context is suspended again once the sound has played', await page.evaluate(() => zapAudio.context.state === 'suspended')); const silentPage = await browser.newPage(); silentPage.on('pageerror', e => errors.push(e.message)); await silentPage.evaluateOnNewDocument(() => { -- cgit v1.2.3