MediaPlugin: [iOS] App crash after double tap on a photo
Bug Information
Version Number of Plugin: 5.0.1.1 Device Tested On: iPhone 11, iOS 14.3 Simulator Tested On: n/a Version of VS: 16.9.3 Version of Xamarin: 16.9 Versions of other things you are using: Xamarin.Essential 1.6.1
Unfortunately Xamarin.essentials.MediaPicker is currently missing many options to be able to migrate.
Steps to reproduce the Behavior
Open gallery and double tap on any photo
Expected Behavior
Photo selected (or at least no crash)
Actual Behavior
App throws exception and crashes
Code snippet
var fileMedia = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions());
if (fileMedia != null)
{
//
}
Screenshots

Callstack
Exception : System.ObjectDisposedException
Message : Cannot access a disposed object.
Object name: 'Foundation.InternalNSNotificationHandler'.
StackTrace : at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:34
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:29
at Foundation.NSNotificationCenter.RemoveObserver (Foundation.NSObject observer) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/Foundation/NSNotificationCenter.g.cs:179
at Plugin.Media.MediaPickerDelegate.RemoveOrientationChangeObserverAndNotifications () [0x00012] in d:\a\1\s\src\Media.Plugin\iOS\MediaPickerDelegate.cs:197
at Plugin.Media.MediaPickerDelegate.FinishedPickingMedia (UIKit.UIImagePickerController picker, Foundation.NSDictionary info) [0x00037] in d:\a\1\s\src\Media.Plugin\iOS\MediaPickerDelegate.cs:52
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at iOS.Application.Main (System.String[] args) [0x00001] in Main.cs:12
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 20 (4 by maintainers)
Im also having this issue with my App. More than 100+ crashes are occuring due to this. Please fix this issue asap and revert.
Thanks, fix issues solved with it’s version https://www.nuget.org/packages/Xam.Plugin.Media/5.1.1-beta
I have same bug. please fix issue.
Version beta have error.
Method not found MediaFile.
5.1.0-beta
No nuget update yet?
This seems to solve the crash at least by modifying RemoveOrientationChangeObserverAndNotifications in the iOS MediaPickerDelegate.
Any update on this issue? So many crashes are happening in our App due to this plugin issue.
Is this issue fixed?