react-native-image-picker: Crash after taking photos with high-end iPhone camera ( > iPhone X )

Bug

When press the shoot button as soon as the camera opens, the app will be terminated with the following native code error. (maybe dual or triple camera)

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: data)'
*** First throw call stack:

Environment info

React native info output:

System:
    OS: macOS 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 742.69 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v10.19.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2
      System Images: android-28 | Android TV Intel x86 Atom, android-28 | China version of Wear OS Intel x86 Atom, android-28 | Wear OS Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5

Library version: 2.3.0(the latest)

Steps To Reproduce

  1. launch camera
// Launch Camera:
ImagePicker.launchCamera(options, (response) => {
  // Same code as in above section!
});
  1. press shoot button as soon as camera opens (black photo will be captured)
  2. app crashes

Describe what you expected to happen:

  1. The photo info will be passed normally

Reproducible sample code

      ImagePicker.launchCamera(options, response => {
        // Same code as in above section!
        alert(JSON.stringify(response));
      });

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Same issue here, here’s a stack trace from our analytics tool:

NSInvalidArgumentException *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: data) 
    Frameworks/CoreFoundation.framework/CoreFoundation ___exceptionPreprocess
    /usr/lib/libobjc.A.dylib _objc_exception_throw
    Frameworks/CoreFoundation.framework/CoreFoundation __CFThrowFormattedException
    Frameworks/CoreFoundation.framework/CoreFoundation -[__NSDictionaryM setObject:forKey:].cold.2
    Frameworks/CoreFoundation.framework/CoreFoundation -[__NSDictionaryM setObject:forKey:]
    /Users/USER/Source_Code/Work/APP/node_modules/react-native-image-picker/ios/ImagePickerManager.m:390:17 __74-[ImagePickerManager imagePickerController:didFinishPickingMediaWithInfo:]_block_invoke
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UIPresentationController transitionDidFinish:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[_UICurrentContextPresentationController transitionDidFinish:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore ___56-[UIPresentationController runTransitionForCurrentState]_block_invoke.503
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[_UIViewControllerTransitionContext completeTransition:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UITransitionView notifyDidCompleteTransition:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UITransitionView _didCompleteTransition:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UIViewAnimationState animationDidStop:finished:]
    PrivateFrameworks/UIKitCore.framework/UIKitCore -[UIViewAnimationState animationDidStop:finished:]
    Frameworks/QuartzCore.framework/QuartzCore CA::Layer::run_animation_callbacks(void*)
    /usr/lib/system/libdispatch.dylib __dispatch_client_callout
    /usr/lib/system/libdispatch.dylib __dispatch_main_queue_callback_4CF$VARIANT$armv81
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
    Frameworks/CoreFoundation.framework/CoreFoundation ___CFRunLoopRun
    Frameworks/CoreFoundation.framework/CoreFoundation _CFRunLoopRunSpecific
    PrivateFrameworks/GraphicsServices.framework/GraphicsServices _GSEventRunModal
    PrivateFrameworks/UIKitCore.framework/UIKitCore _UIApplicationMain
    APP/main.m:7:11 main
    /usr/lib/system/libdyld.dylib _start

Affected devices seem to be: iPhone X iPhone XR iPhone 11 iPhone SE

This is also happening when selecting large photos from the image library on iOS with RN 0.61.5 and latest version of this package 2.3.0

Same error here on iPhone 11.

Same error here on iPhone 11.

+1