Xamarin.forms: Forms 3.3 + Mac (Regression+Crash) Changing MainPage

Created on 20 Oct 2018  路  17Comments  路  Source: xamarin/Xamarin.Forms

Description

Crash after updating to 3.3 Stable. In Forms + Mac, changing Applications Main Page crashes. Working in 3.2

Steps to Reproduce

Steps for regression crash

  1. Create a new Project with Forms 3.2 + iOS (Android not required now)
  2. Add a MacOS cocoa project with Forms 3.2 dependency. Set this as default project.
  3. Make necessary changes in macOS files and ensure the MainPage is visible.
  4. Add a new SecondPage.XAML
  5. In App.xaml.cs, change the app's MainPage to SecondPage.XAML (just to verify its working)
  6. To the SecondPage add a button 'Click Me'. In the button handler add the following code
    var myApp = (App)Xamarin.Forms.Application.Current;
    myApp.MainPage = new MainPage();
  7. Run the macOS app, click the button 'Click Me'. Wait for few seconds >>CRASH <<

Expected Behavior

Specified page must be visible and application continues to work.

Actual Behavior

CRASH<<

Basic Information

  • Version with issue: 3.3.0.912450
  • Last known good version:3.2.0871581
  • IDE: Visual Studio for Mac
  • Platform Target Frameworks:

    • macOS: 10.11

  • Nuget Packages: forms 3.3.0.912450
  • Affected Devices:

Screenshots

Reproduction Link

blocker 3 help wanted regression macOS bug up-for-grabs

Most helpful comment

Same trouble with NullReferenceException in AppKit.NSApplication.NSApplicationMain in Xamarin.Forms 3.3, 3.4 and 4.0 pre1 on Mac.
3.2 works fine.
In my case the exception happens whenever Xamarin.Forms animation is triggered, other parts of my app seem to work fine.

All 17 comments

I investigated

Breaking commit: cceee9ded6c8cadb19eb547f72d03c6c14230058

Remove it, and all will work properly

#if __MACOS__
        public override NativeView NextKeyView { 
            get {
                return FocusSearch (forwardDirection: true) ?? base.NextKeyView;
            }
            set {
                if (value != null) // setting the value to null throws an exception
                    base.NextKeyView = value;
            }
        }

        public override NativeView PreviousKeyView {
            get {
                return FocusSearch (forwardDirection: false) ?? base.PreviousKeyView;
            }
        }
#else

This is strange, but if you preserve only one property (return base value) and remove another

        public override NativeView PreviousKeyView {
            get {
                return base.PreviousKeyView;
            }
        }

It will continue crash the app

As I undersand, app tries to use disposed views.

Release notes of 3.3.0.967583 says this issue is fixed --> Release Notes

It still crashes with error

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper managed-to-native) AppKit.NSApplication.NSApplicationMain(int,string[])
  at AppKit.NSApplication.Main (System.String[] args) [0x00040] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.0.0.0/src/Xamarin.Mac/AppKit/NSApplication.cs:100 

Any dependent issues pending?

Repro steps on vCurrent (3.4.0):

  • run ControlGallery on Mac
  • click on SwapRoot - ContentPage twice or more
  • app crash...

Yes please and thank you for reopening. Looks very similar to #4300.

Same trouble with NullReferenceException in AppKit.NSApplication.NSApplicationMain in Xamarin.Forms 3.3, 3.4 and 4.0 pre1 on Mac.
3.2 works fine.
In my case the exception happens whenever Xamarin.Forms animation is triggered, other parts of my app seem to work fine.

4.0 prerelease has this issue as well. Can't build any apps with more than 1 page.
Same thing happens when changing masterDetailPage.Detail to a new page.
macOS page navigation is completely nonfunctional.

Don't know if anyone is seriously looking into the same.
A blocking issue not attended for more than 60 days.

Any ETA on this release?

@samhouts can we have an ETA on this please?
It's close to 90 days now... especially a blocking issue like this.

Great to see the issue In Progress! Be sure to test on Mojave. It was after the update to Mojave and XF3.3 that I started having blocking issues, including this one, on MacOS.

Circling back...great to have this fix, and it works!

Latest update worked! Good work!

This is still happening on Xamarin.Forms 4.0 pre9. I reverted to 3.6 and was able to continue for now.

@samhouts this is still present in Xamarin.Forms 4.0.0 final release. I had to downgrade to 3.6.0 again.

@DeerSteak Thanks for the new issue! This one is specifically for MacOS, so I don't believe it is related. We'll take a look at your issue on 6244.

Same here, changing MainPage in Xamarin.Forms.Application makes the MacOS app crash.

I first downgraded Xamarin.Forms from 4.0.0.49... to 3.6.0.34... and it was still crashing.
Then I downgraded Xamarin.Forms on the common library too, and it worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simontocknell picture simontocknell  路  3Comments

Stensan picture Stensan  路  3Comments

joseluisct picture joseluisct  路  3Comments

deakjahn picture deakjahn  路  3Comments

EmilAlipiev picture EmilAlipiev  路  3Comments