Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Shell: First navigation call on background thread throws the exception "Can only be called on ui thread!" #14366

Open
MaxFmi opened this issue Jun 23, 2021 · 2 comments · Fixed by #14577
Assignees
Labels
a/shell 🐚 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often t/bug 🐛

Comments

@MaxFmi
Copy link

MaxFmi commented Jun 23, 2021

The first navigation call end up in this else case:

await _shell.CurrentItem.CurrentItem.GoToAsync(navigationRequest, queryData, animate, isRelativePopping);
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:
return _shell.CurrentItem.CurrentItem.GoToAsync(navigationRequest, queryData, animate, isRelativePopping);

Description

Steps to Reproduce

  1. Set MainPage of your Shell application
  2. Invoke navigation through "await Shell.Current.GoToAsync(route);"
  3. We end up in line 166 of ShellNavigationManager

Expected Behavior

Should navigate as expected.

Actual Behavior

Exception get thrown: "Can only be called on ui thread!"

Basic Information

  • Version with issue: 4.8.0.1687 (but is still the case in 5.x -> see links above)
  • Last known good version: -
  • Platform Target Frameworks:
    • iOS: 13.x and 14.x
    • Android: not tested but we expect that it behaves the same way as on iOS

Workaround

Wrap "await Shell.Current.GoToAsync(route);" in "await Device.InvokeOnMainThreadAsync(...);"

@MaxFmi MaxFmi added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 23, 2021
@jsuarezruiz jsuarezruiz added this to New in Triage via automation Sep 3, 2021
@jsuarezruiz jsuarezruiz added the i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often label Sep 6, 2021
@jsuarezruiz jsuarezruiz moved this from New to Needs Estimate in Triage Sep 6, 2021
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Sep 6, 2021
@jsuarezruiz jsuarezruiz self-assigned this Sep 6, 2021
@jfversluis jfversluis added this to To Fix in 5.0.0 SR 5 (Planning) via automation Sep 8, 2021
Triage automation moved this from Needs Estimate to Closed Sep 8, 2021
5.0.0 SR 5 (Planning) automation moved this from To Fix to Done Sep 8, 2021
@jfversluis
Copy link
Member

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.

@jfversluis jfversluis reopened this Oct 14, 2021
Triage automation moved this from Closed to New Oct 14, 2021
@jfversluis
Copy link
Member

@AlleSchonWeg

#14730 (comment)

Moving the discussion to here :)

Not sure if that's the issue. The actual exception happened on this line

element.SetValue(ShellContent.QueryAttributesProperty, MergeData(element, query, isPopping));

Where element would be null

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/shell 🐚 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often t/bug 🐛
Projects
Triage
  
Ready For Work
Development

Successfully merging a pull request may close this issue.

3 participants