Bug 51704 - ArgumentOutOfRangeException in Grouped ListView on Android when any Accessibility service is active
Summary: ArgumentOutOfRangeException in Grouped ListView on Android when any Accessibi...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 35546 ()
Depends on:
Blocks:
 
Reported: 2017-01-23 14:46 UTC by Anonymous
Modified: 2017-10-23 20:17 UTC (History)
11 users (show)

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


Attachments
Reproduction project (60.35 KB, application/zip)
2017-01-23 14:46 UTC, Anonymous
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 Anonymous 2017-01-23 14:46:36 UTC
Created attachment 19444 [details]
Reproduction project

Changing ListView's bound ItemsSource in Grouped ListView causes ArgumentOutOfRange Exception on Android Nougat. To reproduce, click on the right arrow button in the attached repro project on an Android Nougat device. Lower versions of Android will not crash. iOS appears to work fine as well.
Comment 1 E.Z. Hart [MSFT] 2017-01-27 19:55:55 UTC
(In reply to williamd from comment #0)
> Created attachment 19444 [details]
> Reproduction project
> 
> Changing ListView's bound ItemsSource in Grouped ListView causes
> ArgumentOutOfRange Exception on Android Nougat. To reproduce, click on the
> right arrow button in the attached repro project on an Android Nougat
> device. Lower versions of Android will not crash. iOS appears to work fine
> as well.

William,

What devices have you observed this problem on? Have you seen it in an emulator? I ran the repro project on a Nexus 6 with Android 7, and tapping the right arrow button just takes me to Page 2 (no crash). Is there maybe another step I'm missing?
Comment 2 Anonymous 2017-01-27 20:44:18 UTC
I've reproduced the issue on my Nexus 6P running Android 7.1.1 to be exact. We've also had reports of the crash occurring on a Pixel device on 7.1.1
Comment 3 Anonymous 2017-01-27 20:45:48 UTC
I have not tried to reproduce the issue on an emulator yet.
Comment 4 Anonymous 2017-01-30 17:31:03 UTC
Setting status back to new after providing additional information.
Comment 5 Anonymous 2017-01-31 15:08:42 UTC
The issue does not appear to occur on Android emulators. You must use a physical device to reproduce the issue.

[art] art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: JNI NewString called with pending exception android.runtime.JavaProxyThrowable: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
[art] art/runtime/java_vm_ext.cc:470] Parameter name: index
[art] art/runtime/java_vm_ext.cc:470]   at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:93 
[art] art/runtime/java_vm_ext.cc:470]   at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:56 
[art] art/runtime/java_vm_ext.cc:470]   at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:181 
[art] art/runtime/java_vm_ext.cc:470]   at Cadenza.Collections.OrderedDictionary`2[TKey,TValue].get_Item (System.Int32 index) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\OrderedDictionary.cs:101 
[art] art/runtime/java_vm_ext.cc:470]   at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].GetGroup (System.Int32 index) [0x0000a] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:555 
[art] art/runtime/java_vm_ext.cc:470]   at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].Xamarin.Forms.ITemplatedItemsList<TItem>.GetGroup (System.Int32 index) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:560 
[art] art/runtime/java_vm_ext.cc:470]   at Xamarin.Forms.Platform.Android.ListViewAdapter.get_Count () [0x00024] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:72 
[art] art/runtime/java_vm_ext.cc:470]   at Android.Widget.BaseAdapter.n_GetCount (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.BaseAdapter.cs:464 
[art] art/runtime/java_vm_ext.cc:470]   at (wrapper dynamic-method) System.Object:5dff09ab-3e25-4cbe-9695-2bb43bf985e8 (intptr,intptr)
[art] art/runtime/java_vm_ext.cc:470]   at int md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_getCount() (ListViewAdapter.java:-2)
[art] art/runtime/java_vm_ext.cc:470]   at int md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.getCount() (ListViewAdapter.java:44)
[art] art/runtime/java_vm_ext.cc:470]   at int android.widget.HeaderViewListAdapter.getCount() (HeaderViewListAdapter.java:132)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.widget.AdapterView.isScrollableForAccessibility() (AdapterView.java:1009)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.AdapterView.onInitializeAccessibilityNodeInfoInternal(android.view.accessibility.AccessibilityNodeInfo) (AdapterView.java:984)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.AbsListView.onInitializeAccessibilityNodeInfoInternal(android.view.accessibility.AccessibilityNodeInfo) (AbsListView.java:1507)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.ListView.onInitializeAccessibilityNodeInfoInternal(android.view.accessibility.AccessibilityNodeInfo) (ListView.java:3999)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) (View.java:6609)
[art] art/runtime/java_vm_ext.cc:470]   at android.view.accessibility.AccessibilityNodeInfo android.view.View.createAccessibilityNodeInfoInternal() (View.java:6568)
[art] art/runtime/java_vm_ext.cc:470]   at android.view.accessibility.AccessibilityNodeInfo android.view.View.createAccessibilityNodeInfo() (View.java:6553)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.accessibility.AccessibilityRecord.setSource(android.view.View, int) (AccessibilityRecord.java:145)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.accessibility.AccessibilityRecord.setSource(android.view.View) (AccessibilityRecord.java:119)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.onInitializeAccessibilityEventInternal(android.view.accessibility.AccessibilityEvent) (View.java:6505)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.AdapterView.onInitializeAccessibilityEventInternal(android.view.accessibility.AccessibilityEvent) (AdapterView.java:994)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent) (View.java:6493)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.widget.AdapterView.onRequestSendAccessibilityEventInternal(android.view.View, android.view.accessibility.AccessibilityEvent) (AdapterView.java:966)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.view.ViewGroup.onRequestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent) (ViewGroup.java:915)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.view.ViewGroup.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent) (ViewGroup.java:888)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.view.ViewGroup.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent) (ViewGroup.java:892)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.view.ViewGroup.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent) (ViewGroup.java:892)
[art] art/runtime/java_vm_ext.cc:470]   at boolean android.view.ViewGroup.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent) (ViewGroup.java:892)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.sendAccessibilityEventUncheckedInternal(android.view.accessibility.AccessibilityEvent) (View.java:6364)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.sendAccessibilityEventUnchecked(android.view.accessibility.AccessibilityEvent) (View.java:6343)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View$SendViewStateChangedAccessibilityEvent.run() (View.java:23675)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View$SendViewStateChangedAccessibilityEvent.runOrPost(int) (View.java:23708)
[art] art/runtime/java_vm_ext.cc:470]   at void android.view.View.notifyViewAccessibilityStateChangedIfNeeded(int) (View.java:9475)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.TextView.setText(java.lang.CharSequence, android.widget.TextView$BufferType, boolean, int) (TextView.java:4486)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.TextView.setText(java.lang.CharSequence, android.widget.TextView$BufferType) (TextView.java:4337)
[art] art/runtime/java_vm_ext.cc:470]   at void android.widget.TextView.setText(java.lang.CharSequence) (TextView.java:4312)
[art] art/runtime/java_vm_ext.cc:470]   at void mono.java.lang.RunnableImplementor.n_run() (RunnableImplementor.java:-2)
[art] art/runtime/java_vm_ext.cc:470]   at void mono.java.lang.RunnableImplementor.run() (RunnableImplementor.java:30)
[art] art/runtime/java_vm_ext.cc:470]   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:751)
[art] art/runtime/java_vm_ext.cc:470]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
[art] art/runtime/java_vm_ext.cc:470]   at void android.os.Looper.loop() (Looper.java:154)
[art] art/runtime/java_vm_ext.cc:470]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
[art] art/runtime/java_vm_ext.cc:470]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
[art] art/runtime/java_vm_ext.cc:470]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
[art] art/runtime/java_vm_ext.cc:470]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
Comment 6 E.Z. Hart [MSFT] 2017-02-08 20:43:46 UTC
(In reply to williamd from comment #2)
> I've reproduced the issue on my Nexus 6P running Android 7.1.1 to be exact.
> We've also had reports of the crash occurring on a Pixel device on 7.1.1

William,

When you run the repro project on a Nexus 6P, are you seeing the exception every time? Or is it intermittent?
Comment 7 Anonymous 2017-02-08 20:50:10 UTC
When running on my Nexus 6P I am encountering the exception everytime I open the app and tap the ">" button.
Comment 8 E.Z. Hart [MSFT] 2017-02-08 20:58:32 UTC
If you update the repro app to Xamarin.Forms 2.3.4.190-pre2, does the problem persist? 

(I'd check myself, but I haven't been able to reproduce the problem yet on any of the hardware I've got here).
Comment 9 Anonymous 2017-02-08 21:16:53 UTC
The problem persists even with all projects updated to reference Xamarin.Forms 2.3.4.190-pre2.

I'm going to try updating to the beta channel and targeting api 25 (7.1). Will report back with results.
Comment 10 Anonymous 2017-02-09 14:18:12 UTC
No luck with the beta channel either.
Comment 11 E.Z. Hart [MSFT] 2017-02-13 16:28:57 UTC
William,

We've tried the reproduction project linked above on a Nexus 6P running 7.1.1, and we were not able to reproduce the exception. We've tried building the project in both Visual Studio and Xamarin Studio; the reproduction project linked above worked fine both times (no crash when tapping the button). 

There must be some other detail or step we're missing. Does the problem occur in both Debug and Release on your device?
Comment 12 Anonymous 2017-02-13 17:02:32 UTC
The problem occurs in both Debug and Release builds for me.
Is there any other information that I could include that would help narrow this down?
Comment 13 E.Z. Hart [MSFT] 2017-02-13 18:37:21 UTC
When you say "reports of the crash occurring on a Pixel device" - is there any chance that's via a reporting tool like Insights? If so, the logs of that might be helpful.

Other than the Nexus 6P device, have you reproduced it on any other devices? Has it occurred on more than one Nexus 6P? 

Have you tried building and deploying from another machine? 

I'm assuming that you're using Xamarin Studio - have you tried it from Visual Studio?

(I'm trying to rule out any possible build tool or test device problems, installer bugs which left XS in a bad state, etc.)
Comment 14 Anonymous 2017-02-14 15:30:17 UTC
If I would have read my own stacktrace more thoroughly I would have figured this out way sooner. Accessibility options are the problem here. If you have any accessibility services turned on, you should be able to reproduce this issue.
Comment 15 Anonymous 2017-02-14 16:15:00 UTC
I should also note that this is not specific to Android 7.1.1. I've reproduced this issue with the Switch Access accessibility service turned on with a Nexus 7 on Android 5.0 and with the Nexus 6P on Android 7.1.1.

If you need any more information just let me know.
Comment 16 E.Z. Hart [MSFT] 2017-02-14 18:19:32 UTC
Ah, that did it. I turned on Switch Access and it immediately crashes when I tap the button.

Thanks for clearing that up!
Comment 17 Gerard C 2017-02-21 19:23:01 UTC
Not sure if it is related but I ran into this issue on my Android emulator (version 6.0).  My grouped ListView was bound to an ObservableRangeCollection which was being updated by the ViewModel around the same time that the list was rendering.  Issue went away when I wrapped the collection update in Device.BeginInvokeOnMainThread.

Device.BeginInvokeOnMainThread(() =>
            {
                MyObservableRangeCollection.ReplaceRange(myListOfItems);
                IsRefreshing = false;
            });
Comment 18 Andrei.N 2017-05-19 20:12:32 UTC
I just got the same exception, I'm using Android 7.1
Any workaround? I checked the threads and it's the main thread where this happens.
In my case it happens on navigating away from the page using Prism NavigationService:

await SomeTask();
await _navService.GoBackAsync();

Also, I wonder if it's related this which appeared RESOLVED FIXED: https://bugzilla.xamarin.com/show_bug.cgi?id=43636


[0:] EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:93 
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:56 
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:181 
  at Xamarin.Forms.Application+NavigationImpl+<OnPopModal>d__2.MoveNext () [0x0000d] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Application.cs:317 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 
  at Prism.Navigation.PageNavigationService+<GoBackAsync>d__11.MoveNext () [0x00188] in <7a32c28f35024e719a93e31b4d1e3d2a>:0 . Priority: High. Timestamp:2017-05-19 22:49:11Z
05-19 22:49:11.174 I/Choreographer( 2336): Skipped 3161 frames!  The application may be doing too much work on its main thread.
05-19 22:49:11.175 D/Mono    ( 2336): [0x972e5600] worker starting
05-19 22:49:11.175 D/Mono    ( 2336): [0x94bb4a80] worker starting
Comment 19 Andrei.N 2017-05-19 20:12:45 UTC
Are there any workarounds?
Comment 20 Andrei.N 2017-05-19 20:13:11 UTC
I'm on Windows, this bug says Macintosh Mac OS
Comment 21 Andrei.N 2017-05-19 20:13:34 UTC
I meant Im on Xamarin Android 7.1
Comment 22 Rui Marinho 2017-05-24 18:09:51 UTC
This is already fixed in the latest pre release 2.3.5-pre3
Comment 23 Samantha Houts [MSFT] 2017-05-25 19:26:21 UTC
*** Bug 35546 has been marked as a duplicate of this bug. ***
Comment 24 Rody 2017-10-23 20:17:04 UTC
I had the exact same issue as the OP on a Galaxy S6 Edge and it turned out to be a user had CCleaner enabled.  For some reason CCleaner is listed under the Accessibility Settings.  It was a pain to figure out because Xamarin Insights only reported part of the Stack Trace. I had to debug the phone in Visual Studios to see the error reported by JNI, which mention Accessibility.