无法找到导致“活动断言超出允许时间”的错误碰撞

发布于 2024-12-17 00:08:03 字数 4825 浏览 1 评论 0原文

我收到以下崩溃日志,显示我的应用程序有“超出允许时间的活动断言”。我的应用程序是一个音频流应用程序。仅当应用程序在后台且不传输任何音频内容时才会发生崩溃。

注意:

  • 我确保 applicationDidEnterBackground 中的 beginBackgroundTaskWithExpirationHandler 在 applicationWillEnterForeground 中具有相应的 endBackgroundTask 。
  • 所有网络访问都在自己的线程上,而不是在主线程上。
  • 当应用程序位于后台时,任何线程都不会尝试访问网络。
  • 该错误是随机的,并且无法通过将设备切换到飞行模式或关闭 WiFi 来重复。

关于如何追踪这个问题有什么建议吗?

这是崩溃日志(没有二进制图像):

Incident Identifier: 0467A340-1FD2-4D49-9FA4-76360889976D
CrashReporter Key:   fdae46f133d13bdc3f043301bc008bd56155588d
Hardware Model:      iPhone3,1
Process:         MyApp [249]
Path:            /var/mobile/Applications/DAA6B446-07D3-4C7C-BD44-80920338CAF4/MyApp/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-11-17 15:25:59.960 -0500
OS Version:      iPhone OS 5.0.1 (9A405)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  4

Application Specific Information:
MyApp[249] has active assertions beyond permitted time: 
{(
    <SBProcessAssertion: 0xfed8890> identifier: UIKitBackgroundCompletionTask process: MyApp[249] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:249 preventSuspend  preventIdleSleep 
)}

Elapsed total CPU time (seconds): 10.700 (user 10.700, system 0.000), 2% CPU 
Elapsed application CPU time (seconds): 0.024, 0% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d711a 0x3434b000 + 573722
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   GraphicsServices                0x30bdefc6 0x30bdb000 + 16326
7   UIKit                           0x377db73c 0x377aa000 + 202556
8   MyApp                       0x000024de main (main.m:14)
9   MyApp                       0x0000249c start + 32

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x3630f3b4 0x3630e000 + 5044
1   libdispatch.dylib               0x37039e78 0x3702d000 + 52856
2   libdispatch.dylib               0x37039b96 0x3702d000 + 52118

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d7154 0x3434b000 + 573780
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   WebCore                         0x3682e128 0x36786000 + 688424
7   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
8   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 3 name:  com.apple.coremedia.player.async
Thread 3:
0   libsystem_kernel.dylib          0x3631f068 0x3630e000 + 69736
1   libsystem_c.dylib               0x331aaf2e 0x3319b000 + 65326
2   libsystem_c.dylib               0x331aacaa 0x3319b000 + 64682
3   CoreMedia                       0x32306000 0x32303000 + 12288
4   MediaToolbox                    0x35169fba 0x35166000 + 16314
5   CoreMedia                       0x32325bc6 0x32303000 + 142278
6   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
7   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d7154 0x3434b000 + 573780
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   Foundation                      0x35d5abc2 0x35d4a000 + 68546
7   Foundation                      0x35d5aa8a 0x35d4a000 + 68234
8   Foundation                      0x35dee59a 0x35d4a000 + 673178
9   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
10  libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 5 name:  com.apple.CFSocket.private
Thread 5:
0   libsystem_kernel.dylib          0x3631f570 0x3630e000 + 71024
1   CoreFoundation                  0x343dc66a 0x3434b000 + 595562
2   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
3   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Unknown thread crashed with unknown flavor: 5, state_count: 1

I am getting the following crash log that shows my app has "active assertions beyond permitted time". My app is an audio streaming app. The crash only occurs when the app is in the background and NOT streaming any audio content.

NOTES:

  • I ensured that beginBackgroundTaskWithExpirationHandler in applicationDidEnterBackground has a corresponding endBackgroundTask in applicationWillEnterForeground.
  • All network accesses are on their own thread and not on the main thread.
  • When the app is in the background there is no attempt by any thread to access the network.
  • The error is random and cannot be duplicated by switching device to airplane mode or turning off WiFi.

Any suggestions for how to track this down?

Here is the crash log (without binary images):

Incident Identifier: 0467A340-1FD2-4D49-9FA4-76360889976D
CrashReporter Key:   fdae46f133d13bdc3f043301bc008bd56155588d
Hardware Model:      iPhone3,1
Process:         MyApp [249]
Path:            /var/mobile/Applications/DAA6B446-07D3-4C7C-BD44-80920338CAF4/MyApp/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-11-17 15:25:59.960 -0500
OS Version:      iPhone OS 5.0.1 (9A405)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  4

Application Specific Information:
MyApp[249] has active assertions beyond permitted time: 
{(
    <SBProcessAssertion: 0xfed8890> identifier: UIKitBackgroundCompletionTask process: MyApp[249] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:249 preventSuspend  preventIdleSleep 
)}

Elapsed total CPU time (seconds): 10.700 (user 10.700, system 0.000), 2% CPU 
Elapsed application CPU time (seconds): 0.024, 0% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d711a 0x3434b000 + 573722
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   GraphicsServices                0x30bdefc6 0x30bdb000 + 16326
7   UIKit                           0x377db73c 0x377aa000 + 202556
8   MyApp                       0x000024de main (main.m:14)
9   MyApp                       0x0000249c start + 32

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x3630f3b4 0x3630e000 + 5044
1   libdispatch.dylib               0x37039e78 0x3702d000 + 52856
2   libdispatch.dylib               0x37039b96 0x3702d000 + 52118

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d7154 0x3434b000 + 573780
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   WebCore                         0x3682e128 0x36786000 + 688424
7   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
8   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 3 name:  com.apple.coremedia.player.async
Thread 3:
0   libsystem_kernel.dylib          0x3631f068 0x3630e000 + 69736
1   libsystem_c.dylib               0x331aaf2e 0x3319b000 + 65326
2   libsystem_c.dylib               0x331aacaa 0x3319b000 + 64682
3   CoreMedia                       0x32306000 0x32303000 + 12288
4   MediaToolbox                    0x35169fba 0x35166000 + 16314
5   CoreMedia                       0x32325bc6 0x32303000 + 142278
6   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
7   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x3630f010 0x3630e000 + 4112
1   libsystem_kernel.dylib          0x3630f206 0x3630e000 + 4614
2   CoreFoundation                  0x343d841c 0x3434b000 + 578588
3   CoreFoundation                  0x343d7154 0x3434b000 + 573780
4   CoreFoundation                  0x3435a4d6 0x3434b000 + 62678
5   CoreFoundation                  0x3435a39e 0x3434b000 + 62366
6   Foundation                      0x35d5abc2 0x35d4a000 + 68546
7   Foundation                      0x35d5aa8a 0x35d4a000 + 68234
8   Foundation                      0x35dee59a 0x35d4a000 + 673178
9   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
10  libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Thread 5 name:  com.apple.CFSocket.private
Thread 5:
0   libsystem_kernel.dylib          0x3631f570 0x3630e000 + 71024
1   CoreFoundation                  0x343dc66a 0x3434b000 + 595562
2   libsystem_c.dylib               0x331aac16 0x3319b000 + 64534
3   libsystem_c.dylib               0x331aaad0 0x3319b000 + 64208

Unknown thread crashed with unknown flavor: 5, state_count: 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单 2024-12-24 00:08:03

beginBackgroundTaskWithExpirationHandler 有一个您可能会超过的时间限制。您可以使用 UIApplicationbackgroundTimeRemaining 属性查看剩余时间。

beginBackgroundTaskWithExpirationHandler has a time limit that you may be exceeding. You can see how much time is remaning with UIApplication's backgroundTimeRemaining property.

晨敛清荷 2024-12-24 00:08:03

当应用程序通过 applicationWillEnterForeground() 返回前台时,您不能依赖于结束后台任务。 iOS 只允许 3 分钟在后台执行工作。这就是后台任务开始方法有一个过期处理程序的原因。当调用过期处理程序时,您应该(非常快地)清理任务并结束该任务(通过 endBackgroundTask):

UIBackgroundTaskIdentifier bkgndTask;
---
bkgndTask = [app beginBackgroundTaskWithExpirationHandler:^{
    if (bkgndTask != UIBackgroundTaskInvalid) {
        [[UIApplication sharedApplication] bkgndTask];
        bkgndTask = UIBackgroundTaskInvalid;
    }
}];

You can't rely on ending your background task when the app returns to the foreground via applicationWillEnterForeground(). iOS only allows 3 mins to perform work in the background. This is why the background task begin method has an expiration handler. You should cleanup up your task (very quickly) and end that task (via endBackgroundTask) when the expiration handler is called:

UIBackgroundTaskIdentifier bkgndTask;
---
bkgndTask = [app beginBackgroundTaskWithExpirationHandler:^{
    if (bkgndTask != UIBackgroundTaskInvalid) {
        [[UIApplication sharedApplication] bkgndTask];
        bkgndTask = UIBackgroundTaskInvalid;
    }
}];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文