0

My Xamarin iOS app is crashing on a ContentPage when I switch away from it to another app.

The first occurrence was in a label renderer, so I wrapped it in a try catch block:

protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
    //Add a try because of this:    
    //https://stackoverflow.com/questions/46881393/ios-crash-report-unexpected-start-state-exception
    try
    {
        base.OnElementChanged(e);

        if (label != null)
        {
            sv = label.Parent as ScrollViewEx;
        }
    }
    catch
    {

    }

}

Now it is crashing in another part of the app trying to access a disposed editor object when I switch away.

Is there a life cycle thing going on here that I need to be aware of in terms of why the OS is trying to re-render UI objects in such circumstances?

And how can I generically protect my app from these sorts of crashes without having to wrap every single UI object in a try catch just because I'm switching to another app?

jho
  • 199
  • 1
  • 8

1 Answers1

0

I am not familiar with the issue, however, what I can recommend is at the end of the catch keyword, put (Exception e) as a parameter

try
{...}
catch(Exception e)
{
    Debug.WriteLine(e.Message);
}

This way you will be one step closer to figuring out this painful bug.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 06 '22 at 02:09