Share via

CarouselView problems when first showing

Rainer 166 Reputation points
2021-05-17T06:53:41.717+00:00

I have a CarouselView that shows product details and allows swiping right or left to view more products. In iOS this works fine, but in Android, when the page is loaded for the first time the CarouselView stutters badly and even scrolls to the wrong item. After a few seconds this corrects itself and the scrolling is smooth. I believe this may be due to garbage collection because I see these types of messages in the application output:

[Mono] GC_BRIDGE waiting for bridge processing to finish
[eercats.beerbo] Explicit concurrent copying GC freed 8173(600KB) AllocSpace objects, 1(20KB) LOS objects, 49% free, 4003KB/8006KB, paused 1.231ms total 11.277ms
[Mono] GC_TAR_BRIDGE bridges 804 objects 907 opaque 8 colors 804 colors-bridged 804 colors-visible 804 xref 7 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.20ms tarjan 0.39ms scc-setup 0.09ms gather-xref 0.02ms xref-setup 0.04ms cleanup 1.25ms
[Mono] GC_BRIDGE: Complete, was running for 19.67ms
[Mono] GC_MAJOR: (LOS overflow) time 19.99ms, stw 21.24ms los size: 2048K in use: 282K
[Mono] GC_MAJOR_SWEEP: major size: 5296K in use: 4061K
[Mono] GC_BRIDGE waiting for bridge processing to finish
[eercats.beerbo] Explicit concurrent copying GC freed 10795(648KB) AllocSpace objects, 2(40KB) LOS objects, 49% free, 4224KB/8448KB, paused 1.310ms total 11.063ms
[Mono] GC_TAR_BRIDGE bridges 838 objects 1016 opaque 5 colors 838 colors-bridged 838 colors-visible 838 xref 4 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.12ms tarjan 0.29ms scc-setup 0.07ms gather-xref 0.02ms xref-setup 0.06ms cleanup 0.29ms
[Mono] GC_BRIDGE: Complete, was running for 15.17ms
[Mono] GC_MAJOR: (LOS overflow) time 15.74ms, stw 18.65ms los size: 2048K in use: 290K
[Mono] GC_MAJOR_SWEEP: major size: 7264K in use: 5788K
[OpenGLRenderer] Davey! duration=710ms; Flags=0, IntendedVsync=814148297302483, Vsync=814148730635799, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=814148735188462, AnimationStart=814148735282462, PerformTraversalsStart=814148994219462, DrawStart=814148994663462, SyncQueued=814148999242462, SyncStart=814148999992462, IssueDrawCommandsStart=814149000333462, SwapBuffers=814149006352462, FrameCompleted=814149008864462, DequeueBufferDuration=1053000, QueueBufferDuration=979000, GpuCompleted=0, 
[eercats.beerbo] Explicit concurrent copying GC freed 4687(231KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4389KB/8778KB, paused 440us total 18.075ms

After a few seconds, when the problem goes away, these messages also stop appearing.

I've tried simplifying the contents in the CarouselView and I found that if I remove the product image then this problem goes away entirely. This makes me guess the issue may be related to allocating the memory needed to show the images.

To be clear, the issue I'm seeing is not only the scrolling performance. When the view first appears and I try to swipe, the scrolling is basically broken. It usually scrolls only 2/3rd to the next frame and stops. If I try swiping again it moves to the wrong frame. If I keep swiping it eventually starts working correctly.

Also, occasionally, I've seen the CarouselView break even more. I've sometimes seen it spontaneously switch from the intended horizontally scrolling view to vertically scrolling.

Has anyone else seen issues like this and have any suggestions how to minimize them?

Developer technologies | .NET | Xamarin

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.