Skip to content

Conversation

@Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented May 8, 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!

Root Cause of the issue

  • An exception is caused when attempting to scroll to an index that is out of bounds (i.e., not present in the section), which leads to the issue. (Issue 7678_1 and Issue31339)

  • After fixing the crash issue, it was observed that items were positioned at the last instead of the first in issue 31339. The root cause is that InitialPositionSet is set to true during the initial load when the ItemsSource is not yet assigned. Later, when the ItemsSource is dynamically updated, InitialPositionSet remains true. As a result, the SetPosition method in CarouselViewController2 (triggered by section.VisibleItemsInvalidationHandler) applies the wrong position during concurrent updates, causing an incorrect item to be displayed in the view.

Description of Change

  • Added a check to validate the index before attempting to scroll. This prevents exceptions caused by trying to scroll to an out-of-bounds item in the carousel view.

  • Set InitialPositionSet to true only after the ItemsSource has been updated. This ensures the correct position can be calculated and applied.

Issues Fixed

Fixes #29310
Fixes #31339
Fixes #31431
Fixes #16020

Test Case

  • Reenabled the test case : Issue7678

  • Reenabled the test case : Issue7678_1

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
Cv2CrashOccured.mov
CV2NoCrashFixed.mov
CarouselView2Crash.mov
Nocrashoncv2.mov

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels May 8, 2025
@jsuarezruiz jsuarezruiz added platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView labels May 8, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review May 9, 2025 11:09
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner May 9, 2025 11:09
@Ahamed-Ali Ahamed-Ali requested review from mattleibow and rmarinho May 9, 2025 11:09
@rmarinho
Copy link
Member

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 SR9 milestone Jun 9, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Jun 9, 2025
@Ahamed-Ali Ahamed-Ali force-pushed the fix-29310 branch 2 times, most recently from 22e3539 to 953971b Compare June 30, 2025 11:00
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR9, .NET 9 SR10 Jul 3, 2025
@PureWeen PureWeen removed this from the .NET 9 SR10 milestone Aug 4, 2025
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Sep 18, 2025
@PureWeen
Copy link
Member

/azp run

@PureWeen PureWeen dismissed stale reviews from jsuarezruiz and themself September 18, 2025 20:44

Changes Made

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).


return true;
}
catch (Exception ex) when (ex is ObjectDisposedException or InvalidOperationException)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know how to reproduce an ObjectDisposedException? Catching ObjectDisposedException suggests lifecycle management issues that should be fixed at the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m not exactly sure how to reproduce this ObjectDisposedException edge case @jsuarezruiz

@PureWeen PureWeen modified the milestones: .NET 9 SR12, .NET 10 SR1 Oct 8, 2025
@PureWeen PureWeen moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Oct 10, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Oct 23, 2025
@PureWeen PureWeen changed the base branch from main to inflight/candidate October 31, 2025 20:32
@PureWeen PureWeen merged commit 9d07c19 into dotnet:inflight/candidate Oct 31, 2025
134 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Oct 31, 2025
github-actions bot pushed a commit that referenced this pull request Nov 4, 2025
* Fixed the CarouselView2 rendering issues

* Modified the test case

* Fixed the 7678_1 issue

* Re-fixed the issue7678_1 based on conflicts file

* Removed the GetDesiredSize code

* Removed spaces

* Fixed the 31339 crash issue and position update related issue

* Fixed the crash when setting position is greater than itemcount

* Included the more test scenarios and included the recipe test

* Added the Log for debugging purposes

* Fixed the CarouselView2 rendering issues

* Modified the test case

* Fixed the 7678_1 issue

* Re-fixed the issue7678_1 based on conflicts file

* Removed the GetDesiredSize code

* Removed spaces

* Fixed the 31339 crash issue and position update related issue

* Fixed the crash when setting position is greater than itemcount

* Included the more test scenarios and included the recipe test

* Added the Log for debugging purposes

* Committed the review changes
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 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 p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios

Projects

Status: Done

4 participants