极光推送不使用地理围栏功能会导致api调用延迟,严重问题

godreer
2019-07-30 06:18 546 0

我这里使用的是最新版极光推送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 <redacted> + 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 <redacted> + 68
18  Foundation                          0x00000001f681ffb0 <redacted> + 340
19  CoreFoundation                      0x00000001f5ce8a50 <redacted> + 28
20  CoreFoundation                      0x00000001f5ce89cc <redacted> + 92
21  CoreFoundation                      0x00000001f5ce8284 <redacted> + 180
22  CoreFoundation                      0x00000001f5ce2f64 <redacted> + 1032
23  CoreFoundation                      0x00000001f5ce2844 CFRunLoopRunSpecific + 452
24  Foundation                          0x00000001f66e45f0 <redacted> + 304
25  Foundation                          0x00000001f67213dc <redacted> + 92
26  PushTest                            0x0000000102040f24 +[JCOREQueueManager threadEntryPoint:] + 216
27  Foundation                          0x00000001f66e31d0 <redacted> + 72
28  Foundation                          0x00000001f681fdbc <redacted> + 1044
29  libsystem_pthread.dylib             0x00000001f595da04 <redacted> + 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 <redacted> + 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 <redacted> + 68
18  Foundation                          0x00000001f681ffb0 <redacted> + 340
19  CoreFoundation                      0x00000001f5ce8a50 <redacted> + 28
20  CoreFoundation                      0x00000001f5ce89cc <redacted> + 92
21  CoreFoundation                      0x00000001f5ce8284 <redacted> + 180
22  CoreFoundation                      0x00000001f5ce2f64 <redacted> + 1032
23  CoreFoundation                      0x00000001f5ce2844 CFRunLoopRunSpecific + 452
24  Foundation                          0x00000001f66e45f0 <redacted> + 304
25  Foundation                          0x00000001f67213dc <redacted> + 92
26  PushTest                            0x0000000102040f24 +[JCOREQueueManager threadEntryPoint:] + 216
27  Foundation                          0x00000001f66e31d0 <redacted> + 72
28  Foundation                          0x00000001f681fdbc <redacted> + 1044
29  libsystem_pthread.dylib             0x00000001f595da04 <redacted> + 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的第一次推送,之后的推送就没有这个延迟,猜测就是在地理围栏初始化这里出现了问题

1个回答

热门排序