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

Android crash from FrameRenderer caused by VisualElementPackager #5614

Open
sis2004 opened this issue Mar 19, 2019 · 2 comments
Open

Android crash from FrameRenderer caused by VisualElementPackager #5614

sis2004 opened this issue Mar 19, 2019 · 2 comments
Labels
e/2 🕑 2 good first issue help wanted We welcome community contributions to any issue, but these might be a good place to start! i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@sis2004
Copy link

sis2004 commented Mar 19, 2019

Description

When I use CarouselView inside a ListView (where each cell has its own carousel view), it crashes in an Android emulator with the following exception:

System.ArgumentException: Element must be of type Frame
  at Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00010] in C:\Projects\Repos\Xamarin.Forms\Xamarin.Forms.Platform.Android\FastRenderers\FrameRenderer.cs:83 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00130] in C:\Projects\Repos\Xamarin.Forms\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:127 
... see attached file for the full stack trace ...

Full stack trace

When I debugged it using a local Xamarin.Forms nuget package built from the latest master, I noticed that the children of the CarouselView (newChildren) were not in the same order as the corresponding renderers (_childViews) in the VisualElementPackager.SetElement method, which caused the FrameRenderer to be applied to the ContentView that resulted in this exception.

The image below illustrates this issue, where the Frame-based arrow controls and the indicator are the last 3 children, while their (frame) renderers are the first 3 elements in the _childViews.

CardViewFrameRenderer

Do you have any ideas on what's causing this, and how it can be fixed?

Note: This issue has been reported in the corresponding CardView repository, and the author agreed that it seems to be a Xamarin.Forms bug.

Steps to Reproduce

  1. Use CarouselView from the CardView package as an item template of a ListView. Include arrow controls and indicator view for the CarouselView.
  2. Display the form with that list view showing multiple carousel views and multiple items for each carousel view.
  3. Scroll up and down for the List view and left and right for each carousel view.

Expected Behavior

The form should scroll through items without crashing.

Actual Behavior

After some swiping the app crashes with the exception above.

Basic Information

  • Version with issue: 3.6 and current master.
  • Last known good version: Unknown
  • IDE: Visual Studio 2017 Professional Edition
  • Platform Target Frameworks:
    • iOS: n/a
    • Android: 8.1 (Oreo)
    • UWP: n/a
  • Android Support Library Version:
  • Nuget Packages: CardView 2.0.5
  • Affected Devices: Android Emulator
@AndreiMisiukevich
Copy link
Contributor

Similar issue AndreiMisiukevich/ContextMenu#4

android.runtime.JavaProxyThrowable: System.InvalidCastException: Specified cast is not valid.
at Xamarin.Forms.Platform.Android.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00007] in <7999cc4bd5664eca8a72469344172ca3>:0
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild

StackLayout is passed instead of scrollView.

@samhouts samhouts added the i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often label May 29, 2019
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Sep 16, 2019
@AbuMandour
Copy link

any update ?

@samhouts samhouts removed the inactive Issue is older than 6 months and needs to be retested label Feb 24, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Sep 18, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/2 🕑 2 good first issue help wanted We welcome community contributions to any issue, but these might be a good place to start! i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

No branches or pull requests

4 participants