Capacitor: bug: saveToGallery doesn't work on iOS

Created on 21 Oct 2019  ·  2Comments  ·  Source: ionic-team/capacitor

Bug Report

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 1.2.1

@capacitor/core: 1.2.1

@capacitor/android: 1.2.1

@capacitor/ios: 1.2.1

Installed Dependencies:

@capacitor/cli 1.2.0

@capacitor/ios 1.2.0

@capacitor/core 1.2.0

@capacitor/android 1.2.0

[success] Android looking great! 👌
Found 5 Capacitor plugins for ios:
cordova-background-geolocation-lt (3.2.2)
cordova-plugin-background-fetch (5.6.0)
cordova-plugin-badge (0.8.8)
cordova-plugin-cocoalumberjack (0.0.4)
cordova-plugin-insomnia (4.3.0)
[success] iOS looking great! 👌

Affected Platform(s)

  • [ ] Android
  • [x] iOS
  • [ ] Electron
  • [ ] Web

Current Behavior

Passing the flag saveToGallery: true to the Camera plugin has no effect on iOS. Contrary to expected behavior the taken photo is not saved to the Photo Gallery in iOS.

Expected Behavior

When this flag is passed, the photo taken by the user should be saved to the system photo gallery.

Sample Code or Sample Application Repo

https://github.com/brian-g/CapacitorCameraTest

Reproduction Steps

When the "Take Picture" button is pressed and a photo is taken, the resulting photo should be in the Photo gallery of the iPhone.

Other Technical Details

yarn --version output: 1.19.0

node --version output: v10.16.0

pod --version output (iOS issues only): 1.7.5

Other Information

The console has this output when the button is pressed:

⚡️  To Native ->  Camera getPhoto 53140666
2019-10-21 10:46:37.444798-0500 App[3118:1287343] [general] Connection to daemon was invalidated

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

Main Thread Checker: UI API called on a background thread: -[UIViewController setModalPresentationStyle:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bf95c $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 1392
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8
2019-10-21 10:46:38.042073-0500 App[3118:1287344] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController setModalPresentationStyle:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bf95c $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 1392
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8

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

Main Thread Checker: UI API called on a background thread: -[UIImagePickerController setSourceType:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bfa74 $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 1672
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8
2019-10-21 10:46:50.202666-0500 App[3118:1287344] [reports] Main Thread Checker: UI API called on a background thread: -[UIImagePickerController setSourceType:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bfa74 $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 1672
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8

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

Main Thread Checker: UI API called on a background thread: -[UIImagePickerController setCameraDevice:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bfcc4 $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 2264
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8
2019-10-21 10:46:50.328277-0500 App[3118:1287344] [reports] Main Thread Checker: UI API called on a background thread: -[UIImagePickerController setCameraDevice:]
PID: 3118, TID: 1287344, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Capacitor                           0x00000001003bfcc4 $s9Capacitor15CAPCameraPluginC10showCamerayySo13CAPPluginCallCFySbcfU_ + 2264
5   Capacitor                           0x00000001003b2c00 $sSbIegy_SbIeyBy_TR + 68
6   TCC                                 0x0000000187522b60 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 7008
7   TCC                                 0x0000000187526b28 FFCF214C-13B9-3871-BE86-C3D5C3108939 + 23336
8   libxpc.dylib                        0x0000000180ff9d88 217DC1A7-7821-3F1F-A837-3825D770EF05 + 97672
9   libxpc.dylib                        0x0000000180fee01c 217DC1A7-7821-3F1F-A837-3825D770EF05 + 49180
10  libdispatch.dylib                   0x00000001005f6c84 _dispatch_client_callout3 + 16
11  libdispatch.dylib                   0x00000001006122a4 _dispatch_mach_msg_async_reply_invoke + 388
12  libdispatch.dylib                   0x0000000100609044 _dispatch_kevent_worker_thread + 1376
13  libsystem_pthread.dylib             0x000000018113dfdc _pthread_wqthread + 332
14  libsystem_pthread.dylib             0x0000000181140ae0 start_wqthread + 8

bug good first issue ios camera

Most helpful comment

Save to gallery now works, but it also saves the image to the gallery if you select a photo from the gallery, which duplicates the image in the gallery.

Additionally the Error descripted in the original bug report is still there "Main Thread Checker: UI API called on a background thread". Which leads to long loading times when opening the camera.

All 2 comments

I've checked and there is no code for saveToGallery on iOS, so that explains why it doesn't work.

Save to gallery now works, but it also saves the image to the gallery if you select a photo from the gallery, which duplicates the image in the gallery.

Additionally the Error descripted in the original bug report is still there "Main Thread Checker: UI API called on a background thread". Which leads to long loading times when opening the camera.

Was this page helpful?
0 / 5 - 0 ratings