roycornelissen/GMImagePicker.Xamarin

Crash when picking video from iCloud

Opened this issue · 3 comments

Hello roycornelissen,
I have a problem using your ImagePicker, these are the steps to reproduce on our app:

·Select a video from picker that is stored on iCloud and not in the device
·Request to download it
·Everything is ok here
·Open again the imagePicker and try to download another video from iCloud
·Application crashes natively like this:

2018-09-05 12:24:48.373 [308:19476] critical: at <unknown> <0xffffffff> 2018-09-05 12:24:48.384 [308:19476] critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (intptr,intptr,intptr,intptr) <0x0004b> 2018-09-05 12:24:48.392 [308:19476] critical: at UIKit.UICollectionView.PerformBatchUpdates (System.Action,UIKit.UICompletionHandler) [0x0005f] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/build/ios/native/UIKit/UICollectionView.g.cs:552 2018-09-05 12:24:48.395 [308:19476] critical: at iOS.GMImagePicker.GMGridViewController/<>c__DisplayClass28_0.<PhotoLibraryDidChange>b__0 () [0x000c5] in iOS/GMImagePicker/GMGridViewController.cs:378 2018-09-05 12:24:48.404 [308:19476] critical: at CoreFoundation.DispatchQueue.static_dispatcher_to_managed (intptr) [0x0003d] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/CoreFoundation/Dispatch.cs:343 2018-09-05 12:24:48.408 [308:19476] critical: at (wrapper native-to-managed) CoreFoundation.DispatchQueue.static_dispatcher_to_managed (intptr) <0x000e3> 2018-09-05 12:24:48.408 [308:19476] critical: at <unknown> <0xffffffff> 2018-09-05 12:24:48.411 [308:19476] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x0004f> 2018-09-05 12:24:48.412 [308:19476] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:79 2018-09-05 12:24:48.413 [308:19476] critical: at UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:63 2018-09-05 12:24:48.414 [308:19476] critical: at iOS.Application.Main (string[]) [0x00001] in Main.cs:18 2018-09-05 12:24:48.418 [308:19476] critical: at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) [0x0001e] in <d680a8bf3a2a4c8dbbfde665ba81f6f2#A683D333-58E2-40DC-F898-4B3DAA7253C3>:0 2018-09-05 12:24:48.419 [308:19476] critical:

I couldn't find who is calling UIKit.UICollectionView.PerformBatchUpdates on GMGridViewController.
Which I guess is causing the native crash.
Note that this is not happening if the file requested is stored on the device.

Any help will be appreciated,

thanks and congratulations for this component 👍

Btw I fixed my problem with a workaround...
Simply putting a boolean on GMPickerController "bool Disposed" and setting it to true when Dispose() is called. Then I check _picker.Disposed boolean as an exit precondition on PerformBatchUpdates.

if you try to disable 'done' button while your image is downloading it will be succeed. I import some progress view on every cell in collectionview when I clearify my code I'm going to fork and import it.
it is based on gridviewcontroller.cs and gridviewcell.cs 'itemselected' method. you should check whether image is available on local or not. if it is available then go. if it is not then try to sync it by RequestContentEditingInput method. 'request options' should include networkaccessallowed = true.

@kormemis I configured the component to be single selection so the 'done' button its never been shown to the user, it works with a single tap on the selected video. Also I check whether the file is stored locally first and my request options for cloud assets include "networkaccessallowed = true" as you said.

Anyway I will be glad to see your fork when you are done just for check if I'm doing something wrong. Thanks for the reply :)