Bug 51707 - NullReferenceException when scrolling a ListView with RecycleElement caching strategy on Android 7.1.1
Summary: NullReferenceException when scrolling a ListView with RecycleElement caching ...
Status: RESOLVED DUPLICATE of bug 51645
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-23 15:11 UTC by Marc
Modified: 2017-08-13 23:19 UTC (History)
6 users (show)

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


Attachments
SampleApp to reproduce bug (47.01 KB, application/gzip)
2017-06-26 12:58 UTC, Olivier Gauthier
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 DUPLICATE of bug 51645

Description Marc 2017-01-23 15:11:09 UTC
When scrolling a ListView with RecycleElement caching strategy it crashes with a NullReferenceException on ListViewAdapter.cs
When changed to RetainElement it works without problems.

This happens in a Huawei Nexus 6P with Android version 7.1.1 and Xamarin.Forms 2.3.3.180

This is the exception detail:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (System.Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x000ef] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:223 
  at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position, System.IntPtr native_convertView, System.IntPtr native_parent) [0x0001a] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.BaseAdapter.cs:443 
  at (wrapper dynamic-method) System.Object:1c174dc3-6b5c-4364-a227-d42ca610266c (intptr,intptr,int,intptr,intptr)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_getView(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.getView(ListViewAdapter.java:100)
	at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
	at android.widget.AbsListView.obtainView(AbsListView.java:2363)
	at android.widget.ListView.makeAndAddView(ListView.java:1970)
	at android.widget.ListView.fillDown(ListView.java:704)
	at android.widget.ListView.fillGap(ListView.java:668)
	at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5186)
	at android.widget.ListView.trackMotionScroll(ListView.java:1889)
	at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3568)
	at android.widget.AbsListView.onTouchMove(AbsListView.java:3977)
	at android.widget.AbsListView.onTouchEvent(AbsListView.java:3802)
	at android.view.View.dispatchTouchEvent(View.java:10023)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2626)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2307)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_dispatchTouchEvent(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:55)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
	at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:413)
	at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1808)
	at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
	at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
	at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
	at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:375)
	at android.view.View.dispatchPointerEvent(View.java:10243)
	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4438)
	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4306)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3999)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4056)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6246)
	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6220)
	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6181)
	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6349)
	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
	at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
	at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
	at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6320)
	at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6372)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
	at android.view.Choreographer.doCallbacks(Choreographer.java:686)
	at android.view.Choreographer.doFrame(Choreographer.java:615)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6119)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Comment 1 Akash Kava 2017-02-13 16:59:07 UTC
Same error with Google Pixel,

Android: 7.1.1
Android Build: NOF26V
Manufacturer: Google
Model: Pixel
Thread: main-1
CrashReporter Key: AC819234-F91E-C858-933D-03AFA3CDCCEB885CF8D9
Start Date: Mon Feb 13 13:11:47 GMT+05:30 2017
Date: Mon Feb 13 13:12:28 GMT+05:30 2017
Format: Xamarin

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (System.Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x000ef] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:223 
  at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position, System.IntPtr native_convertView, System.IntPtr native_parent) [0x0001a] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.BaseAdapter.cs:443 
  at (wrapper dynamic-method) System.Object:14aab1b8-4017-48f2-a23b-6736e391236e (intptr,intptr,int,intptr,intptr)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_getView(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.getView(ListViewAdapter.java:100)
	at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
	at android.widget.AbsListView.obtainView(AbsListView.java:2363)
	at android.widget.ListView.makeAndAddView(ListView.java:1970)
	at android.widget.ListView.fillDown(ListView.java:704)
	at android.widget.ListView.fillGap(ListView.java:668)
	at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5186)
	at android.widget.ListView.trackMotionScroll(ListView.java:1889)
	at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4734)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
	at android.view.Choreographer.doCallbacks(Choreographer.java:686)
	at android.view.Choreographer.doFrame(Choreographer.java:618)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6119)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Comment 2 Akash Kava 2017-02-14 12:49:01 UTC
Update, the issue occurs with items with headers only, when we scroll and next time before reusing header, bug appears.
Comment 3 Samantha Houts [MSFT] 2017-02-15 18:44:09 UTC

*** This bug has been marked as a duplicate of bug 51645 ***
Comment 4 Olivier Gauthier 2017-06-26 12:56:01 UTC
I have same issue without headers 
(see https://github.com/oliviergauthier/xamarin-forms-recycle-element-android)

When i scroll quickly, app crash with : 

System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (System.Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x000d8] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:216
  at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position, System.IntPtr native_convertView, System.IntPtr native_parent) [0x00018] in <d855bac285f44dda8a0d8510b679b1e2>:0
  at at (wrapper dynamic-method) System.Object:b341a637-46eb-4895-aaad-96593e5cef6f (intptr,intptr,int,intptr,intptr)


Working on : Nexus 4(4.4.4), Nexus 5 (6.0.1)
Failed on : Oneplus 3T (7.1.1), Android Simulator (7.1.2), Galaxy S7 Edge (7.0), Nexus 6P (8.0-preview), Galaxy S8+ (7.0)
Configuration : Debug and Release
Xamarin Forms : 2.3.4.247
Mono : 5.0.1.1
Tool : Visual Studio For Mac 7.0.1(Build 24)
Comment 5 Olivier Gauthier 2017-06-26 12:58:57 UTC
Created attachment 23115 [details]
SampleApp to reproduce bug

This sample show 2 pages, one without caching and one with caching, the one with caching crash on Android 7.0 and greater when scrolling.
Comment 6 Olivier Gauthier 2017-06-26 13:34:39 UTC
Failed also with Forms 2.3.4.231 but seems to be fixed in 2.3.5-preview