1

I have a webpage index.php which contains a link to sound.php. On sound.php, sound is played using SoundJS.

When I navigate from sound.php to index.php, Google Chrome usually (but not always) displays an error message ("Aw, Snap!"): https://support.google.com/chrome/answer/95669?hl=en

I'm using Chrome 40 for Mac OS. It doesn't matter whether I use a link or the browser's back button.

Here's my code:

sound.php calls a JS function that's using SoundJS:

<script type="text/javascript">      
  var int = [0, 7];
  prepareAudio();  
</script>

As soon as I delete this code, the browser doesn't crash anymore.

prepareAudio() is in an external file:

function prepareAudio() {   

  // Try WebAudio or HTMLAudio
  createjs.Sound.initializeDefaultPlugins();

  // Try flash otherwise
  if (!createjs.Sound.isReady()) {
    // Flash plug-in is not default
    createjs.FlashPlugin.swfPath = "../audio/";

    // Enable flash support
    $.getScript("../../js/flashplugin-0.6.0.min.js");

    // Prefer WebAudio over HTMLAudio. Prefer HTMLAudio over Flash.
    createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashPlugin]);
    }

  // Get audio files
  var audioPath = "../audio/";

  var manifest = [];
  for (var i = 0; i< audioFiles.length; i++)
    manifest.push({id: audioFiles[i], src: audioPath + audioFiles[i] + ".ogg"});

  // Play audio 
  var queue = new createjs.LoadQueue(); 
  createjs.Sound.alternateExtensions = ["mp3"];
  queue.installPlugin(createjs.Sound);
  queue.addEventListener("complete", function() {playTask(int);});
  queue.loadManifest(manifest);
  createjs.Sound.registerSounds(manifest, audioPath);
}

There's some more code involved. I play sounds using

  createjs.Sound.play(mySound); 

Audio playback is fine in Chrome and other browsers.

Pida
  • 928
  • 9
  • 32
  • This sounds like an issue more with Chrome's handling of your sound setup. "Aw, Snap!"s like these are bugs in Chrome and treated seriously, so file a bug report in the Chromium bug tracker. – apscience Feb 08 '15 at 23:11
  • 2
    I was able to consistently reproduce this in Chrome 40 OSX using the [SoundJS Audio Test Suite](http://www.createjs.com/#!/Demos/SoundJS/Audio-Test-Suite) by starting a few looping sounds then hitting the back button. After restarting Chrome though, I can no longer reproduce. This suggests to me that it may be memory related. Perhaps Chrome's GC for WebAudio has a crash bug? Might be worth filing a bug with them. – gskinner Feb 08 '15 at 23:57
  • This appears to be fixed in the latest release of Chrome 40.0.2214.115 – OJay Feb 19 '15 at 18:33

3 Answers3

3

As gskinner pointed out, the problem can be reproduced on other websites. It can also be reproduced on pages that only use a single audio resource.

The problem is specific to Chrome 40 (or at least very recent versions of Chrome). It is not specific to certain versions of SoundJS.

Using another browser seems to be the only solution.

Pida
  • 928
  • 9
  • 32
  • 1
    this seems to be related: http://stackoverflow.com/questions/28393885/why-would-my-app-crash-in-chrome-if-i-refresh-a-few-times/28458945#28458945 – OJay Feb 11 '15 at 17:44
  • 1
    This appears to be fixed in the latest release of Chrome 40.0.2214.115 – OJay Feb 19 '15 at 18:27
0

When a page loses focus, chrome reduces the amount of available resources to your page. Usually, this isn't that big of a deal, but when you are dealing with sounds, it can cause some really odd behavior.

You can detect when a page loses focus with the window.onblur. You should try reducing the resources your javascript is using when the window loses focus. If that works, you found your culprit. If not, you should probably submit a bug report to google.

  • Do you assume both pages are open at the same time? That's not the case. All pages open in the same window/tab. So when I click on the link to index.php, sound.php is closed and shouldn't use any resources at all. – Pida Feb 08 '15 at 23:22
0

It appears to be fixed in new Chrome release 40.0.2214.115, but a workaround done by OJay here helped me to overcome this issue prior to this Chrome fix :

var isChrome40 = navigator && navigator.userAgent &&
navigator.userAgent.match("40.0.2214.111");
if (isChrome40) {
    createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);
}`
NenadP
  • 585
  • 7
  • 24