expo: App crashes when calling ImagePicker.launchImageLibraryAsync on iOS 12.5.5

Summary

When calling ImagePicker.launchImageLibraryAsync on iPhone 6 iOS 12.5.5 the app crashes. This has NOT been reproducible on:

  • iPad Pro 14.6
  • iPad Air 2 iOS 15.0
  • iPhone 7 iOS 15.0.2

There was no problem prior to SDK 43

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

43

Environment

Expo CLI 4.12.8 environment info: System: OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo) Shell: 5.1.4 - /bin/bash Binaries: Node: 15.5.1 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 7.3.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: Android SDK: API Levels: 22, 23, 24, 25, 26, 28 Build Tools: 23.0.1, 23.0.2, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom npmPackages: expo: ^43.0.0 => 43.0.0 react: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 npmGlobalPackages: expo-cli: 4.12.8 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

Should be reproducible using an iPhone 6 with iOS 12.5.5 and opening the Snack below. This Snack is the same as the Snack from the ImagePicker documentation (https://docs.expo.dev/versions/latest/sdk/imagepicker). We have not been able to reproduce on any of the other iOS versions we have available (iPad Pro 14.6, iPad Air 2 iOS 15.0 & iPhone 7 iOS 15.0.2)

https://snack.expo.dev/@qinspect/image-picker

About this issue

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

Commits related to this issue

Most upvoted comments

I was able to fix this by setting the presentationStyle option to 0 (fullscreen) explicitly:

ImagePicker.launchImageLibraryAsync({
        presentationStyle: 0,
});

see https://github.com/expo/expo/blob/master/packages/expo-image-picker/src/ImagePicker.types.ts#L143

Default behaviour is to fallback to UIImagePickerPresentationStyle.Automatic (-2), which I believe is not supported on iOS 12

I think this should be handled internally by the expo-image-picker library

same issue, iPhone 6 – IOS 12.4.9. When ImagePicker.launchImageLibraryAsync is called app crashes instantly. Expo 43.

confirmed same problem ios 12.5.5 sdk 43 working fine with sdk 42 so maybe it’s clear why( files ios/versioned-react-native/ABI43_0_0/ReactNative/React/Views/ABI43_0_0RCTModalHostView.m ios/vendored/sdk43/react-native-screens/ios/ABI43_0_0RNSScreen.m need review so if my guess is correct ios 12 will be dropped next year)

versions from 11.0.0 to 11…0.3 doesn’t work

It appears that the affected code has been replaced in SDK 45, and the bug only occurs on iOS devices still running iOS 12 or below. Also, there is a simple workaround for the issue in JS by passing in a presentation style. Probably safe to close this. @brentvatne

ImagePicker.launchImageLibraryAsync({ presentationStyle: 0, });

this works great work!!!

We’re encountering the same crash for iOS 12.0.5 on both Expo client and standalone bare sdk 43 (expo-image-picker 11.0.3). Unfortunately this is blocking us from upgrading to sdk 43. No crashes on iOS 12.0.5 in sdk 42 with expo-image-picker version < 11.0.0.

Simulator provides this crash report:

libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The specified modal presentation style doesn't have a corresponding presentation controller.'
terminating with uncaught exception of type NSException
CoreSimulator 776.4 - Device: iPhone 7 (65E57B19-EC55-445B-B25C-F5D532C8476E) - Runtime: iOS 12.4 (16G73) - DeviceType: iPhone 7

from main.m

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[]) {
  @autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); <<< Exception
  }
}

Please let me know if you need more information.