发现极光推送iOS版api调用延迟问题记录

一句话概括就是:极光推送iOS版不使用地理围栏功能会导致api调用延迟

我这里使用的是最新版极光推送iOS 3.2.1版本,以sdk携带的PushTest Demo为例,在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中将以下代码注释掉:

//如果使用地理围栏,请先获取地理位置权限。
// [self getLocationAuthority];
// //如果使用地理围栏功能,需要注册地理围栏代理
// [JPUSHService registerLbsGeofenceDelegate:self withLaunchOptions:launchOptions];

即不使用地理围栏功能,然后运行App于前台,开始在网站上发起推送通知。首先Demo App顶部会显示通知栏,这个时候会触发 - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler 方法的调用,打印日志“ iOS10 前台收到远程通知 ”。

但是同时也会显示 Main Thread Checker 的警告:

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 95879, TID: 13312528, Thread name: org.hxhg.jiguang.thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 libobjc.A.dylib 0x00000001f4f4f894 + 56
5 CoreLocation 0x00000001fcd0a328 CLClientStopVehicleHeadingUpdates + 142084
6 CoreLocation 0x00000001fcce1434 CoreLocation + 5172
7 CoreLocation 0x00000001fcce1b24 CLClientCreateWithBundleIdentifierAndPathOnRunLoop + 128
8 CoreLocation 0x00000001fcce1a2c CLClientCreateWithBundleIdentifierAndPath + 320
9 CoreLocation 0x00000001fcced1c0 CLClientStopVehicleHeadingUpdates + 22940
10 CoreLocation 0x00000001fcced9c4 CLClientStopVehicleHeadingUpdates + 24992
11 PushTest 0x00000001020a93f0 -[JPUSHGeofenceManager init] + 84
12 PushTest 0x00000001020a92a4 __38+[JPUSHGeofenceManager sharedGeoFence]_block_invoke + 40
13 libdispatch.dylib 0x000000010248c1dc _dispatch_client_callout + 20
14 libdispatch.dylib 0x000000010248e2d0 _dispatch_once_callout + 108
15 PushTest 0x00000001020a9274 +[JPUSHGeofenceManager sharedGeoFence] + 56
16 PushTest 0x00000001020af420 -[JPUSHClientController handleRemoteNotification:] + 172
17 libobjc.A.dylib 0x00000001f4f4f604 + 68
18 Foundation 0x00000001f681ffb0 + 340
19 CoreFoundation 0x00000001f5ce8a50 + 28
20 CoreFoundation 0x00000001f5ce89cc + 92
21 CoreFoundation 0x00000001f5ce8284 + 180
22 CoreFoundation 0x00000001f5ce2f64 + 1032
23 CoreFoundation 0x00000001f5ce2844 CFRunLoopRunSpecific + 452
24 Foundation 0x00000001f66e45f0 + 304
25 Foundation 0x00000001f67213dc + 92
26 PushTest 0x0000000102040f24 +[JCOREQueueManager threadEntryPoint:] + 216
27 Foundation 0x00000001f66e31d0 + 72
28 Foundation 0x00000001f681fdbc + 1044
29 libsystem_pthread.dylib 0x00000001f595da04 + 132
30 libsystem_pthread.dylib 0x00000001f595d960 _pthread_start + 52
31 libsystem_pthread.dylib 0x00000001f5965df4 thread_start + 4
2019-07-30 14:05:39.709529+0800 PushTest[95879:13312528] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 95879, TID: 13312528, Thread name: org.hxhg.jiguang.thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 libobjc.A.dylib 0x00000001f4f4f894 + 56
5 CoreLocation 0x00000001fcd0a328 CLClientStopVehicleHeadingUpdates + 142084
6 CoreLocation 0x00000001fcce1434 CoreLocation + 5172
7 CoreLocation 0x00000001fcce1b24 CLClientCreateWithBundleIdentifierAndPathOnRunLoop + 128
8 CoreLocation 0x00000001fcce1a2c CLClientCreateWithBundleIdentifierAndPath + 320
9 CoreLocation 0x00000001fcced1c0 CLClientStopVehicleHeadingUpdates + 22940
10 CoreLocation 0x00000001fcced9c4 CLClientStopVehicleHeadingUpdates + 24992
11 PushTest 0x00000001020a93f0 -[JPUSHGeofenceManager init] + 84
12 PushTest 0x00000001020a92a4 __38+[JPUSHGeofenceManager sharedGeoFence]_block_invoke + 40
13 libdispatch.dylib 0x000000010248c1dc _dispatch_client_callout + 20
14 libdispatch.dylib 0x000000010248e2d0 _dispatch_once_callout + 108
15 PushTest 0x00000001020a9274 +[JPUSHGeofenceManager sharedGeoFence] + 56
16 PushTest 0x00000001020af420 -[JPUSHClientController handleRemoteNotification:] + 172
17 libobjc.A.dylib 0x00000001f4f4f604 + 68
18 Foundation 0x00000001f681ffb0 + 340
19 CoreFoundation 0x00000001f5ce8a50 + 28
20 CoreFoundation 0x00000001f5ce89cc + 92
21 CoreFoundation 0x00000001f5ce8284 + 180
22 CoreFoundation 0x00000001f5ce2f64 + 1032
23 CoreFoundation 0x00000001f5ce2844 CFRunLoopRunSpecific + 452
24 Foundation 0x00000001f66e45f0 + 304
25 Foundation 0x00000001f67213dc + 92
26 PushTest 0x0000000102040f24 +[JCOREQueueManager threadEntryPoint:] + 216
27 Foundation 0x00000001f66e31d0 + 72
28 Foundation 0x00000001f681fdbc + 1044
29 libsystem_pthread.dylib 0x00000001f595da04 + 132
30 libsystem_pthread.dylib 0x00000001f595d960 _pthread_start + 52
31 libsystem_pthread.dylib 0x00000001f5965df4 thread_start + 4

这个时候马上点击顶部通知栏,Xcode日志栏并无反应,过了十几秒后,才打印日志: iOS10 收到远程通知 ,这应该意味着 - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler 这个方法在十几秒后才被触发调用。

结合 Main Thread Checker 警告,我猜测这应该是在子线程调用UI操作导致了这个问题,此外,根据堆栈日志,里面有调用 [JPUSHGeofenceManager init]方法,但是我这里没有使用地理围栏功能为什么sdk也要进行初始化,是不是有问题?

注意,这里的延迟只会发生在每次启动app的第一次推送,之后的推送就没有这个延迟,猜测就是在地理围栏初始化这里出现了问题

转载于:https://my.oschina.net/ioslighter/blog/3081124

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值