react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

Fatal Exception: NSInvalidArgumentException

Open francoangulo opened this issue 8 months ago • 2 comments

Description

Having a crash when attempting to upload a video. Apparently due to the absence of MIME type in the video file since that's the object[7] field in the createAttachmentResponse method mentioned above in the exception details. (line 499 also mentioned in the exception details)

Image

Exception details

Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[7]

          Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x16018 objc_exception_throw
2  CoreFoundation                 0x15e6c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
3  CoreFoundation                 0x15a88 +[NSDictionary dictionaryWithObjects:forKeys:count:]
4  YourApplication                 0x1f23c4 -[ImageCropPicker createAttachmentResponse:withExif:withSourceURL:withLocalIdentifier:withFilename:withWidth:withHeight:withMime:withSize:withDuration:withData:withRect:withCreationDate:withModificationDate:] + 499 (ImageCropPicker.m:499)
5  YourApplication                 0x1f1d84 __75-[ImageCropPicker handleVideo:withFileName:withLocalIdentifier:completion:]_block_invoke + 457 (ImageCropPicker.m:457)
6  AVFCore                        0xdb154 -[AVAssetExportSession AVExportSessionExportAsynchronouslyCompletionHandler]
7  MediaToolbox                   0x7590c0 figAssetExportSession_transitionToStatus
8  MediaToolbox                   0x758afc figAssetExportSession_figRemakerNotification
9  CoreMedia                      0x22194 fncCallOriginalCallbackAndReleaseWeakListener
10 CoreMedia                      0x22110 fncHandleDeferredNotification
11 CoreMedia                      0x22434 figDeferredNotificationDispatchFunction
12 libdispatch.dylib              0x3dd4 _dispatch_client_callout
13 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain
14 libdispatch.dylib              0xbf30 _dispatch_lane_invoke
15 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh
16 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread
17 libsystem_pthread.dylib        0x4934 _pthread_wqthread
18 libsystem_pthread.dylib        0x10cc start_wqthread
        

francoangulo avatar Apr 08 '25 16:04 francoangulo

As a temporary workaround, I patched the package by applying a nullish fallback to prevent the crash.

     
@@ -487,10 +501,10 @@ RCT_EXPORT_METHOD(openCropper:(NSDictionary *)options
         @"sourceURL": (sourceURL) ? sourceURL : [NSNull null],
         @"localIdentifier": (localIdentifier) ? localIdentifier : [NSNull null],
         @"filename": (filename) ? filename : [NSNull null],
-        @"width": width,
-        @"height": height,
-        @"mime": mime,
-        @"size": size,
+        @"width": width ? width : [NSNull null],
+        @"height": height ? height : [NSNull null],
+        @"mime": mime ? mime : [NSNull null],
+        @"size": size ? size : [NSNull null],
         @"data": (data) ? data : [NSNull null],
         @"exif": (exif) ? exif : [NSNull null],
         @"cropRect": CGRectIsNull(cropRect) ? [NSNull null] : [ImageCropPicker cgRectToDictionary:cropRect],

francoangulo avatar Apr 08 '25 16:04 francoangulo