Bug 51429 - Exception thrown when scrolling grouped listview with RecycleElements on on physical Android device
Summary: Exception thrown when scrolling grouped listview with RecycleElements on on p...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: High critical
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
URL:
: 49011 51645 ()
Depends on:
Blocks:
 
Reported: 2017-01-11 22:20 UTC by Robert
Modified: 2017-05-24 21:36 UTC (History)
10 users (show)

Tags: android ac
Is this bug a regression?: ---
Last known good build:


Attachments
These two files can be used to duplicate the bug. They contain the code to create and display a listview (1.66 KB, application/x-zip-compressed)
2017-01-11 22:20 UTC, Robert
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Robert 2017-01-11 22:20:05 UTC
Created attachment 19237 [details]
These two files can be used to duplicate the bug. They contain the code to create and display a listview

I have a ListView that is using a custom cell template with a stacklayout and the listview is grouped. I would like to have the listview use a caching stragegy of recycle element. If I set up a listview with this criteria, I get a system crash and a null exception thrown after scrolling a little bit down the list. This only happens on a physical device,

I tested this on an LG v20 and a Google Pixel.

On the emulator the error never occurs.

Here is the stack trace I got:

0xFB in Xamarin.Forms.Platform.Android.ListViewAdapter.GetView at C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:223,5	C#
0x1E in Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ at /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.BaseAdapter.cs:443,4	C#
Comment 1 Robert 2017-01-11 22:21:14 UTC
I also see Bug49011 marking this as not reproducible, but I was able to reproduce this result with the attachment I added.
Comment 2 Andrew Herrick 2017-01-30 01:15:44 UTC
Hi. I've had a few of my Droid users experience this exact thing as well. Seems it's a common problem with Droid 7.0+

Any fix/work around you found?

These seem like the same:

https://bugzilla.xamarin.com/show_bug.cgi?id=51429
https://bugzilla.xamarin.com/show_bug.cgi?id=51645
https://bugzilla.xamarin.com/show_bug.cgi?id=51704
Comment 3 Andrew Herrick 2017-01-30 15:20:01 UTC
FYI this is still an issue in Forms 2.3.4.184-pre1
Comment 4 Andrew Herrick 2017-01-30 16:43:00 UTC
My current workaround is to use "RetainElement" if Android. Obviously not ideal but not sure what else to do.
    
C#:

public class CacheListView : ListView
    {
        public CacheListView(ListViewCachingStrategy strategy) : base(strategy)
        {
        }
    }


XAML:

      <common:CacheListView x:Name ="lstView" IsGroupingEnabled="true"
                HasUnevenRows="True"
                GroupDisplayBinding="{Binding Key}"
                ItemTapped="OnItemSelected"
                IsVisible="{Binding ShowList}"
                IsPullToRefreshEnabled="True"
                RefreshCommand="{Binding LoadMyListCommand}"
                IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                ItemsSource="{Binding MyList}">

          <x:Arguments>
            <ListViewCachingStrategy>
              <OnPlatform x:TypeArguments="ListViewCachingStrategy" iOS="RecycleElement" Android="RetainElement" WinPhone="RecycleElement" />
            </ListViewCachingStrategy>
          </x:Arguments>

      </common:CacheListView>
Comment 5 John Harris 2017-01-30 17:32:33 UTC
I run a custom listview for all my stuff. I added a check for Android 7 to get around this for now.
static ListViewCachingStrategy GetStrategy()
{
    if (Device.OS == TargetPlatform.Android && new Version(CrossDeviceInfo.Current.Version).Major >= 7)
    {
        return ListViewCachingStrategy.RetainElement;
    }
    return ListViewCachingStrategy.RecycleElement;
}

public ListView() : base(GetStrategy())
{
}
Comment 6 Andrew Herrick 2017-01-30 18:12:30 UTC
Nice! I like this better than trying to pass parms via XAML. Thanks!
Comment 7 Samantha Houts [MSFT] 2017-02-15 18:47:58 UTC
*** Bug 49011 has been marked as a duplicate of this bug. ***
Comment 8 Samantha Houts [MSFT] 2017-02-15 18:49:57 UTC
*** Bug 51645 has been marked as a duplicate of this bug. ***
Comment 9 Olivier Ansquer 2017-03-18 09:19:38 UTC
No fix ? This bug is critical. It crashes all my listviews on Android 7.
Comment 10 Akash Kava 2017-03-22 05:37:57 UTC
Any update? This is blocking issue.
Comment 11 daniel.bergquist 2017-05-23 21:05:29 UTC
I'm seeing this in 2.3.4.247
Comment 12 Samantha Houts [MSFT] 2017-05-24 21:36:39 UTC
This was fixed by https://github.com/xamarin/Xamarin.Forms/pull/856. Please try 2.3.5-pre1+.

Thank you!