Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

react-native-image-crop-picker call to openCropper causes crash on ios only

$
0
0

I'm trying to implement react-native-image-crop-picker into a react-native app. Everything works fine on Android, it's just ios that causes the problem. I narrowed it down to the openCropper method. I was able to fix part of the problem, but I'm stuck on the last little bit.

The code inside of react-native that I'm using is:

ImagePicker.openPicker({
  mediaType: 'photo',
  writeTempFile: true,
  includeExif: true,
})
  .then(image => {
    this.setState({ modalOpen: false });
    console.log('returned from openPicker');
    // Remove the Promise All for the ImagePicker
    ImagePicker.openCropper({
      path: (image as PickerImage).path,
      width: 400,
      height: 400,
      writeTempFile: false,
      includeExif: true
    })
      .then(croppedImage => {
        console.log('returned from openCropper');

      })
      .catch(e => { console.log('Error in openCropper: ' + e) });
  })
  .catch(e => { console.log('Error in openPicker: ' + e) });

The first issue I had was an exception in the ImageCropPicker.m file. The exception I got was:

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

Debugging pointed me to the startCropping. The call to initWithImage was causing the error. I enclosed the entire block in a dispatch_async call and that stopped the exception.

However, now what happens is after choosing a file (or taking a picture), I can see it pop up on the screen for just a moment, then it disappears. I'm guessing that it has to do with putting the cropping overlay onto the view, but I can't find that anywhere to test...and it's not throwing an exception.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>