This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 42832 - Scrolling in ListView with active ContextActions causes System.NullReferenceException
Summary: Scrolling in ListView with active ContextActions causes System.NullReferenceE...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-27 10:37 UTC by Markus.Rollmann
Modified: 2016-11-09 22:18 UTC (History)
6 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
repro project (58.71 KB, application/zip)
2016-08-19 16:30 UTC, Jimmy Garrido
Details
Reproduction project (286.02 KB, application/x-zip-compressed)
2016-11-07 16:34 UTC, c.krempp91
Details

Description Markus.Rollmann 2016-07-27 10:37:41 UTC
The listview caching strategy have to be "Recycle element"
Select an item in a listview with context actions with a long click. then on android the context action bar appears on the top, and the selected item gets a blue background. Now scoll a few times down and up, so that the selected item is scrolled out of diplay and comes again on display. This causes a crash with a System.NullReferenceException.
Comment 1 Rui Marinho 2016-08-10 16:21:22 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages for the latest pre release 2.3.2-pre1, please reopen this report with an attached reproduction.

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards, 
Xamarin Forms Team
Comment 2 Jimmy Garrido 2016-08-19 16:30:44 UTC
Created attachment 17127 [details]
repro project

I can still reproduce the crash with Forms 2.3.2-pre1. I've attached a repro project.

### Steps to Reproduce
1. Run the attached Android project
2. Long press a list item to open the context actions
3. Scroll the ListView around

### Expected Results
No app crash

### Actual Results
The app will crash. It appears to happen when the selected item is displayed on screen again then scrolled offscreen.
Comment 3 Jimmy Garrido 2016-08-19 16:32:21 UTC
Reopening due to comment 2
Comment 4 Rui Marinho 2016-10-17 18:00:00 UTC
Should be fixed in 2.3.4-pre1
Comment 5 Hrafn Loftsson 2016-10-28 10:10:40 UTC
A similar bug is in iOS.  When activating a context action (delete) in a listview and scrolling up/down, you get the following:

System.ArgumentNullException has been thrown
Value cannot be null.
Parameter name: gestureRecognizer

I have made a test project which shows this behavior: https://github.com/KolibriDev/TestLayoutXaml
Comment 6 c.krempp91 2016-11-07 16:34:16 UTC
Created attachment 18355 [details]
Reproduction project

This is a reproduction of the issue(s) described.
Comment 7 c.krempp91 2016-11-07 16:35:25 UTC
I have not been able to test against 2.3.4-pre1, but I was testing against 2.3.3.166-pre4. I noticed this issue, and one other which I believe has a very similar root cause. The second issue I found was that if you have the context action bar present and perform an orientation change, the amount of times varies but 1 - 2 times should do it, the app will crash. From what I can gather these issues only occur when certain conditions are met: 

First, ListViewCachingStrategy.RecycleElement needs to be set for the ListView.

Second, You have to be using data binding for the crash to occur. If you just have a ListView that contains views without any BindingContext the crash does not occur. 

I have added a test project as well which should exhibit both issues:
https://bugzilla.xamarin.com/attachment.cgi?id=18355

Note You need to log in before you can comment on or make changes to this bug.