-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] Improve image_picker for iOS to handle more image types #6812
[image_picker] Improve image_picker for iOS to handle more image types #6812
Conversation
This is much needed, thank you much @vashworth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed there was a previous similar PR about this #4665
.../image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m
Show resolved
Hide resolved
packages/image_picker/image_picker_ios/ios/Classes/FLTPHPickerSaveImageToPathOperation.m
Outdated
Show resolved
Hide resolved
packages/image_picker/image_picker_ios/ios/Classes/FLTPHPickerSaveImageToPathOperation.m
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make the Fixes #issue on its own lines then GitHub will handle linking the PR to the issues and will auto-close.
Needs formatting:
|
@@ -55,6 +55,76 @@ - (void)testSaveGIFImage API_AVAILABLE(ios(14)) { | |||
[self verifySavingImageWithPickerResult:result fullMetadata:YES]; | |||
} | |||
|
|||
- (void)testSaveBMPImage API_AVAILABLE(ios(14)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to test the pre-iOS 14 codepath without using PHPickerResult
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, that code is dead, FLTPHPickerSaveImageToPathOperation
is only available on iOS 14.
.../image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I just tested I have couple of RAW files in my real iPhone13 Pro device and it does not complete the future and throws error("Cancelled by a second request") next time when I'm about tho pick file.(which was the ultimate problem with this package) I just simply ran
|
Also strangely it does work on some of RAW the file but for some RAW files it does. Here are the sample files which doesn't seems to be working File Specs |
The canceled by a second request issue is tracked with flutter/flutter#82602, which I'm working on now. However the underlying problem is that it can't load the image:
There are other Apple dev threads complaining about the same: https://developer.apple.com/forums/thread/672379 and https://developer.apple.com/forums/thread/661834. I wonder if trying again works, or if it perma-fails for a given image once it's decided it can't be accessed. |
Talked with @vashworth about this one, we decided to merge even with the inconsistent selection of the RAW files since this change is still better than what we had before--it's supporting a lot more image formats. Plus there are reports of this happening on Apple developer forums which makes me think the |
As @jmagman mentioned we decided to merge this. I was able to reproduce the issue @LabN36 had, and created a new issue for it with my findings: flutter/flutter#117240 |
* 5f62d21eb [local_auth] Fix failed biometric authentication not throwing error (flutter/plugins#6821) * ca974ab0c [webview_flutter_web] Copies web implementation of webview_flutter from v4_webview (flutter/plugins#6854) * 4d11be416 [image_picker] Don't store null paths in lost cache (flutter/plugins#6678) * fd2841fd0 [webview_flutter_android] Fix timeouts in the integration tests (flutter/plugins#6857) * abc9f9a9b [flutter_plugin_tools] If `clang-format` does not run, fall back to other executables in PATH (flutter/plugins#6853) * 7efb5e89d [video_player] Add compatibility with the current platform interface (flutter/plugins#6855) * 32dcbf3e3 [image_picker] Improve image_picker for iOS to handle more image types (flutter/plugins#6812) * 840a04954 [webview_flutter] Copies app-facing implementation of webview_flutter from v4_webview (flutter/plugins#6856)
…#117314) * 5f62d21eb [local_auth] Fix failed biometric authentication not throwing error (flutter/plugins#6821) * ca974ab0c [webview_flutter_web] Copies web implementation of webview_flutter from v4_webview (flutter/plugins#6854) * 4d11be416 [image_picker] Don't store null paths in lost cache (flutter/plugins#6678) * fd2841fd0 [webview_flutter_android] Fix timeouts in the integration tests (flutter/plugins#6857) * abc9f9a9b [flutter_plugin_tools] If `clang-format` does not run, fall back to other executables in PATH (flutter/plugins#6853) * 7efb5e89d [video_player] Add compatibility with the current platform interface (flutter/plugins#6855) * 32dcbf3e3 [image_picker] Improve image_picker for iOS to handle more image types (flutter/plugins#6812) * 840a04954 [webview_flutter] Copies app-facing implementation of webview_flutter from v4_webview (flutter/plugins#6856)
flutter#6812) * Improve image picker for ios to handle more image types * Update release info * different svg, remove raw test * change pro raw image * change pro raw image * add error log * fix formatting * fix image identifiers in test * get image type identifier from itemProvider in test
Changes iOS image picker (iOS 14+) to use
NSItemProvider
's methodloadDataRepresentationForTypeIdentifier:completionHandler:
instead ofloadObjectOfClass:completionHandler:
.The
loadObjectOfClass
method is unable to convert some image types directly into aUIImage
. For example, WebP and ProRaw images return an error ofCould not coerce an item to class UIImage
. However,loadDataRepresentationForTypeIdentifier
is able to load all image types that conform toUTTypeImage
(UTTypeHEIC
,UTTypeHEIF
,UTTypeLivePhoto
,UTTypeICO
,UTTypeICNS
,UTTypePNG
,UTTypeGIF
,UTTypeJPEG
,UTTypeWebP
,UTTypeTIFF
,UTTypeBMP
,UTTypeSVG
,UTTypeRAWImage
) intoNSData
, which can then be converted into aUIImage
.Fixes flutter/flutter#92100.
Fixes flutter/flutter#95885.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.