Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用SoundJS留下网页会导致Google Chrome崩溃_Javascript_Google Chrome_Audio_Soundjs - Fatal编程技术网

Javascript 使用SoundJS留下网页会导致Google Chrome崩溃

Javascript 使用SoundJS留下网页会导致Google Chrome崩溃,javascript,google-chrome,audio,soundjs,Javascript,Google Chrome,Audio,Soundjs,我有一个网页index.php,其中包含指向sound.php的链接。在sound.php上,使用SoundJS播放声音 当我从sound.php导航到index.php时,Google Chrome通常(但不总是)会显示一条错误消息(“Aw,Snap!”): 我在Mac OS上使用Chrome40。无论我使用的是链接还是浏览器的后退按钮 这是我的代码: sound.php调用使用SoundJS的JS函数: <script type="text/javascript">

我有一个网页
index.php
,其中包含指向
sound.php
的链接。在
sound.php
上,使用SoundJS播放声音

当我从
sound.php
导航到
index.php
时,Google Chrome通常(但不总是)会显示一条错误消息(“Aw,Snap!”):

我在Mac OS上使用Chrome40。无论我使用的是链接还是浏览器的后退按钮

这是我的代码:

sound.php
调用使用SoundJS的JS函数:

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

在Chrome和其他浏览器中,音频播放效果良好。

当页面失去焦点时,Chrome会减少页面的可用资源量。通常,这没什么大不了的,但是当你处理声音时,它会导致一些非常奇怪的行为


您可以使用
窗口.onblur
检测页面何时失去焦点。当窗口失去焦点时,您应该尝试减少javascript使用的资源。如果这样做有效,你就找到了罪犯。如果没有,你可能应该向谷歌提交一份bug报告。

正如gskinner所指出的,这个问题可以在其他网站上重现。它也可以在只使用单一音频资源的页面上复制

这个问题是Chrome40(或者至少是最新版本的Chrome)特有的。它不是特定于某些版本的SoundJS


使用另一个浏览器似乎是唯一的解决方案。

新的Chrome版本40.0.2214.115似乎已经解决了这一问题,但OJay的解决方案帮助我在Chrome修复之前解决了这个问题:

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

这听起来更像是Chrome处理声音设置的问题。“哇,啪!”这些都是Chrome中的bug,需要认真对待,所以在Chrome bug跟踪器中提交一份bug报告。我能够在Chrome 40 OSX中通过启动一些循环声音,然后点击后退按钮,始终如一地重现这一点。重新启动Chrome后,我无法再复制。这对我来说可能与记忆有关。也许Chrome的Web音频GC有一个崩溃bug?可能值得向他们提交一个bug。这似乎在最新版本的Chrome 40.0.2214.115中得到了修复。您是否认为这两个页面同时打开?事实并非如此。在同一窗口/选项卡中打开的所有页面。因此,当我点击index.php的链接时,sound.php被关闭,不应该使用任何资源。这似乎是相关的:这似乎在Chrome 40.0.2214.115的最新版本中得到了修复
  createjs.Sound.play(mySound); 
var isChrome40 = navigator && navigator.userAgent &&
navigator.userAgent.match("40.0.2214.111");
if (isChrome40) {
    createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);
}`