【问题标题】:NSSound crashing when trying to load a system sound尝试加载系统声音时 NSSound 崩溃
【发布时间】:2011-09-27 09:56:29
【问题描述】:

有时我的 Cocoa 应用程序在尝试加载系统声音时崩溃。我自己无法重现此问题,但一些用户向我发送了崩溃报告。

堆栈跟踪始终相同(见下文)。应用打开一个模态对话框,用户点击确定,声音加载完毕并崩溃:

[NSSound soundNamed:@"Hero"];

在网络上[1] 多次提及此问题,但没有解决方案。请注意,我正在从主线程加载声音,而不是尝试播放它。它立即崩溃。此外,声音文件本身没有损坏(我有一位用户通过电子邮件将其发送给我,它与我安装的那个匹配)。

崩溃日志摘录:

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000009a0d204

VM Regions Near 0x9a0d204:
    shared memory          0000000009310000-0000000009511000 [ 2052K] r--/r-- SM=SHM  
--> MALLOC_TINY            0000000009a00000-0000000009c00000 [ 2048K] rw-/rwx SM=COW  
    MALLOC_LARGE           0000000009c00000-000000000bc9c000 [ 32.6M] rw-/rwx SM=PRV  

Application Specific Information:
objc[8625]: garbage collection is OFF
Performing @selector(ok:) from sender NSButton 0x236510

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ???                             0x09a0d204 0 + 161534468
1   com.apple.audio.units.Components    0x7000ed9d AUHAL::AUHAL(ComponentInstanceRecord*, unsigned long, bool) + 775
2   com.apple.audio.units.Components    0x7002feff ComponentEntryPoint<DefaultOutputAU>::Dispatch(ComponentParameters*, DefaultOutputAU*) + 144
3   com.apple.CoreServices.CarbonCore   0x98487949 CallComponent + 223
4   com.apple.CoreServices.CarbonCore   0x98487992 CallComponentDispatch + 29
5   com.apple.CoreServices.CarbonCore   0x984f3b6c CallComponentOpen + 43
6   com.apple.CoreServices.CarbonCore   0x98486608 OpenAComponent + 426
7   com.apple.CoreServices.CarbonCore   0x98486688 OpenComponent + 24
8   com.apple.AppKit                0x9b810cd3 _initializeCA + 1115
9   com.apple.AppKit                0x9b811c23 -[NSSound _postInitialization] + 349
10  com.apple.AppKit                0x9b810609 -[NSSound initWithContentsOfURL:byReference:] + 263
11  com.apple.AppKit                0x9b812767 +[NSSound _searchForSoundNamed:] + 1044
12  com.apple.AppKit                0x9b8122de +[NSSound soundNamed:] + 227

1:http://lists.apple.com/archives/Cocoa-dev/2007/Oct/msg01159.html

【问题讨论】:

  • 向我们展示更多代码。你在哪里使用那个声音?...
  • 显示更多代码无济于事,回溯很清楚:+[NSSound soundNamed:] 在某些情况下会导致崩溃。

标签: cocoa crash crash-reports nssound


【解决方案1】:

您提到的问题的解决方案(或者更确切地说是解决方法)已应用于传输 changeset 3540不允许自定义声音,后来在 changeset 5577支持自定义用户声音在豹上

很遗憾,回溯不匹配,并且您的崩溃日志来自 Snow Leopard 或 Lion,因此这些解决方案可能不适用于您。我建议您向 Apple 提交bug report

【讨论】:

  • 谢谢!很高兴听到我不是唯一一个遇到这个问题的人。我最终为用户添加了一个禁用声音的选项。
猜你喜欢
  • 2018-07-31
  • 1970-01-01
  • 2019-09-10
  • 2012-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-27
  • 1970-01-01
相关资源
最近更新 更多