Skip to content

Fix crash when dynamically updating Loop in CarouselView #29453

Closed
bhavanesh2001 wants to merge 7 commits into
dotnet:mainfrom
bhavanesh2001:fix_29411
Closed

Fix crash when dynamically updating Loop in CarouselView #29453
bhavanesh2001 wants to merge 7 commits into
dotnet:mainfrom
bhavanesh2001:fix_29411

Conversation

@bhavanesh2001
Copy link
Copy Markdown
Contributor

@bhavanesh2001 bhavanesh2001 commented May 12, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

In CarouselView, enabling or disabling loop mode dynamically at runtime has no effect.
Currently, attempting to set Loop to false on Android and iOS causes a crash due to missing platform updates.

Root Cause

The MapLoop mapper was not included in the handler’s property mapper. As a result, runtime changes to the Loop property were not communicated to the platform-specific implementations.

Description of Change

Added MapLoop to the property mapper for CarouselViewHandler, enabling support for dynamic updates to loop behavior at runtime and preventing platform crashes.

Validated the behavior on the following platforms

  • Android
  • iOS
  • Windows
  • Mac

Issues Fixed

Fixes #29411

@bhavanesh2001 bhavanesh2001 requested a review from a team as a code owner May 12, 2025 19:50
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label May 12, 2025
@rmarinho
Copy link
Copy Markdown
Member

/azp run

rmarinho
rmarinho previously approved these changes May 13, 2025
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@@ -0,0 +1,26 @@
#if !MACCATALYST //Appium Swipe is not working on MACCATALYST
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will take a look to it. Can you try to use the DragCoordinates method for Mac (with a compilation directive in the test)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Will try that out. In my local machine , App.SwipeRightToLeft() is reducing the screen brightness.

Copy link
Copy Markdown
Contributor Author

@bhavanesh2001 bhavanesh2001 May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz I tried using App.DragCoordinates, but it doesn’t work as expected on MacCatalyst. It performs a one-finger drag, while CarouselView swipe requires a two-finger gesture on the touchpad to trigger scroll.

@rmarinho
Copy link
Copy Markdown
Member

Do we need to add this to also CV2 ?

Comment thread src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs
@PureWeen
Copy link
Copy Markdown
Member

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

bhavanesh2001 commented May 14, 2025

Test's seems to be passing. Although, I forgot to add Mapper to CV2 :(

@devanathan-vaithiyanathan
Copy link
Copy Markdown
Contributor

I have created a PR for this issue to include additional logic for maintaining the current item when the loop value changes, and to handle scrollbar visibility based on the loop value.

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label May 16, 2025
@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor

@bhavanesh2001 , When the loop setting is changed from false to true at runtime, the CarouselView does not update properly. We cannot scroll past the first item, and it behaves as if the loop is still set to false. I have attached a video for reference.

Issue report for windows - #29412

Loop.False.to.True.mp4

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

@bhavanesh2001 , When the loop setting is changed from false to true at runtime, the CarouselView does not update properly. We cannot scroll past the first item, and it behaves as if the loop is still set to false. I have attached a video for reference.

Issue report for windows - #29412

Hmm, I guess this is an issue that has existed before. Since we aren't changing anything related to Windows here

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor

@bhavanesh2001 , When the loop setting is changed from false to true at runtime, the CarouselView does not update properly. We cannot scroll past the first item, and it behaves as if the loop is still set to false. I have attached a video for reference.
Issue report for windows - #29412

Hmm, I guess this is an issue that has existed before. Since we aren't changing anything related to Windows here

@bhavanesh2001 , Previously, we could not change the loop at runtime; we could only set it during initialization. This issue does not occur when setting it at initialization. This behavior was introduced in this PR.

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

@bhavanesh2001 , Previously, we could not change the loop at runtime; we could only set it during initialization. This issue does not occur when setting it at initialization. This behavior was introduced in this PR.

Yeah, I meant whatever is causing the issue was already present; we just enabled it by mapping the Loop property. Also, I'm not sure if this PR is in play. #29527 seems to include additional changes compared to this one. Does the same issue occur with that PR as well? 🤔

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

Closing in favour of #29527

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] CarouselView.Loop = false causes crash on Android when changed at runtime

6 participants