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

[Bug] [iOS] NRE on grouped ListView when removing cells with gesture recognizers #11381

Closed
sescalada opened this issue Jul 9, 2020 · 1 comment · Fixed by #13012
Closed
Assignees
Labels
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/iOS 🍎 t/bug 🐛

Comments

@sescalada
Copy link
Contributor

Description

When working with a grouped list, if you add a gesture recognizer which handler ends modifying bound collection, a NRE is raised.
To reproduce the issue, I just modified public grouped ListView sample. Template was changed to include an Image with a
TapGestureRecognizer, which removes tapped cell and its group, if that group is no longer containing elements.

NRE is produced in iOS EventTracker.

Stack trace:

2020-07-09 17:17:46.650135+0200 groupingSampleListViewiOS[2527:32870]
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.iOS.EventTracker.LoadRecognizers () [0x00059] in D:\a\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:576
at Xamarin.Forms.Platform.iOS.EventTracker.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs e) [0x0004e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:644
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:384
at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:129
at Xamarin.Forms.Platform.iOS.ImageRenderer.<>n_
_0 (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) <0x117289fa0 + 0x0005a> in <b4a6bff6d9dc43cf83129db67d9306c1>:0 at Xamarin.Forms.Platform.iOS.ImageRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x000a8] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ImageRenderer.cs:77
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main
(System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at GroupingSampleListView.Application.Main (System.String[] args) [0x00001] in D:\repos\Samples\Xamarin_Forms___ListView_Grouping\groupingSampleListView\iOS\Main.cs:17
2020-07-09 17:17:46.651465+0200 groupingSampleListViewiOS[2527:32870] Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
at Xamarin.Forms.Platform.iOS.EventTracker.LoadRecognizers () [0x00059] in D:\a\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:576
at Xamarin.Forms.Platform.iOS.EventTracker.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.
iOS.VisualElementChangedEventArgs e) [0x0004e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:644
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:384
at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:129
at Xamarin.Forms.Platform.iOS.ImageRenderer.<>n__0 (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) <0x117289fa0 + 0x0005a> in <b4a6bff6d9dc43cf83129db67d9306c1>:0 at Xamarin.Forms.Platform.iOS.ImageRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x000a8] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ImageRenderer.cs:77
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplicati
on.cs:65
at GroupingSampleListView.Application.Main (System.String[] args) [0x00001] in D:\repos\Samples\Xamarin_Forms___ListView_Grouping\groupingSampleListView\iOS\Main.cs:17

Steps to Reproduce

  1. Tap on image with red background to remove a cell.
  2. Repeat for all cells.
  3. At some moment, NRE will be raised.

I was able to reproduce it on every run using iPhone 11 simulator from Windows.

Expected Behavior

Not having a NRE.

Actual Behavior

NRE is raised.

Basic Information

  • Version with issue: 4.7
  • Last known good version:
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • iOS: [13.5]

Screenshots

Reproduction Link

Xamarin_Forms___ListView_Grouping.zip

Workaround

Instead of using Image + Recognizer you can try with a button with opacity.

@sescalada sescalada added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 9, 2020
@pauldipietro pauldipietro added this to New in Triage Jul 9, 2020
@PureWeen
Copy link
Contributor

PureWeen commented Jul 9, 2020

Yea, it looks like this was intended to fix
#1569 this but didn't quite completely fix it

@PureWeen PureWeen moved this from New to Ready For Work in Triage Jul 9, 2020
@PureWeen PureWeen added m/high impact ⬛ and removed s/unverified New report that has yet to be verified labels Jul 9, 2020
@PureWeen PureWeen added this to the 4.8.0 milestone Jul 9, 2020
@PureWeen PureWeen added the e/2 🕑 2 label Jul 9, 2020
@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often and removed m/high impact ⬛ labels Jul 13, 2020
@samhouts samhouts added this to To do in iOS Ready For Work Jul 16, 2020
@samhouts samhouts removed this from Ready For Work in Triage Jul 16, 2020
@samhouts samhouts added this to To do in vCurrent (4.8.0) Jul 30, 2020
@samhouts samhouts modified the milestones: 4.8.0, 5.0.0 Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@samhouts samhouts removed this from To do in vCurrent (4.8.0) Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@jsuarezruiz jsuarezruiz added the in-progress This issue has an associated pull request that may resolve it! label Dec 1, 2020
@jsuarezruiz jsuarezruiz moved this from To do to In progress in iOS Ready For Work Dec 1, 2020
@jsuarezruiz jsuarezruiz self-assigned this Dec 10, 2020
iOS Ready For Work automation moved this from In progress to Done Dec 18, 2020
rmarinho added a commit that referenced this issue Dec 18, 2020
* Fixed issue removing cells on iOS ListView

* Added UITest

* Run Issue11381 UITest only on iOS

Co-authored-by: Rui Marinho <me@ruimarinho.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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/iOS 🍎 t/bug 🐛
Projects
Development

Successfully merging a pull request may close this issue.

4 participants