React-native-image-crop-picker: app craches when choose photo on ios

Created on 16 Jan 2020  路  8Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

Tell us which versions you are using:

  • react-native-image-crop-picker ^0.24.0
  • react-native v0.59.0

    Platform

Tell us to which platform this issue is related

  • iOS 9.3.6

Expected behaviour

Actual behaviour

when camera opened I can take the picture but when I want to choose it the app crashes and sometimes crashed just when the camera is opened, but it works when I use debugg js remotly mode instead on android works very well in the all cases.

with higher version ios like 13 it works well

Attachments

// stacktrace or any other useful debug info

Love react-native-image-crop-picker? Please consider supporting our collective:
馃憠 https://opencollective.com/react-native-image-crop-picker/donate

Most helpful comment

Forgot to update this. I was able to get all of the issues resolved. For me, modifying the ImageCropPicker.m file fixed the crashes and the problem with the screen disappearing was due to changes that I made.

Previously, I called openCropper directly and closed the modal within the .then. I changed the method to call the openPicker, process the original file and call openCropper. I forgot to move the modal down into the openCropper and so the modal was being closed right after the openCropper was being called, not after it returned.

For programmers who do not understand iOS, can you share your specific solution?
Include native code

All 8 comments

@ivpusic need your help

You need to set usage description in info plist file to use camera. @hanaechahid

Hi @Saad-Bashar, firstly thank you.
this my info.plist:

<key>NSCameraUsageDescription</key>
       <string>$(PRODUCT_NAME) need permission to access the camera. that you can use it to 
          scan your document and upload it.</string>
<key>NSMicrophoneUsageDescription</key>
      <string>$(PRODUCT_NAME) Need permission to access to your microphone</string>
<key>NSPhotoLibraryAddUsageDescription</key>
       <string>$(PRODUCT_NAME) Need permission to access to your Photo library</string>
<key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME)  Need permission to access to your Photo library to be accessed for the first time</string>

but what I don't understanding is why it 's working with debug js remotly

I'm having the same problem. I used Android emulator for development and it worked fine. Now I'm running it on an iPhone (attached) and as soon as openPicker is called, it crashes.

the code I use to call it is:

ImagePicker.openPicker({
      mediaType: 'photo',
      writeTempFile: true,
      includeExif: true,
    })

The same thing happens

2020-01-16 20:02:30.801198-0600 PolyAmDate[58570:2930766] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
2020-01-16 20:02:38.134199-0600 PolyAmDate[58570:2930766] id: 744BEFC9-7B2C-4103-A7EE-9B4FD80FE700/L0/001 filename: IMG_0005.HEIC
2020-01-16 20:02:39.144 [info][tid:com.apple.root.default-qos][RCTImageLoader.mm:738] [PERF ASSETS] Loading image at size {3024, 4032}, which is larger than the screen size {750, 1334}
2020-01-16 20:02:39.147 [info][tid:com.apple.root.default-qos][RCTImageLoader.mm:738] [PERF ASSETS] Loading image at size {3024, 4032}, which is larger than the screen size {750, 1334}
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIViewController init]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100ddcf54 -[RSKImageCropViewController init] + 80
5   PolyAmDate                          0x0000000100ddd224 -[RSKImageCropViewController initWithImage:] + 80
6   PolyAmDate                          0x0000000100dacc58 -[ImageCropPicker startCropping:] + 80
7   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
8   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
9   PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
10  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
11  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
13  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
14  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
15  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
16  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
17  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8
2020-01-16 20:02:39.168687-0600 PolyAmDate[58570:2931117] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController init]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100ddcf54 -[RSKImageCropViewController init] + 80
5   PolyAmDate                          0x0000000100ddd224 -[RSKImageCropViewController initWithImage:] + 80
6   PolyAmDate                          0x0000000100dacc58 -[ImageCropPicker startCropping:] + 80
7   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
8   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
9   PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
10  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
11  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
13  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
14  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
15  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
16  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
17  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100ddeff0 -[RSKImageCropViewController imageScrollView] + 96
5   PolyAmDate                          0x0000000100de1408 -[RSKImageCropViewController setCropMode:] + 112
6   PolyAmDate                          0x0000000100dacd24 -[ImageCropPicker startCropping:] + 284
7   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
8   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
9   PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
10  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
11  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
13  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
14  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
15  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
16  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
17  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8
2020-01-16 20:02:46.960940-0600 PolyAmDate[58570:2931117] [reports] Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100ddeff0 -[RSKImageCropViewController imageScrollView] + 96
5   PolyAmDate                          0x0000000100de1408 -[RSKImageCropViewController setCropMode:] + 112
6   PolyAmDate                          0x0000000100dacd24 -[ImageCropPicker startCropping:] + 284
7   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
8   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
9   PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
10  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
11  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
13  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
14  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
15  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
16  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
17  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIScrollView initWithFrame:]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100de68c4 -[RSKImageScrollView initWithFrame:] + 108
5   PolyAmDate                          0x0000000100ddeff0 -[RSKImageCropViewController imageScrollView] + 96
6   PolyAmDate                          0x0000000100de1408 -[RSKImageCropViewController setCropMode:] + 112
7   PolyAmDate                          0x0000000100dacd24 -[ImageCropPicker startCropping:] + 284
8   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
9   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
10  PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
11  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
12  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
13  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
14  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
15  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
16  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
17  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
18  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8
2020-01-16 20:02:47.056606-0600 PolyAmDate[58570:2931117] [reports] Main Thread Checker: UI API called on a background thread: -[UIScrollView initWithFrame:]
PID: 58570, TID: 2931117, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   PolyAmDate                          0x0000000100de68c4 -[RSKImageScrollView initWithFrame:] + 108
5   PolyAmDate                          0x0000000100ddeff0 -[RSKImageCropViewController imageScrollView] + 96
6   PolyAmDate                          0x0000000100de1408 -[RSKImageCropViewController setCropMode:] + 112
7   PolyAmDate                          0x0000000100dacd24 -[ImageCropPicker startCropping:] + 284
8   PolyAmDate                          0x0000000100dacbcc __49-[ImageCropPicker openCropper:resolver:rejecter:]_block_invoke + 280
9   PolyAmDate                          0x0000000100f45960 __119-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 + 556
10  PolyAmDate                          0x0000000100f4668c __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2 + 700
11  PolyAmDate                          0x0000000100f471d8 __80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.264 + 604
12  libdispatch.dylib                   0x00000001026097fc _dispatch_call_block_and_release + 24
13  libdispatch.dylib                   0x000000010260abd8 _dispatch_client_callout + 16
14  libdispatch.dylib                   0x000000010260d2d4 _dispatch_queue_override_invoke + 872
15  libdispatch.dylib                   0x000000010261c160 _dispatch_root_queue_drain + 376
16  libdispatch.dylib                   0x000000010261ca88 _dispatch_worker_thread2 + 156
17  libsystem_pthread.dylib             0x00000001889f6b48 _pthread_wqthread + 212
18  libsystem_pthread.dylib             0x00000001889f9760 start_wqthread + 8

I've made a little progress. I don't get the exception any more. I modified the startCropping method within the ImageCropPicker.m file to wrap all of the calls within a dispactch_async instead of just the getRootVC call.
Now, after I select the image I see it pop up on the screen for a moment then it disappears. This is what's in the console now:

2020-01-16 20:40:07.126514-0600 PolyAmDate[59044:2940294] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
2020-01-16 20:40:09.813832-0600 PolyAmDate[59044:2940294] id: 744BEFC9-7B2C-4103-A7EE-9B4FD80FE700/L0/001 filename: IMG_0005.HEIC
2020-01-16 20:40:10.720 [info][tid:com.facebook.react.JavaScript] returned from openPicker
2020-01-16 20:40:10.803 [info][tid:com.apple.root.default-qos][RCTImageLoader.mm:738] [PERF ASSETS] Loading image at size {3024, 4032}, which is larger than the screen size {750, 1334}
2020-01-16 20:40:34.074634-0600 PolyAmDate[59044:2940294] id: 744BEFC9-7B2C-4103-A7EE-9B4FD80FE700/L0/001 filename: IMG_0005.HEIC
2020-01-16 20:40:34.972 [info][tid:com.facebook.react.JavaScript] returned from openPicker
2020-01-16 20:40:35.048 [info][tid:com.apple.root.default-qos][RCTImageLoader.mm:738] [PERF ASSETS] Loading image at size {3024, 4032}, which is larger than the screen size {750, 1334}

Also crashing :(

Forgot to update this. I was able to get all of the issues resolved. For me, modifying the ImageCropPicker.m file fixed the crashes and the problem with the screen disappearing was due to changes that I made.

Previously, I called openCropper directly and closed the modal within the .then. I changed the method to call the openPicker, process the original file and call openCropper. I forgot to move the modal down into the openCropper and so the modal was being closed right after the openCropper was being called, not after it returned.

Forgot to update this. I was able to get all of the issues resolved. For me, modifying the ImageCropPicker.m file fixed the crashes and the problem with the screen disappearing was due to changes that I made.

Previously, I called openCropper directly and closed the modal within the .then. I changed the method to call the openPicker, process the original file and call openCropper. I forgot to move the modal down into the openCropper and so the modal was being closed right after the openCropper was being called, not after it returned.

For programmers who do not understand iOS, can you share your specific solution?
Include native code

Was this page helpful?
0 / 5 - 0 ratings

Related issues

equesteo picture equesteo  路  3Comments

fmcruz picture fmcruz  路  3Comments

sergiulucaci picture sergiulucaci  路  3Comments

althurzard picture althurzard  路  3Comments

aterribili picture aterribili  路  3Comments