diff --git a/packages/image_picker/image_picker_ios/CHANGELOG.md b/packages/image_picker/image_picker_ios/CHANGELOG.md index db9303fbf8b..a8b8c31a14f 100644 --- a/packages/image_picker/image_picker_ios/CHANGELOG.md +++ b/packages/image_picker/image_picker_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.13+3 + +* Fixes a performance regression on iOS where picking videos could cause a long delay due to transcoding. The picker is now configured to request the original asset to avoid conversion. + ## 0.8.13+2 * Updates to Pigeon 26. diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m index 6671f4f6843..85c88d46c15 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m @@ -701,4 +701,28 @@ - (void)testPickMultiVideoWithoutLimit { XCTAssertEqual(plugin.callContext.maxItemCount, 0); } +- (void)testPickVideoSetsCurrentRepresentationMode API_AVAILABLE(ios(14)) { + id mockPickerViewController = OCMClassMock([PHPickerViewController class]); + OCMStub(ClassMethod([mockPickerViewController alloc])).andReturn(mockPickerViewController); + OCMExpect([mockPickerViewController + initWithConfiguration:[OCMArg checkWithBlock:^BOOL(PHPickerConfiguration *config) { + return config.preferredAssetRepresentationMode == + PHPickerConfigurationAssetRepresentationModeCurrent; + }]]) + .andReturn(mockPickerViewController); + + FLTImagePickerPlugin *plugin = [[FLTImagePickerPlugin alloc] init]; + id partialPlugin = OCMPartialMock(plugin); + id mockViewController = OCMClassMock([UIViewController class]); + OCMStub([partialPlugin viewControllerWithWindow:OCMOCK_ANY]).andReturn(mockViewController); + + [plugin pickVideoWithSource:[FLTSourceSpecification makeWithType:FLTSourceTypeGallery + camera:FLTSourceCameraRear] + maxDuration:nil + completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ + }]; + + OCMVerifyAll(mockPickerViewController); +} + @end diff --git a/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPlugin.m b/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPlugin.m index 78918e7edc7..8ca93e706a9 100644 --- a/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPlugin.m +++ b/packages/image_picker/image_picker_ios/ios/image_picker_ios/Sources/image_picker_ios/FLTImagePickerPlugin.m @@ -99,6 +99,7 @@ - (void)launchPHPickerWithContext:(nonnull FLTImagePickerMethodCallContext *)con PHPickerConfiguration *config = [[PHPickerConfiguration alloc] initWithPhotoLibrary:PHPhotoLibrary.sharedPhotoLibrary]; config.selectionLimit = context.maxItemCount; + config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent; NSMutableArray *filters = [[NSMutableArray alloc] init]; if (context.includeImages) { [filters addObject:[PHPickerFilter imagesFilter]]; diff --git a/packages/image_picker/image_picker_ios/pubspec.yaml b/packages/image_picker/image_picker_ios/pubspec.yaml index f91784c872c..30b0194fd16 100755 --- a/packages/image_picker/image_picker_ios/pubspec.yaml +++ b/packages/image_picker/image_picker_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker_ios description: iOS implementation of the image_picker plugin. repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 -version: 0.8.13+2 +version: 0.8.13+3 environment: sdk: ^3.9.0