javascriptgoogle-chromeaudiosoundjs

Leaving a webpage with SoundJS causes Google Chrome to crash


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.


Solution

  • 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.