Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] crash CarouselView in uwp on xf 5.x.x.x #13133

Open
mostafa2007iau opened this issue Dec 14, 2020 · 7 comments
Open

[Bug] crash CarouselView in uwp on xf 5.x.x.x #13133

mostafa2007iau opened this issue Dec 14, 2020 · 7 comments
Labels
a/carouselview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/UWP s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified t/bug 🐛
Projects

Comments

@mostafa2007iau
Copy link

mostafa2007iau commented Dec 14, 2020

Description

Steps to Reproduce

  1. crash CarouselView in uwp on xf 5.x.x.x
  2. The carouselView tag on any page when it loads data causes the program to close without any specific

Expected Behavior

Actual Behavior

Basic Information

Version with issue: Xamarin Forms 5.0.0.1791 pre5
Last known good version: Xamarin Forms 4.8.0.1687
Platform Target Frameworks:
iOS: -
Android: -
UWP: windows 10 version 2004
message.

Affected Devices: windows 10 enterprise insider preview version 2004 os build 20215.1000

Environment

Show/Hide Visual Studio info

Build Logs

Screenshots

Reproduction Link

Workaround

@mostafa2007iau mostafa2007iau added s/unverified New report that has yet to be verified t/bug 🐛 labels Dec 14, 2020
@samhouts samhouts added this to New in Triage Dec 14, 2020
@jsuarezruiz jsuarezruiz added a/carouselview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/UWP labels Dec 14, 2020
@jsuarezruiz
Copy link
Contributor

@mostafa2007iau Could you attach an example where reproduce the issue? It would be interesting to know what Layout you use, etc.

@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Dec 14, 2020
@jsuarezruiz jsuarezruiz added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Dec 14, 2020
@mostafa2007iau
Copy link
Author

@mostafa2007iau Could you attach an example where reproduce the issue? It would be interesting to know what Layout you use, etc.

more info add to comment

@CocoCR300
Copy link

CocoCR300 commented Jan 18, 2021

I am experiencing something similar with X.F 5.0.0.1874 on the same platform, when the collection binded to the CarouselView.ItemsSource property is empty, then the CarouselView.CurrentItem property is set to null and the app crashes without an exception being thrown, this also happens setting CurrentItem to null manually.

Small example here: https://github.com/CocoCR300/CarouselViewCrashExample
I tested on UWP (Windows 10, version 1903 (10.0; Build 18362)) and Android (10 - API 29), it's happening on UWP only.

@Redth Redth removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 21, 2021
@CocoCR300
Copy link

CocoCR300 commented Jan 22, 2021

I updated Xamarin.Forms to 5.0.0.1905 and the UWP project target framework version to 10.0.19041.0 on my example and after some tests:

  • With Loop set to False, an empty collection binded to ItemsSource doesn't cause errors.
  • The CarouselView doesn't refresh when updating the collection binded to it (adding/deleting an item or calling the Clear method), it refreshes only by assigning a new collection and, when an item is deleted it scrolls automatically (as expected) but the item deleted remains displayed. I tried changing the BindingMode but nothing happened.
  • The CurrentItem = null issue persists.
  • The scrollbar goes crazy when it's positioned in the end and the collection is updated by adding and deleting items.

@PureWeen PureWeen moved this from Needs Info to New in Triage Jan 22, 2021
@CocoCR300
Copy link

CocoCR300 commented Jan 22, 2021

Now, but only sometimes and when Loop is False, the example is throwing this exception when a collection (empty or not) is assigned to ItemsSource on Android. The stack trace is similar as the reported on #13441.

Java.Lang.IllegalArgumentException: 'Invalid target position'

{Java.Lang.IllegalArgumentException: Invalid target position at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <8b3b636835d84984ba4604c1f57b1983>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <8b3b636835d84984ba4604c1f57b1983>:0 at AndroidX.RecyclerView.Widget.RecyclerView+LayoutManager.StartSmoothScroll (AndroidX.RecyclerView.Widget.RecyclerView+SmoothScroller smoothScroller) [0x00027] in D:\a\1\s\generated\androidx.recyclerview.recyclerview\obj\Release\monoandroid90\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:7510 at Xamarin.Forms.Platform.Android.ScrollHelper.AnimateScrollToPosition (System.Int32 index, Xamarin.Forms.ScrollToPosition scrollToPosition) [0x00029] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ScrollHelper.cs:62 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.ScrollTo (Xamarin.Forms.ScrollToRequestEventArgs args) [0x00037] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:219 at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].ScrollToRequested (System.Object sender, Xamarin.Forms.ScrollToRequestEventArgs args) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:603 at Xamarin.Forms.ItemsView.OnScrollToRequested (Xamarin.Forms.ScrollToRequestEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Items\ItemsView.cs:219 at Xamarin.Forms.ItemsView.ScrollTo (System.Int32 index, System.Int32 groupIndex, Xamarin.Forms.ScrollToPosition position, System.Boolean animate) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Items\ItemsView.cs:172 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateFromCurrentItem () [0x0003c] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:513 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00079] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:171 at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:383 at Xamarin.Forms.Element.SetValueFromRenderer (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:248 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateAdapter () [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:131 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateItemsSource () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:151 at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:212 at Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:158 at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56 at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762 at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773 at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666 at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at CarouselViewCrashExample.MainViewModel.OnPropertyChanged (System.String propertyName) [0x00001] in D:\Projects\CarouselViewCrashExample\CarouselViewCrashExample\CarouselViewCrashExample\MainViewModel.cs:89 at CarouselViewCrashExample.MainViewModel.SetValue[T] (T& backingField, T value, System.String propertyName) [0x0001f] in D:\Projects\CarouselViewCrashExample\CarouselViewCrashExample\CarouselViewCrashExample\MainViewModel.cs:98 at CarouselViewCrashExample.MainViewModel.set_StringCollection (System.Collections.ObjectModel.ObservableCollection`1[T] value) [0x00000] in D:\Projects\CarouselViewCrashExample\CarouselViewCrashExample\CarouselViewCrashExample\MainViewModel.cs:43 at CarouselViewCrashExample.MainViewModel.FillCollection () [0x00000] in D:\Projects\CarouselViewCrashExample\CarouselViewCrashExample\CarouselViewCrashExample\MainViewModel.cs:72 at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:74 at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112 at Xamarin.Forms.ButtonElement.ElementClicked (Xamarin.Forms.VisualElement visualElement, Xamarin.Forms.Internals.IButtonElement ButtonElementManager) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\ButtonElement.cs:60 at Xamarin.Forms.Button.SendClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:173 at Xamarin.Forms.Platform.Android.ButtonElementManager.OnClick (Xamarin.Forms.VisualElement element, Xamarin.Forms.IButtonController buttonController, Android.Views.View v) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\ButtonElementManager.cs:25 at Xamarin.Forms.Platform.Android.FastRenderers.ButtonRenderer.Android.Views.View.IOnClickListener.OnClick (Android.Views.View v) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ButtonRenderer.cs:72 at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <84ca7e914f6148f0b961431a9ac4287b>:0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.60(intptr,intptr,intptr) --- End of managed Java.Lang.IllegalArgumentException stack trace ---java.lang.IllegalArgumentException: Invalid target position at androidx.recyclerview.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:11807) at androidx.recyclerview.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:8470) at crc64ee486da937c010f4.ButtonRenderer.n_onClick(Native Method) at crc64ee486da937c010f4.ButtonRenderer.onClick(ButtonRenderer.java:104) at android.view.View.performClick(View.java:7862) at android.widget.TextView.performClick(TextView.java:15004) at android.view.View.performClickInternal(View.java:7831) at android.view.View.access$3600(View.java:879) at android.view.View$PerformClick.run(View.java:29359) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)}

@rmarinho
Copy link
Member

@mostafa2007iau do you mind add more information of the code you use or a small sample so we can reproduce the issue.

@CocoCR300 do you mind open a new issue with your feedback and sample code please? thanks

@rmarinho rmarinho added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 26, 2021
@rmarinho rmarinho moved this from New to Needs Info in Triage Jan 26, 2021
@janduldhardt
Copy link

Having the same problem in UWP.
If the binded itemsSource list is empty the CarouselView.ItemsSource will be null and on updating the app crashes even we directly set the CarouselView.ItemsSource = new List<>();

Does anyone have a current workaround?

@Redth Redth removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Apr 27, 2021
@Redth Redth moved this from Needs Info to New in Triage Apr 28, 2021
@rachelkang rachelkang moved this from New to Needs Info in Triage Apr 29, 2021
@rachelkang rachelkang added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/carouselview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/UWP s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified t/bug 🐛
Projects
Triage
  
Needs Info
Development

No branches or pull requests

7 participants