Skip to content

Commit

Permalink
Fix UI API called on a background thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamungkun, Sarunyoo committed Feb 14, 2020
1 parent ead75ee commit b0c1b97
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ios/CDVCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,17 @@ - (void)takePicture:(CDVInvokedUrlCommand*)command

- (void)showCameraPicker:(NSString*)callbackId withOptions:(CDVPictureOptions *) pictureOptions
{
CDVCameraPicker* cameraPicker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
self.pickerController = cameraPicker;

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

// Perform UI operations on the main thread
dispatch_async(dispatch_get_main_queue(), ^{
CDVCameraPicker* cameraPicker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
self.pickerController = cameraPicker;

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

// If a popover is already open, close it; we only want one at a time.
if (([[self pickerController] pickerPopoverController] != nil) && [[[self pickerController] pickerPopoverController] isPopoverVisible]) {
[[[self pickerController] pickerPopoverController] dismissPopoverAnimated:YES];
Expand Down

0 comments on commit b0c1b97

Please sign in to comment.