Bug Description
When the game is actively playing audio (background music or sound effects) and the browser tab is closed or navigated away, the audio context is not properly cleaned up. This causes the AudioContext to remain open in memory, leading to a memory leak and in some cases the audio continuing to play briefly after navigation.
Steps to Reproduce
- Start the game and let the background music begin
- Open browser DevTools → Memory tab
- Take a heap snapshot
- Close the game tab or navigate to another page
- Take another heap snapshot and compare
Expected Behavior
When the page unloads, the game should call audioContext.close() and remove all event listeners via a beforeunload or visibilitychange handler to properly clean up audio resources.
Actual Behavior
No cleanup handler exists for the audio context. The AudioContext object remains referenced in memory. On some browsers (Firefox), the background music continues for 1-2 seconds after tab close before the process is killed.
Root Cause (suspected)
The script.js file creates an AudioContext or uses HTML audio elements without attaching a window.addEventListener('beforeunload', ...) cleanup function. The audio nodes remain in an undisposed state.
Environment
- Chrome 122 / Firefox 124
- Windows 10 / macOS
- Reproducible on every session
Wallet: 0x964739472C587d24934c37BEbB405CeE36D59B24
Bug Description
When the game is actively playing audio (background music or sound effects) and the browser tab is closed or navigated away, the audio context is not properly cleaned up. This causes the AudioContext to remain open in memory, leading to a memory leak and in some cases the audio continuing to play briefly after navigation.
Steps to Reproduce
Expected Behavior
When the page unloads, the game should call
audioContext.close()and remove all event listeners via abeforeunloadorvisibilitychangehandler to properly clean up audio resources.Actual Behavior
No cleanup handler exists for the audio context. The AudioContext object remains referenced in memory. On some browsers (Firefox), the background music continues for 1-2 seconds after tab close before the process is killed.
Root Cause (suspected)
The script.js file creates an AudioContext or uses HTML audio elements without attaching a
window.addEventListener('beforeunload', ...)cleanup function. The audio nodes remain in an undisposed state.Environment
Wallet: 0x964739472C587d24934c37BEbB405CeE36D59B24