Xamarin.forms: NavigationPage crashes on macOS on startup.

Created on 13 Jun 2018  路  16Comments  路  Source: xamarin/Xamarin.Forms

Description

Application taken from https://github.com/xamarin/dev-days-labs, with macOS support added.

Steps to Reproduce

  1. Run the application
  2. Observe the crash

Expected Behavior

No crash

Actual Behavior

  at Xamarin.Forms.Platform.MacOS.NativeToolbarTracker.UpdateTitle () [0x00125] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.NativeToolbarTracker.UpdateToolBar () [0x0011b] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.NativeToolbarTracker.set_Navigation (Xamarin.Forms.NavigationPage value) [0x0008d] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.NavigationPageRenderer.Init () [0x00025] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.NavigationPageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0000e] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00027] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.Platform.WillAppear () [0x0001c] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.PlatformRenderer.ViewWillAppear () [0x00006] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(intptr,intptr,intptr)
  at AppKit.NSWindow.set_ContentViewController (AppKit.NSViewController value) [0x00025] in /Library/Frameworks/Xamarin.Mac.framework/Versions/4.5.0.280/src/Xamarin.Mac/AppKit/NSWindow.g.cs:8784 
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.UpdateMainPage () [0x00034] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.SetMainPage () [0x00000] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00041] in <c68a59ab414f432b997fdd72eb47bf76>:0 
  at DevDaysSpeakers.macOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00013] in /Users/filipnavara/Documents/GitHub/dev-days-labs/HandsOnLab/Start/DevDaysSpeakers/DevDaysSpeakers.macOS/AppDelegate.cs:32 
  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/4.5.0.280/src/Xamarin.Mac/AppKit/NSApplication.cs:100 
  at DevDaysSpeakers.macOS.MainClass.Main (System.String[] args) [0x00017] in /Users/filipnavara/Documents/GitHub/dev-days-labs/HandsOnLab/Start/DevDaysSpeakers/DevDaysSpeakers.macOS/Main.cs:11 

Basic Information

  • Version with issue: 3.0 (newest stable and preview in nuget tested)
  • IDE: Visual Studio for Mac

Reproduction Link


Archive.zip

high impact macOS bug

Most helpful comment

Crashing NavigationPage on 10.14. Project unchanged since last run on 10.13. Fails after AppDelegate.MainWindow.Get. True for both our development Macs. Currently on Forms 3.2.0.

All 16 comments

Hmm. I tried the sample application, and it did not crash for me. Can you provide more information about your IDE? What version are you using? What update channel? Are there any other steps that are required to create the crash? Does it happen eery time or intermittently?

Thanks!

Visual Studio for Mac, latest alpha. Happens every time. When I reported it it was on a machine running macOS Mojave beta. I will retry on stable version(s) and report back.

I assume the line that breaks is the following:
https://github.com/xamarin/Xamarin.Forms/blob/093a4efa2da9cb681890158ca8ee9bb6f30b0a8c/Xamarin.Forms.Platform.MacOS/NativeToolbarTracker.cs#L306

In UpdateBarBackgroundColor the same thing is checked for null values.

It seems the crash is specific to macOS Mojave Developer Preview. However, on macOS High Sierra it doesn't really work reliably either.

On the first run it showed me a warning that I am trying to run unsigned app (correct), but the navigation title was not in the title bar at all:

screen shot 2018-06-16 at 12 11 59
screen shot 2018-06-16 at 12 12 19

On second run it didn't display the warning anymore (also correct) and the title was present.

screen shot 2018-06-16 at 12 10 19

Seeing the same issue in our error tracking system. Happens on 10.13 as well as 10.14 (some customers use the beta). On 10.14 it happens much more often, though.

I can reproduce this on 10.14 all the time (did not try the sample code here, though)

Currently using Xamarin Forms 2.5.0.

The same here, in the 10.14 (Mojave) the error happened when using MasterDetailPage.

Crashing NavigationPage on 10.14. Project unchanged since last run on 10.13. Fails after AppDelegate.MainWindow.Get. True for both our development Macs. Currently on Forms 3.2.0.

Here's a work around.

Create the window with this style mask NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable | NSWindowStyle.FullSizeContentView.

That always works, but creates a fixed window.

Afterbase.DidFinishLaunching(notification);.
Do this:
_window.StyleMask = _window.StyleMask | NSWindowStyle.Titled;
_window.Title = "<your title>";

Result: resizable window with a title.

* Update, navigating from the root page triggers this error again :(

I'm also seeing this issue with Mojave. I rolled back to 3.1 as there were other issues with 3.2 for me. I'm using Tabbed Navigation. Now that Mojave is out, this is critical as many users are starting to upgrade and their app is now dying on them. It happens for my app when I move to a different tab than the main tab.

Is there anyway to mark this critical. I've tried the work arounds above and as stated in the update, navigating away still triggers this error message.

Same issue here with Mojave. Any news or workaround?

@samhouts Can we get this re-triaged?

Here's a work around.

Create the window with this style mask NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable | NSWindowStyle.FullSizeContentView.

That always works, but creates a fixed window.

Afterbase.DidFinishLaunching(notification);.
Do this:
_window.StyleMask = _window.StyleMask | NSWindowStyle.Titled;
_window.Title = "<your title>";

Result: resizable window with a title.

Update, navigating from the root page triggers this error again :(*

With this workaround, the application opens but crash in UpdateTitle () when the first navigation page is opened, as quoted in the Update made by @Stenciletto .

Mojave was officially released about a week ago. @pauldipietro can we get this elevated in priority. I think it was lowered because they thought there was a workaround, but the workaround didn't work.

Is there a working workaround? I tried downgrading to 3.2 because I ran into #4300, and now I'm instead running into this one.

Same experience here as @chucker. Between these two issues my mac app has been dead in the water for a few weeks now. Wishing I had not updated to Mojave yet... Please consider reopening this issue.

Was this page helpful?
0 / 5 - 0 ratings