Bug 40630 - CarouselView with ItemsSource null or empty throws Exception (v2.2.0.18-pre3)
Summary: CarouselView with ItemsSource null or empty throws Exception (v2.2.0.18-pre3)
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris King
URL:
Depends on:
Blocks:
 
Reported: 2016-04-22 00:29 UTC by David CASBONNE
Modified: 2017-05-05 17:37 UTC (History)
3 users (show)

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


Attachments
iOS exception (367.97 KB, image/png)
2016-04-22 00:29 UTC, David CASBONNE
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 NOT_ON_ROADMAP

Description David CASBONNE 2016-04-22 00:29:14 UTC
Created attachment 15812 [details]
iOS exception

I have bind ItemsSource of the CarouselView to a List<Vehicle>.
Sometimes, this list could be empty (users have no registered cars for example).

(I think this would be easy to reproduce so I don't attach any example).

When loading the page, I've an exception :
- On iOS 9.3.1 (simulator) : i've a Foundation.MonoTouchException (see attachment for details, I'm not able to copy the exception...)
- On Android Nexus 5 in 5.0 (Genymotion) : here is the complete exception :

Java.Lang.IndexOutOfBoundsException: Invalid item position -1(-1). Item count:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00064] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:195
  at Android.Support.V7.Widget.RecyclerView+Recycler.GetViewForPosition (Int32 position) [0x0004a] in <filename unknown>:0
  at Xamarin.Forms.Platform.Android.PhysicalLayoutManager.OnLayoutChildren (Android.Support.V7.Widget.Recycler recycler, Android.Support.V7.Widget.State state) [0x001af] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\CarouselViewRenderer.cs:1093
  at Android.Support.V7.Widget.RecyclerView+LayoutManager.n_OnLayoutChildren_Landroid_support_v7_widget_RecyclerView_Recycler_Landroid_support_v7_widget_RecyclerView_State_ (IntPtr jnienv, IntPtr native__this, IntPtr native_recycler, IntPtr native_state) [0x00019] in <filename unknown>:0
  at at (wrapper dynamic-method) System.Object:6aedc121-9e25-4153-8cfe-5c87152a6af3 (intptr,intptr,intptr,intptr)
  at --- End of managed exception stack trace ---
  at java.lang.IndexOutOfBoundsException: Invalid item position -1(-1). Item count:0
  at at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4622)
  at at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PhysicalLayoutManager.n_onLayoutChildren(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PhysicalLayoutManager.onLayoutChildren(PhysicalLayoutManager.java:148)
  at at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
  at at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
  at at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.CarouselViewRenderer.n_onLayout(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.CarouselViewRenderer.onLayout(CarouselViewRenderer.java:44)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:48)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
  at at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onLayout(Native Method)
  at at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:62)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.n_onLayout(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.onLayout(MasterDetailContainer.java:61)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1187)
  at at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.n_onLayout(Native Method)
  at at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.onLayout(MasterDetailPageRenderer.java:67)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:62)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
  at at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
  at at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
  at at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
  at at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
  at at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
  at at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
  at at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
  at at android.view.View.layout(View.java:15596)
  at at android.view.ViewGroup.layout(ViewGroup.java:4966)
  at at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072)
  at at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829)
  at at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
  at at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
  at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
  at at android.view.Choreographer.doCallbacks(Choreographer.java:580)
  at at android.view.Choreographer.doFrame(Choreographer.java:550)
  at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
  at at android.os.Handler.handleCallback(Handler.java:739)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:135)
  at at android.app.ActivityThread.main(ActivityThread.java:5221)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:372)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Comment 1 David CASBONNE 2016-04-22 01:41:03 UTC
I just remark I've not told the expected behavior : in the case of an empty or null ItemsSource we could have 2 behaviors.

1. The simplest : display anything ! Just a blank page :)

2. More complicated : have the ability to display a fallback page.

Thanks !
Comment 2 Chris King 2017-05-05 17:37:27 UTC
CarouselView to be deprecated and replaced with https://github.com/xamarin/Xamarin.Forms/pull/853