Bug 42629 - [Android] MasterDetailPage ArrayIndexOutOfBoundsException crash when switching Detail pages back and forth between two TabbedPages
Summary: [Android] MasterDetailPage ArrayIndexOutOfBoundsException crash when switchin...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-18 14:21 UTC by Jani Lirkki
Modified: 2016-11-07 22:32 UTC (History)
6 users (show)

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


Attachments
Sample Android app for reproducing the crash. (5.29 MB, application/x-zip-compressed)
2016-07-18 14:21 UTC, Jani Lirkki
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 for Bug 42629 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Jani Lirkki 2016-07-18 14:21:28 UTC
Created attachment 16705 [details]
Sample Android app for reproducing the crash.

The attached Android sample app has a MasterDetailPage and the MasterPage contains two list items for changing the detail page between two pages. Both detail pages are of type TabbedPage.

The app crashes on my Android device when I perform the following steps:
1) Start the app. The app opens and the Detail page is set to instance of "First Tabbed Page".
2) Tap the Xamarin icon in topleft corner to open the masterpage.
3) Choose "Another Tabbed Page" -> The Detail page is replaced with instance of "Another Tabbed Page".
4) Tap again the Xamarin icon in topleft corner to open the masterpage.
5) Choose "First Tabbed Page" -> CRASH!

Here is the crash details from Output window:
Unhandled Exception:
Java.Lang.ArrayIndexOutOfBoundsException: length=12; index=-1
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11283 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractObjectMethod (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00017] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:339 
  at Android.App.ActionBarInvoker.GetTabAt (Int32 index) [0x00017] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.ActionBar.cs:3186 
  at Xamarin.Forms.Platform.Android.Platform.PagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00042] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Platform.cs:750 
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:137 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Element.cs:369 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x000f4] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:581 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:378 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, Boolean fromTarget) [0x0020c] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindingExpression.cs:177 
  at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindingExpression.cs:76 
  at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty) [0x00042] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Binding.cs:113 
  at Xamarin.Forms.BindableObject.ApplyBindings (System.Object oldContext, Boolean skipBindingContext) [0x00034] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:408 
  at Xamarin.Forms.BindableObject.BindingContextPropertyBindingPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000e] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:428 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x00108] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:584 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:378 

The sample app uses Xamarin Forms version 2.3.1.111-pre2.
Comment 1 Jani Lirkki 2016-08-08 09:48:07 UTC
Still reproducible in Xamarin Forms version 2.3.2.118-pre1.
Comment 2 adrianknight89 2016-11-05 07:38:28 UTC
Can you try minimizing the repro? I think there is a lot going on there. If you could pin it down to a smaller subset of code, it's going to help devs debug faster.

That said, I'd first look into what you're doing inside OnAppearing (i.e. setting BindingContext and calling async methods). This trio can introduce issues.
Comment 3 adrianknight89 2016-11-05 07:40:09 UTC
A very delicious bug btw.