Xcode 10主线程检查器:Cordova相机插件 [英] Xcode 10 Main Thread Checker: Cordova Camera Plugin

查看:74
本文介绍了Xcode 10主线程检查器:Cordova相机插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS13发行之后,我正在使用Cordova测试混合应用程序.启动相机非常慢,并会生成以下内容:

Following iOS13 release, I'm testing a hybrid app using Cordova. Launching the camera is very slow and generates the following:

==================================================================

=================================================================

主线程检查器:在后台线程上调用的UI API:-[UIImagePickerController init]

Main Thread Checker: UI API called on a background thread: -[UIImagePickerController init]

PID:1347,TID:618928,线程名称:(none),队列名称:com.apple.root.default-qos,QoS:0

PID: 1347, TID: 618928, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0

回溯:

4 0x0000000100f1bba0 + [CDVCameraPicker createFromPictureOptions:] + 124

4 0x0000000100f1bba0 +[CDVCameraPicker createFromPictureOptions:] + 124

5 0x0000000100f15d54-[CDVCamera showCameraPicker:withOptions:] + 108

5 0x0000000100f15d54 -[CDVCamera showCameraPicker:withOptions:] + 108

6 0x0000000100f15570 __25- [CDVCamera takePicture:] _ block_invoke_2 + 336

6 0x0000000100f15570 __25-[CDVCamera takePicture:]_block_invoke_2 + 336

7 AVFoundation 0x00000001b76178f8 2BC0C357-314E-3AE8-B006-C28528B87512 + 710904

7 AVFoundation 0x00000001b76178f8 2BC0C357-314E-3AE8-B006-C28528B87512 + 710904

8 TCC 0x00000001b35dfbf8 85A762AF-99DB-3B4C-B24B-09600CC17196 + 7160

8 TCC 0x00000001b35dfbf8 85A762AF-99DB-3B4C-B24B-09600CC17196 + 7160

9 TCC 0x00000001b35e3de4 85A762AF-99DB-3B4C-B24B-09600CC17196 + 24036

9 TCC 0x00000001b35e3de4 85A762AF-99DB-3B4C-B24B-09600CC17196 + 24036

10 libxpc.dylib 0x00000001acfe3804 79A1F1AD-9CB4-3334-91D9-E1ED6B1032A3 + 104452

10 libxpc.dylib 0x00000001acfe3804 79A1F1AD-9CB4-3334-91D9-E1ED6B1032A3 + 104452

11 libxpc.dylib 0x00000001acfd72c4 79A1F1AD-9CB4-3334-91D9-E1ED6B1032A3 + 53956

11 libxpc.dylib 0x00000001acfd72c4 79A1F1AD-9CB4-3334-91D9-E1ED6B1032A3 + 53956

12 libdispatch.dylib 0x000000010109b3b4 _dispatch_client_callout3 + 20

12 libdispatch.dylib 0x000000010109b3b4 _dispatch_client_callout3 + 20

13 libdispatch.dylib 0x00000001010b7000 _dispatch_mach_msg_async_reply_invoke + 392

13 libdispatch.dylib 0x00000001010b7000 _dispatch_mach_msg_async_reply_invoke + 392

14 libdispatch.dylib 0x00000001010ada8c _dispatch_kevent_worker_thread + 1436

14 libdispatch.dylib 0x00000001010ada8c _dispatch_kevent_worker_thread + 1436

15 libsystem_pthread.dylib 0x00000001ad0e6adc _pthread_wqthread + 336

15 libsystem_pthread.dylib 0x00000001ad0e6adc _pthread_wqthread + 336

16 libsystem_pthread.dylib 0x00000001ad0ecc7c start_wqthread + 8

16 libsystem_pthread.dylib 0x00000001ad0ecc7c start_wqthread + 8

Xcode 10.3cordova-plugin-camera版本4.1.0

Xcode 10.3 cordova-plugin-camera version 4.1.0

在iPhone X,iOS13上运行

running on iPhone X, iOS13

最终,相机打开并允许我拍照,但之后UI不能正确显示.我尝试创建一个仅添加了相机插件的全新应用程序,并且发生了同样的事情.

Eventually the camera opens and allows me to take a photo but the UI is not displayed correctly afterwards. I've tried creating a brand new app with only the camera plugin added and the same thing happens.

该如何解决?

推荐答案

似乎需要在UI线程中调用UIImagePickerController.幸运的是,代码已经准备好进行更改!

It would seem that UIImagePickerController needs to be called in the UI Thread. Fortunately, the code is already ready for that change!

只需将cameraPicker初始化部分移至主线程部分:

Just move the cameraPicker init section into the main thread section:

dispatch_async(dispatch_get_main_queue(), ^{
  // UI MainThread execution
 CDVCameraPicker* cameraPicker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
 weakSelf.pickerController = cameraPicker;

cameraPicker.delegate = weakSelf;
cameraPicker.callbackId = command.callbackId;
// we need to capture this state for memory warnings that dealloc this object
cameraPicker.webView = weakSelf.webView;
  ...
}

D.

这篇关于Xcode 10主线程检查器:Cordova相机插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆