Repository navigation
FLTImagePickerImageUtil crash: UIGraphicsBeginImageContext() failed to allocate CGBitampContext #144602
Copy link
Copy link
Closed
flutter/packages
#6285Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: fatal crashCrashes that terminate the processCrashes that terminate the processe: OS-version specificAffects only some versions of the relevant operating systemAffects only some versions of the relevant operating systemneeds repro infoAutomated crash report whose cause isn't yet knownAutomated crash report whose cause isn't yet knownp: image_pickerThe Image Picker plugin.The Image Picker plugin.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Steps to reproduce
Replicating the issue locally is challenging. However, there has been a noticeable uptick in occurrences reported on Crashlytics among iOS users running iOS 17 and above. The image_picker version that we are currently using is 1.0.5, but we also noticed these issues in earlier versions.
Expected results
We shouldn't see these issues in Crashlytics.
Actual results
We've observed reports of this issue from a relatively large number of our users on Crashlytics.
Code sample
Here is the example how we use ImagePicker
Code sample
final pickedFile = await picker.pickImage(
// use the camera if available, else fall back to gallery
source: (cameras.isNotEmpty) ? ImageSource.camera : ImageSource.gallery,
preferredCameraDevice: CameraDevice.rear,
maxHeight: 1024,
maxWidth: 1024,
imageQuality: 60,
);Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
+[FLTImagePickerImageUtil scaledImage:maxWidth:maxHeight:isMetadataAvailable:]
image_picker_ios:
FLTImagePickerImageUtil.m - Line 74
+[FLTImagePickerImageUtil scaledImage:maxWidth:maxHeight:isMetadataAvailable:] + 74```
Fatal Exception: NSInternalInconsistencyException
UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=1.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.
</details>
### Flutter Doctor output
<details open><summary>Doctor output</summary>
```console
[!] Flutter (Channel [user-branch], 3.16.9, on macOS 14.0 23A344 darwin-arm64,
locale en-RS)
! Flutter version 3.16.9 on channel [user-branch] at
/Users/radivojeostojic/Documents/development/flutter
Currently on an unknown channel. Run `flutter channel` to switch to an
official channel.
If that doesn't fix the issue, reinstall Flutter by following
instructions at https://flutter.dev/docs/get-started/install.
! Warning: `dart` on your path resolves to
/opt/homebrew/Cellar/dart/2.17.6/libexec/bin/dart, which is not inside
your current Flutter SDK checkout at
/Users/radivojeostojic/Documents/development/flutter. Consider adding
/Users/radivojeostojic/Documents/development/flutter/bin to the front of
your path.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss
this error.
• Framework revision 41456452f2 (6 weeks ago), 2024-01-25 10:06:23 -0800
• Engine revision f40e976bed
• Dart version 3.2.6
• DevTools version 2.28.5
• If those were intentional, you can disregard the above warnings; however
it is recommended to use "git" directly to perform update checks and
upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version
33.0.1)
• Android SDK at /Users/radivojeostojic/Library/Android/sdk
• Platform android-34, build-tools 33.0.1
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.68.1)
• VS Code at /Users/radivojeostojic/Downloads/Visual Studio
Code.app/Contents
• Flutter extension version 3.60.0
[✓] Connected device (5 available)
• SM G955U1 (mobile) • 988bdc37395638324a • android-arm64 • Android 9 (API 28)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31) (emulator)
• Radivoje’s iPhone (mobile) • 00008110-000159280100401E • ios • iOS 17.3.1 21D61
• macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.94
[✓] Network resources
• All expected network resources are available.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: fatal crashCrashes that terminate the processCrashes that terminate the processe: OS-version specificAffects only some versions of the relevant operating systemAffects only some versions of the relevant operating systemneeds repro infoAutomated crash report whose cause isn't yet knownAutomated crash report whose cause isn't yet knownp: image_pickerThe Image Picker plugin.The Image Picker plugin.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
darshankawar commentedon Mar 6, 2024
Thanks for the report @radivojeostojic
Looks like this could be specific to xcode + ios version combination, as I see below similar issues logged for different frameworks:
xamarin/Xamarin.Forms#15827
react-native-linear-gradient/react-native-linear-gradient#637
Apple forum: https://forums.developer.apple.com/forums/thread/733326
Based on the report, I'll label this for team's attention / tracking.
[-]FLTImagePickerImageUtil issue reported on Crashlytics [/-][+]FLTImagePickerImageUtil crash: UIGraphicsBeginImageContext() failed to allocate CGBitampContext[/+]jmagman commentedon Mar 7, 2024
Maybe a regression from flutter/packages#5527? cc @tarrinneal
tarrinneal commentedon Mar 7, 2024
Seems unlikely, that change didn't touch any code that should be effecting allocation (or anything that could cause crashes imo)
jmagman commentedon Mar 8, 2024
Ah sorry, I thought this might be related to the 0,0 size. But digging more
UIGraphicsBeginImageContextWithOptionsis deprecated in iOS 17 and should be replaced withUIGraphicsImageRendererhttps://developer.apple.com/forums/thread/731227.https://github.com/flutter/packages/blob/0badb4356021085b02e5a4a788ce2c1d4e237b0d/packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerImageUtil.m#L66
Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGrap…
github-actions commentedon Mar 28, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGrap…
Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGrap…