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.6iPad Air 2 iOS 15.0iPhone 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)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (4 by maintainers)
Commits related to this issue
- Squashed commit of the following: commit af3560afebf5f4482e037c1f7c46ca16bd1975a2 Author: Zhiyuan Zheng <me@xmflsct.com> Date: Sun Feb 6 22:52:43 2022 +0100 Hotfix v3.1.2 commit c8a16c9aa61de... — committed to tooot-app/app by xmflsct 2 years ago
- Squashed commit of the following: commit c8e72399884ba91003ccfa09fc8021a486d1a353 Author: Zhiyuan Zheng <me@xmflsct.com> Date: Sun Feb 6 22:53:54 2022 +0100 Hotfix 3.2.4 commit 1799a673216523... — committed to tooot-app/app by xmflsct 2 years ago
- Squashed commit of the following: commit e4c87fbc5528644a20b8b8dcaeef9a729218f4ab Author: Zhiyuan Zheng <me@xmflsct.com> Date: Sun Feb 6 22:54:53 2022 +0100 Hotfix v3.3.2 commit 16f1cd50356d8... — committed to tooot-app/app by xmflsct 2 years ago
- Fix iOS 12 crashes on media selection https://github.com/expo/expo/issues/14903#issuecomment-966161497 — committed to tooot-app/app by xmflsct 2 years ago
I was able to fix this by setting the presentationStyle option to 0 (fullscreen) explicitly:
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 12I think this should be handled internally by the
expo-image-pickerlibrarysame 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:
from main.m
Please let me know if you need more information.