CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

Static play API cuts off sounds in Chrome 67 #302

Closed novwhisky closed 5 years ago

novwhisky commented 6 years ago

Issue Details

Note, this issue is not about Chrome's auto-play policy change, though it may relate to their rollback.

Using createjs.Sound.registerSound/createjs.Sound.play to play a sequence of MP3s will occasionally cause audio to cut off. Investigating further I found that there's a correlation between advancing sounds while Chrome's speaker icon is fading out. (i.e. the AudioContext disconnecting) The issue will not manifest if you click through very rapidly or conversely, wait for the previous source to fully disconnect.

No, however attempting to console.log instance.sourceNode (even while DevTools are closed) causes the problem not to manifest, as though the additional function calls were enough to defer the event to a subsequent frame in the event loop.

I'm hoping switching to PreloadJS' LoadQueue might not be subject to the same issue and will try that next.

I've created an isolated test case at http://gallery.wi.tt/createjs-chrome-67/. Note that DevTools should not be open. This obviously makes it difficult to debug; In some cases (other than that mentioned above) I've found I can console.log certain data and then wait for the issue to reproduce before opening DevTools to see what's in the console.

realjck commented 6 years ago

I'm experiencing the same issue while using createjs.LoadQueue for sounds preload.

novwhisky commented 6 years ago

No-opping this if branch seems to prevent the issue from happening.

https://github.com/CreateJS/SoundJS/blob/357d48c0b8a9a8ffcdc6c68c6c4f757ff18737b7/src/soundjs/webaudio/WebAudioSoundInstance.js#L230-L242

Of course, that'll prevent a lot of objects from GCing and eventually lead to a leak so I'm looking into the call stacks leading up to _cleanUpAudioNode()

novwhisky commented 6 years ago

Update: this appears to be a regression in Chrome that seems to be resolved in the latest beta (68.0.3440.25) https://bugs.chromium.org/p/chromium/issues/detail?id=849189

Tiogshi commented 6 years ago

I'm using the Web Audio plugin for SoundJS, and using PreloadJS's load queue to preload assets coming up soon as well... and am noticing any current sound audibly cut off at the same moment that sound files finish preloading. However, the sounds which get muted are apparently still "running", as I am seeing the complete events for those sounds still get triggered.

Hoping mainline 68 includes the fix.

truonghongtrieu commented 5 years ago

I'm so glad that I found this discussion for the issue.

I'm using Chrome 68 and everything works perfectly fine now! Release on July 25, 2018: https://developers.google.com/web/updates/2018/07/nic68 Change list: https://chromium.googlesource.com/chromium/src/+/af747db680d72a467a49516384286fb31b2f681a

realjck commented 5 years ago

Since three years we develop e-learning webapps with CreateJS. Theses apps play audio dialogs all along (With a succession of 10-20 seconds length mp3).

In our case this issue with Chrome 67 was a major one during the last two months. Our e-learning webapps were having sound cuts each minute and they became unusable on Chrome. I had to inform my clients to tell their students to switch to other browsers until Chromium pushes a new version.

I'm glad that this have been fixed, and hope that the Chromium team understood how this bug have appeared to prevent a similar issue from happening again.

lannymcnie commented 5 years ago

Glad Google sorted it out. Feel free to reopen if the problem persists past Chrome 67.