AudioManager skips foreground recovery between sounds when no sources are playing

Aperta
#3,109 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

The issue points to packages/core/src/audio/AudioManager.ts, especially _onVisibilityChange() and its foreground recovery guard. Read that code first, then locate the engine regression suite and cover the silent interval, explicit caller suspension, and cold-context cases described here. Done when those cases verify recovery only for a previously running context without overriding explicit suspension or creating a cold context.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

An already unlocked/running AudioContext is suspended when the page becomes hidden, but AudioManager skips foreground recovery if no AudioSource is currently playing (_playingCount === 0). This can leave a state-aware ambient-audio controller waiting for a running context until another explicit resume/user interaction.

This is distinct from #3098: that PR allows a real gesture to supersede a pending programmatic resume. In this case, the foreground recovery attempt is never started.

Reproduction
  1. Within a real user gesture, successfully await AudioManager.resume().
  2. Leave no sources playing (for example, all one-shots have ended or the soundscape is currently silent).
  3. Hide the page. _onVisibilityChange() suspends the existing context.
  4. Return to the foreground and wait beyond the 100 ms recovery delay.
  5. Observe that the context remains suspended and no new native resume() is issued. A controller that only starts new environmental voices while the context is running cannot restart them automatically.

Calling AudioManager.resume() explicitly can recover it; this is not a claim that every later direct AudioSource.play() necessarily fails.

Expected

Recover a previously running context after a visibility-induced suspension, including intervals between sounds. Preserve explicit caller AudioManager.suspend() semantics, do not create/unlock a cold context on page visibility alone, and retain the gesture fallback required by browser policy.

Evidence

Checked the actual AudioManager source at #3098 HEAD 788e6f5b8c694f3eb2c1c5677b52dae925005778:

  • Visibility suspension and recovery guard: hidden suspends the context unconditionally if it exists, while foreground recovery returns early for _playingCount <= 0.
  • Executed that source with a mocked AudioContext and visibility events, after successfully resuming once:
State before hide State after showing and waiting 160 ms Total native resume calls
0 playing sources, no explicit suspend suspended 1
1 playing source, no explicit suspend running 2
0 playing sources, explicit caller suspend suspended 1

The mechanism is deterministically reproduced with mocked audio hardware; this report does not claim physical iOS validation. Please cover the silent interval, explicit suspension, and cold-context cases in the engine regression suite.

Lingua principale
TypeScript
Stelle
5.9k
Fork
413
Merge medio
16h 17m
PR unite (30g)
41

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di galacean/engine

Tutte le issue di galacean/engine

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.