Testing new OfflineAudioContext#7255
Testing new OfflineAudioContext#7255gonzalezgonzalezjorgeluis71-tech wants to merge 1 commit intophaserjs:masterfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 5 potential issues.
Bugbot Free Tier Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
|
||
| // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 | ||
| this.config.context.decodeAudioData(this.xhrLoader.response, | ||
| this.config.offlineContext.decodeAudioData(this.xhrLoader.response, |
There was a problem hiding this comment.
Config property name mismatch causes audio decoding crash
High Severity
The onProcess method accesses this.config.offlineContext but the config object is constructed at line 61 with the property name context (i.e., { context: audioContext }). Since offlineContext was never set on the config, this will be undefined, and calling decodeAudioData on undefined will throw a runtime error. Every audio file load will crash.
| BaseSoundManager.call(this, game); | ||
|
|
||
| if (this.locked && game.isBooted) | ||
| this.locked = this.offlineContext.state === 'suspended'; |
There was a problem hiding this comment.
OfflineAudioContext always suspended prevents AudioContext creation
High Severity
An OfflineAudioContext always starts in 'suspended' state per the Web Audio API spec, so this.locked at line 90 will always be true. This means createAudioContext() in the else branch (line 107) is never called. Meanwhile, the unlockHandler has the createAudioContext() call commented out (lines 347–350) and checks if (_this.context && body) — which is always false since context remains null. The AudioContext is never created, so audio can never play.
Additional Locations (1)
| if (this.locked && game.isBooted) | ||
| this.locked = this.offlineContext.state === 'suspended'; | ||
|
|
||
| console.log('SM locked', this.locked); |
There was a problem hiding this comment.
Debug console.log statements left in production code
Medium Severity
Multiple console.log debug statements were left in the code: 'SM locked' (line 92), 'createAudioContext' (line 125), 'decodeAudio' (line 243), 'SM unlock' (line 337), and 'SM unlockHandler invoked' (line 345). These are clearly development/debugging aids that don't belong in production code for a framework library.
Additional Locations (2)
| */ | ||
| unlock: function () | ||
| { | ||
| console.log('SM unlock'); |
There was a problem hiding this comment.
decodeAudio calls method on null context reference
High Severity
The decodeAudio method calls this.context.decodeAudioData(...) at line 298, but this.context can now be null since the AudioContext creation is deferred. If decodeAudio is called before the context is created (which is likely given the locked-state logic issues), this will throw a TypeError.
|
|
||
| set: function (value) | ||
| { | ||
| this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); |
There was a problem hiding this comment.
Missing null check on context in destroy method
Medium Severity
The destroy method's first branch checks this.game.config.audio.context (the config value) and then calls this.context.suspend() without null-checking this.context. Since this.context now starts as null and may never be assigned (due to the deferred creation), calling suspend() on null will throw a TypeError. The else if branch correctly guards with this.context, but this branch does not.


Please do not update the README or Change Log, we will do this when we merge your PR.
This PR (delete as applicable)
Describe the changes below:
Note
High Risk
Touches core WebAudio initialization/locking and decoding pathways; incorrect context creation or missing
offlineContextwiring can break all audio playback or decoding across browsers.Overview
Switches audio decoding for
AudioFileto use anOfflineAudioContext(config.offlineContext.decodeAudioData) instead of decoding on the live playback context.Refactors
WebAudioSoundManagerto create and track a newofflineContext, defer creation of the playbackAudioContextuntil unlocked/needed, and make globalmute/volumeresilient when master nodes aren’t created yet (store_mute/_volume, null-guard node usage, saferdestroy/update/onBlur).Also tweaks
WebAudioSoundmissing-audio error text and adds several debugconsole.logstatements in the sound manager.Written by Cursor Bugbot for commit 75ebcea. This will update automatically on new commits. Configure here.