IOS地图加载异常Main Thread Checker:[AGSRequestOperation kickoffConnection]

地图页面load后,调试出现如下异常:

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]

PID: 3317, TID: 82294, Thread name: Runtime Network Callback Thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

Backtrace:

4 FQArcGISProj 0x000000010cfe5340 -[AGSRequestOperation kickoffConnection] + 1072

5 Foundation 0x00007fff208515d7 __NSThreadPerformPerform + 179

6 CoreFoundation 0x00007fff203724a7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

7 CoreFoundation 0x00007fff2037239f __CFRunLoopDoSource0 + 180

8 CoreFoundation 0x00007fff2037186c __CFRunLoopDoSources0 + 242

9 CoreFoundation 0x00007fff2036bf68 __CFRunLoopRun + 871

10 CoreFoundation 0x00007fff2036b704 CFRunLoopRunSpecific + 562

11 Foundation 0x00007fff20828049 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213

12 FQArcGISProj 0x000000010d0cf318 -[AGSThreadTargetImpl mainRoutine] + 264

13 Foundation 0x00007fff208511a1 __NSThread__start__ + 1009

14 libsystem_pthread.dylib 0x00007fff701cb4e1 _pthread_start + 125

15 libsystem_pthread.dylib 0x00007fff701c6f6b thread_start + 15

2023-01-11 16:20:29.480230+0800 FQArcGISProj[3317:82294] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]

PID: 3317, TID: 82294, Thread name: Runtime Network Callback Thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

Backtrace:

4 FQArcGISProj 0x000000010cfe5340 -[AGSRequestOperation kickoffConnection] + 1072

5 Foundation 0x00007fff208515d7 __NSThreadPerformPerform + 179

6 CoreFoundation 0x00007fff203724a7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

7 CoreFoundation 0x00007fff2037239f __CFRunLoopDoSource0 + 180

8 CoreFoundation 0x00007fff2037186c __CFRunLoopDoSources0 + 242

9 CoreFoundation 0x00007fff2036bf68 __CFRunLoopRun + 871

10 CoreFoundation 0x00007fff2036b704 CFRunLoopRunSpecific + 562

11 Foundation 0x00007fff20828049 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213

12 FQArcGISProj 0x000000010d0cf318 -[AGSThreadTargetImpl mainRoutine] + 264

13 Foundation 0x00007fff208511a1 __NSThread__start__ + 1009

14 libsystem_pthread.dylib 0x00007fff701cb4e1 _pthread_start + 125

15 libsystem_pthread.dylib 0x00007fff701c6f6b thread_start + 15

(lldb)

在左侧窗口可以定位到错误地址,如下所示:

这是调用的第三方库UI不能在后台线程中执行,之前的版本都没问题,可能是IOS13以后新增加的检测。

参考:Main Thread Checker: UI API called on a background thread_skylin19840101的博客-CSDN博客

某些第三方带源码的库手动修改没问题。

但是,ArcGIS我用的是10.25版本,如果更新到最新版本100以上,改动特别大,因此,选择关闭主线程检测功能。

关闭方式:

Edit Scheme -> Diagnostics -> RuntimelyAPI Checking -> Main Thread Checker。去掉Main Thread Checker前面的对勾。

如下图所示:

只有在调试时才有这个选项,在Archive版本中没有。

参考:Xcode9 新特性之Main Thread Checker - 简书 (jianshu.com)

关闭了主线程检测后,调试时不提示错误了,但到那里仍然崩溃。

经过对代码的排查,发现是加载底图时出错了,底图时作为静态图层加载的,运行有后台线程。

ArcGIS sdk用的是10.25版本,升级100以上太麻烦了。

经过内测,发现真机都没问题,但是模拟器不行。

有没有大神可以指导一下,怎么跳过主线程检测呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值