Open MaxFmi opened 3 years ago
Reverted the PR for this as it caused an NRE in another scenario. At least this bug has a workaround. We should see if we can fix this properly.
@AlleSchonWeg
https://github.com/xamarin/Xamarin.Forms/pull/14730#issuecomment-943202026
Moving the discussion to here :)
Not sure if that's the issue. The actual exception happened on this line
Where element
would be null
The first navigation call end up in this else case: https://github.com/xamarin/Xamarin.Forms/blob/ae8e52feb5faacf1890b870eb291b509e5b832e6/Xamarin.Forms.Core/Shell/ShellNavigationManager.cs#L166 Which is not surrounded by "InvokeOnMainThread" and throws the exception "Can only be called on ui thread!".
The navigation calls above are wrapped by "InvokeOnMainThread" and work as expected: https://github.com/xamarin/Xamarin.Forms/blob/ae8e52feb5faacf1890b870eb291b509e5b832e6/Xamarin.Forms.Core/Shell/ShellNavigationManager.cs#L160
Description
Steps to Reproduce
Expected Behavior
Should navigate as expected.
Actual Behavior
Exception get thrown: "Can only be called on ui thread!"
Basic Information
Workaround
Wrap "await Shell.Current.GoToAsync(route);" in "await Device.InvokeOnMainThreadAsync(...);"