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

[Bug] UWP: PopAsync causes a crash when called from a CollectionView.SelectionChanged event #11090

Closed
JogyBlack opened this issue Jun 17, 2020 · 2 comments · Fixed by #11160
Closed
Assignees
Labels
a/collectionview blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛
Milestone

Comments

@JogyBlack
Copy link
Contributor

Description

In latest releases of Xamarin.Forms, calling Navigation.PopAsync() from a CollectionView.SelectionChanged handler causes a crash in UWP projects.
Same code works fine with Android.

Steps to Reproduce

  1. Create a simple Xamarin.Forms navigation application with two pages.
  2. The main page contains a button to navigate to the second page.
  3. The second page contains a CollectionView with several elements, and a SelectionChanged handler. In the SelectionChanged handler call Navigation.PopAsync to return to the main page.

Expected Behavior

The user is navigated back to the main page.

Actual Behavior

Unhandled exception: "Object reference not set to an instance of an object."
at Xamarin.Forms.Platform.UWP.SelectableItemsViewRenderer1.UpdateFormsSingleSelection() at Xamarin.Forms.Platform.UWP.SelectableItemsViewRenderer1.UpdateFormsSelection()
at Xamarin.Forms.Platform.UWP.SelectableItemsViewRenderer`1.NativeSelectionChanged(Object sender, SelectionChangedEventArgs args)

Basic Information

  • Version with issue: 4.6.0.967
  • Last known good version: 4.4.0.991864
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • UWP: 16299
  • Affected Devices: Windows Desktop

Reproduction Link

Sample project to demonstrate the problem:
App1.zip

Workaround

Instead of handling SelectionChanged, use a TapGestureRecognizer for the items in the CollectionView and call PopAsync() there.

@JogyBlack JogyBlack added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 17, 2020
@hartez hartez added a/collectionview p/UWP and removed s/unverified New report that has yet to be verified labels Jun 17, 2020
@hartez hartez added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often e/2 🕑 2 labels Jun 17, 2020
@hartez hartez self-assigned this Jun 17, 2020
@JogyBlack
Copy link
Contributor Author

Note: still happens with the just released Xamarin.Forms 4.7.0.968

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jun 22, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@mattleibow
Copy link
Contributor

Just tried this with 4.8.0.1364 and it just happened.

@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@PureWeen PureWeen added this to the 5.0.0 milestone Nov 5, 2020
@rmarinho rmarinho added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Nov 16, 2020
rmarinho pushed a commit that referenced this issue Nov 23, 2020
…ixes #11090

* Fix UWP CollectionView crash pop navigation in SelectionChanged

* Moved the validation to line 178
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants