Skip to content

[Inflight/Candidate] [iOS] Fix for CollectionView layout issue after iOS device rotation - #38815

Merged
kubaflo merged 1 commit into
inflight/candidatefrom
kubaflo-candidate-backport-38771
Sep 23, 2026
Merged

kubaflo merged 1 commit into
inflight/candidatefrom
kubaflo-candidate-backport-38771

Conversation

@kubaflo

@kubaflo kubaflo commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

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!

Backport

Backport of #38771 from inflight/current to inflight/candidate. The fix, regression test, and all three screenshot baselines are unchanged from the original PR.

Root cause

The issue occurs because of the cell being arranged too early during the preferred layout pass when the collection view constraints change during device rotation. This updates the cached arranged size before LayoutSubviews receives the final native bounds, which can cause the layout to skip the required final arrangement and result in incorrect item positioning or sizing in RTL layouts.

Solution description

The fix involves deferring the arrangement to LayoutSubviews when the layout constraints change, such as during device rotation, so the cell can be arranged using the actual native bounds. At the same time, inline arrangement is retained for dynamic content changes to preserve the behavior introduced by the existing CollectionView2 dynamic content fix.

Regression PR

#37437

Validation

The original PR reports validation on iOS. Platform tests were not rerun for this backport. Repository formatting completed successfully, and the candidate patch ID matches the original commit exactly, including the binary screenshot baselines.

Issues Fixed

Fixes #38622

Output ScreenShot

Before/after recordings from the original PR:

Platform Before After
iOS
38622-BeforeFix.mov
38622-AfterFix.mov

…nt changes and preserve dynamic content updates.

Backport-of: #38771
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo merged commit 8a61fb1 into inflight/candidate Sep 23, 2026
5 of 15 checks passed
@kubaflo
kubaflo deleted the kubaflo-candidate-backport-38771 branch September 23, 2026 16:25
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Sep 23, 2026
kubaflo added a commit that referenced this pull request Sep 27, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 3, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 6, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 13, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 14, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo pushed a commit that referenced this pull request Oct 16, 2026
…ctionView2 (#39396)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root cause

The issue occurs because TemplatedCell2 used the most recent managed
arrange size to determine whether UIKit had changed the cell’s native
bounds. Preferred-size calculations can update this value before UIKit
applies its final bounds, making native size changes difficult to
detect. PR #38815 allowed any pending arrange to trigger a final
arrangement, resulting in redundant arrange passes when the native
bounds had not changed and increasing the count to approximately 354.

### Solution description

The fix involves tracking UIKit’s native bounds size separately from the
last managed arrange size. LayoutSubviewscompares consecutive native
bounds and performs a pending final arrangement only when the native
bounds have changed. This preserves the rotation correction and required
inline arrangements for dynamically rebuilt content while avoiding
redundant final arrangements when the native bounds remain unchanged.
The corrected implementation reduced the arrange-pass count to
approximately 327–328.
 
**Reason for test level changes:**
 
The CollectionView2 arrange count increased because recycled or rebound
cells now require an inline managed arrangement after measurement
invalidation. This work is necessary to ensure dynamically rebuilt child
content receives valid geometry and does not render blank. In addition,
a genuine native bounds change, such as device rotation, requires a
final arrangement using the bounds supplied by UIKit.
 
These required arrangements raise the valid count above the previous
baseline, which was established before the current dynamic-content and
rotation layout lifecycle. The baseline is therefore increased from 276
to 313 based on repeated corrected runs producing 327–328 arrangements
after the existing 5% margin is applied. This is the smallest baseline
that accepts valid behavior while continuing to reject the redundant
354-pass behavior.

### Regression PR

PR #38815

Validated the behavior in the following platforms
 
- [x] iOS
- [ ] Mac
- [ ] Window
- [ ] Android
 
### Issues Fixed
  
Fixes #39395

### Output

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/7ae5fb9f-ed59-4c3a-8b88-02e52d20d104">|
<video
src="https://github.com/user-attachments/assets/ea367492-c6b5-45d3-ace7-3d8848cdcb6c">|
kubaflo added a commit that referenced this pull request Oct 18, 2026
…iOS device rotation (#38815)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Backport

Backport of #38771 from `inflight/current` to `inflight/candidate`. The
fix, regression test, and all three screenshot baselines are unchanged
from the original PR.

### Root cause

The issue occurs because of the cell being arranged too early during the
preferred layout pass when the collection view constraints change during
device rotation. This updates the cached arranged size before
LayoutSubviews receives the final native bounds, which can cause the
layout to skip the required final arrangement and result in incorrect
item positioning or sizing in RTL layouts.

### Solution description

The fix involves deferring the arrangement to LayoutSubviews when the
layout constraints change, such as during device rotation, so the cell
can be arranged using the actual native bounds. At the same time, inline
arrangement is retained for dynamic content changes to preserve the
behavior introduced by the existing CollectionView2 dynamic content fix.

### Regression PR

#37437

### Validation

The original PR reports validation on iOS. Platform tests were not rerun
for this backport. Repository formatting completed successfully, and the
candidate patch ID matches the original commit exactly, including the
binary screenshot baselines.

### Issues Fixed

Fixes #38622

### Output ScreenShot

Before/after recordings from the original PR:

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/4c2b5c8f-fd29-40b0-a8f3-5063684dc6fd">|
<video
src="https://github.com/user-attachments/assets/948ef0eb-f31d-47e7-b7a9-509a54680f16">|

Co-authored-by: BagavathiPerumal <bagavathiperumal.a@syncfusion.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo pushed a commit that referenced this pull request Oct 18, 2026
…ctionView2 (#39396)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root cause

The issue occurs because TemplatedCell2 used the most recent managed
arrange size to determine whether UIKit had changed the cell’s native
bounds. Preferred-size calculations can update this value before UIKit
applies its final bounds, making native size changes difficult to
detect. PR #38815 allowed any pending arrange to trigger a final
arrangement, resulting in redundant arrange passes when the native
bounds had not changed and increasing the count to approximately 354.

### Solution description

The fix involves tracking UIKit’s native bounds size separately from the
last managed arrange size. LayoutSubviewscompares consecutive native
bounds and performs a pending final arrangement only when the native
bounds have changed. This preserves the rotation correction and required
inline arrangements for dynamically rebuilt content while avoiding
redundant final arrangements when the native bounds remain unchanged.
The corrected implementation reduced the arrange-pass count to
approximately 327–328.
 
**Reason for test level changes:**
 
The CollectionView2 arrange count increased because recycled or rebound
cells now require an inline managed arrangement after measurement
invalidation. This work is necessary to ensure dynamically rebuilt child
content receives valid geometry and does not render blank. In addition,
a genuine native bounds change, such as device rotation, requires a
final arrangement using the bounds supplied by UIKit.
 
These required arrangements raise the valid count above the previous
baseline, which was established before the current dynamic-content and
rotation layout lifecycle. The baseline is therefore increased from 276
to 313 based on repeated corrected runs producing 327–328 arrangements
after the existing 5% margin is applied. This is the smallest baseline
that accepts valid behavior while continuing to reject the redundant
354-pass behavior.

### Regression PR

PR #38815

Validated the behavior in the following platforms
 
- [x] iOS
- [ ] Mac
- [ ] Window
- [ ] Android
 
### Issues Fixed
  
Fixes #39395

### Output

|Platform|Before|After|
|--|--|--|
|iOS| <video
src="https://github.com/user-attachments/assets/7ae5fb9f-ed59-4c3a-8b88-02e52d20d104">|
<video
src="https://github.com/user-attachments/assets/ea367492-c6b5-45d3-ace7-3d8848cdcb6c">|
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 24, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 52ef09ed Deployed Sep 23, 2026 by kubaflo via conclusion #2041
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants