2 votes

Xcode 10 Main Thread Checker : Cordova Camera Plugin

Suite à la sortie d'iOS13, je teste une application hybride utilisant Cordova. Le lancement de l'appareil photo est très lent et génère ce qui suit :

\=================================================================

Vérificateur de fil principal : API de l'interface utilisateur appelée sur un thread d'arrière-plan : -[UIImagePickerController init]

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

Backtrace :

4 0x0000000100f1bba0 +[CDVCameraPicker createFromPictureOptions :] + 124

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

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

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

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

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

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

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

12 libdispatch.dylib 0x000000010109b3b4 _dispatch_client_callout3 + 20

13 libdispatch.dylib 0x00000001010b7000 _dispatch_mach_msg_async_reply_invoke + 392

14 libdispatch.dylib 0x00000001010ada8c _dispatch_kevent_worker_thread + 1436

15 libsystem_pthread.dylib 0x00000001ad0e6adc _pthread_wqthread + 336

16 libsystem_pthread.dylib 0x00000001ad0ecc7c start_wqthread + 8

Xcode 10.3 cordova-plugin-camera version 4.1.0

fonctionnant sur l'iPhone X, iOS13

Finalement, l'appareil photo s'ouvre et me permet de prendre une photo, mais l'interface utilisateur ne s'affiche pas correctement par la suite. J'ai essayé de créer une toute nouvelle application en ajoutant uniquement le plugin de l'appareil photo et la même chose se produit.

Comment cela peut-il être résolu ?

7voto

Delta Points 198

Il semblerait que UIImagePickerController doive être appelé dans le thread UI. Heureusement, le code est déjà prêt pour ce changement !

Il suffit de déplacer la section init de cameraPicker dans la section du fil principal :

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.

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X