-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fixed the Items are not displaying in CarouselView 2 #29397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
22e3539 to
953971b
Compare
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
13d3f99 to
1e51570
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue7678_1.cs
Outdated
Show resolved
Hide resolved
|
/azp run |
Changes Made
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
|
||
| return true; | ||
| } | ||
| catch (Exception ex) when (ex is ObjectDisposedException or InvalidOperationException) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
* 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
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
InitialPositionSetis 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
InitialPositionSetto 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 :
Issue7678Reenabled the test case :
Issue7678_1Tested the behaviour in the following platforms
Screenshot
Cv2CrashOccured.mov
CV2NoCrashFixed.mov
CarouselView2Crash.mov
Nocrashoncv2.mov