Mediaplugin: Bug iOS or Xamarin Updates started crashing iOS photo picking or take photos

Created on 15 Oct 2019  路  16Comments  路  Source: jamesmontemagno/MediaPlugin

Bug Information

Version Number of Plugin: https://www.nuget.org/packages/Xam.Plugin.Media/4.4.1-beta
Device Tested On: iPhone 8
Simulator Tested On: iPhone 8
Version of VS: Version 8.3.3 (Build 8)
Version of Xamarin: Xamarin iOS 13.4.0.2
Versions of other things you are using:

Steps to reproduce the Behavior

Please press take photo

Take photo

Use Photo

App crashes or Hangs.

Expected Behavior

This should go back to calling program and return location of the program

Actual Behavior

Hangs after pressing use photo

Code snippet

System.NullReferenceException: Object reference not set to an instance of an object
at Plugin.Media.MediaPickerDelegate.GetPictureMediaFile (Foundation.NSDictionary info) [0x0007d] in D:\a\1\s\src\Media.Plugin\iOS\MediaPickerDelegate.cs:291
at Plugin.Media.MediaPickerDelegate.FinishedPickingMedia (UIKit.UIImagePickerController picker, Foundation.NSDictionary info) [0x00090] in D:\a\1\s\src\Media.Plugin\iOS\MediaPickerDelegate.cs:61
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/Foundation/NSAction.cs:178
at 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 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at Manbir.iOS.Application.Main (System.String[] args) [0x0001b] in /Users/manbir/manbirmobile/Manbir.iOS/Main.cs:26

Screenshots

image

Most helpful comment

Nope, there was a different PR that broke it completely.

All 16 comments

Can you try 4.4.3-beta which is latest. Also provide sample code for what you are calling.

@jamesmontemagno Please check the sample code below. I have upgraded my project to 4.4.3-beta of Xam.Plugin.Media
namespace XamarinPluginMedia
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();

        takePhoto.Clicked += TakePhoto_ClickedAsync;
    }

    private async void TakePhoto_ClickedAsync(object sender, EventArgs e)
    {
        await CrossMedia.Current.Initialize();

        if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
        {
            DisplayAlert("No Camera", ":( No camera available.", "OK");
            return;
        }

        var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
        {
            Directory = "Sample",
            Name = "test.jpg"
        });

        if (file == null)
            return;

        await DisplayAlert("File Location", file.Path, "OK");
    }
}

}

Hi James, thanks for this great library!

I'm also getting a NullReferenceException while taking a photo (CrossMedia.Current.TakePhotoAsync).
It happens when tapping 'DONE' (after the photo has been taken).

iPhone 8 - Running iOS 13.2

Screen Shot 2019-10-16 at 3 09 29 pm

this is on the new 4.4.3-beta for me too

Got it! Just debugged it. Will be fixed in 4.4.4 asap.

Got it! Just debugged it. Will be fixed in 4.4.4 asap.

Awesome!! Thank you James

https://github.com/ManbirSinghRakhra/XamarinMediaProject
@jamesmontemagno I am sending you my github project for testing. There is nothing but your latest libraries.

Great thanks James, was it a 13.2 issue?

Nope, there was a different PR that broke it completely.

Thanks you so much @jamesmontemagno.

Just tested with 4.4.4 on iOS 13.2.2
Still crashes when taking a photo on a physical device after tapping Use Photo.

Sorry James, I'll try and see if I can figure out the problem.

=================================================================

Basic Fault Address Reporting

Memory around native instruction pointer (0x1b4e72f3c):0x1b4e72f2c 24 e9 fd 97 e0 1f 40 f9 6f e0 01 94 fb 03 00 aa [email protected].......
0x1b4e72f3c 00 04 40 f9 e2 7c 1e 90 42 80 1a 91 e1 1f 40 f9 ..@..|..B.....@.
0x1b4e72f4c f8 28 fc 97 e8 1f 40 b9 88 02 00 34 c2 7c 1e f0 .([email protected].|..
0x1b4e72f5c 42 00 07 91 e0 1f 40 f9 01 00 80 d2 d6 6b ff 97 [email protected]..

=================================================================

Managed Stacktrace:

  at <unknown> <0xffffffff>
  at ImageIO.CGImageDestination:CGImageDestinationFinalize <0x00007>
  at ImageIO.CGImageDestination:Close <0x00017>
  at Plugin.Media.MediaPickerDelegate:SaveImageWithMetadata <0x010b7>
  at <GetPictureMediaFile>d__27:MoveNext <0x017a3>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x001ab>
  at Plugin.Media.MediaPickerDelegate:GetPictureMediaFile <0x0021f>
  at <FinishedPickingMedia>d__10:MoveNext <0x002c3>
  at System.Object:runtime_invoke_dynamic <0x00103>
  at <unknown> <0xffffffff>
  at System.Object:__icall_wrapper_mono_gsharedvt_constrained_call <0x00007>
  at System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start <0x00173>
  at Plugin.Media.MediaPickerDelegate:FinishedPickingMedia <0x00297>
  at System.Object:runtime_invoke_dynamic <0x00103>
  at <unknown> <0xffffffff>
  at UIKit.UIApplication:UIApplicationMain <0x00007>
  at UIKit.UIApplication:Main <0x0002b>
  at UIKit.UIApplication:Main <0x00043>
  at Skedulo.iOS.Application:Main <0x0014b>
  at System.Object:runtime_invoke_dynamic <0x00103>

So, this is different, grabbing the wives iPhones :)

LOL, it seems to be working on iOS13.1.2 so we're probably seeing a bug with the inbuilt system.

she has 13.1.2, so i can't do anything really and i don't have any 13.2.2, but you can run the code and test locally

All good mate, get some sleep ;-)

@jamesmontemagno @clintonrocksmith
It doesn't work with iPhone IOS 13.2 (Emulator). I'm getting the "System.NullReferenceException: Object reference not set to an instance of an object
at XFApp.Views.MediaPage.SelectVideo_Clicked" error when picking a video (or cancel)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Soumya-G picture Soumya-G  路  5Comments

fadaEntrepidus picture fadaEntrepidus  路  6Comments

irinakush picture irinakush  路  6Comments

MarcorOnline picture MarcorOnline  路  7Comments

manonaga2188 picture manonaga2188  路  5Comments