Skip to content

[iOS & Mac] Fix NullReferenceException in CollectionViewHandler2 after handler restore when property changes - #36073

Merged
kubaflo merged 1 commit into
dotnet:inflight/currentfrom
SubhikshaSf4851:fix-36010
Jun 25, 2026
Merged

kubaflo merged 1 commit into
dotnet:inflight/currentfrom
SubhikshaSf4851:fix-36010

Conversation

@SubhikshaSf4851

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 whether this change resolves your issue. Thank you!

This pull request addresses a regression issue where CollectionViewHandler2 could throw a NullReferenceException if a layout property changed after the handler was disconnected and then reconnected. The fix ensures the internal cache is properly reinitialized, and new tests are added to verify the handler's stability in these scenarios.

Description of Change

Bug fix:

  • Ensured _layoutPropertyCache is reinitialized when subscribing to a new items layout in CollectionViewHandler2, preventing NullReferenceException after handler disconnect/reconnect cycles.

Testing improvements:

  • Added regression tests to confirm that changing properties on GridItemsLayout and LinearItemsLayout after a disconnect/restore cycle does not cause crashes in CollectionViewHandler2. These tests cover various property changes and validate the fix

Issues Fixed

Fixes #36010

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforeFix36010 AfterFix36010

…r handler restore when ItemsLayout property changes
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/macos macOS / Mac Catalyst platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jun 23, 2026
@SubhikshaSf4851 SubhikshaSf4851 changed the title [WIP][iOS & Mac] Fix NullReferenceException in CollectionViewHandler2 after handler restore when property changes [iOS & Mac] Fix NullReferenceException in CollectionViewHandler2 after handler restore when property changes Jun 24, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review June 25, 2026 04:55
@sheiksyedm
sheiksyedm requested a review from kubaflo June 25, 2026 04:55
@kubaflo
kubaflo merged commit 16175d6 into dotnet:inflight/current Jun 25, 2026
11 of 17 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR9 milestone Jun 25, 2026
kubaflo pushed a commit that referenced this pull request Jun 25, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Jul 3, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@kubaflo kubaflo mentioned this pull request Jul 6, 2026
kubaflo pushed a commit that referenced this pull request Jul 6, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Jul 7, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Jul 7, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Jul 10, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Jul 15, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Jul 22, 2026
…r handler restore when property changes (#36073)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses a regression issue where
`CollectionViewHandler2` could throw a `NullReferenceException` if a
layout property changed after the handler was disconnected and then
reconnected. The fix ensures the internal cache is properly
reinitialized, and new tests are added to verify the handler's stability
in these scenarios.

### Description of Change

**Bug fix:**
- Ensured `_layoutPropertyCache` is reinitialized when subscribing to a
new items layout in `CollectionViewHandler2`, preventing
`NullReferenceException` after handler disconnect/reconnect cycles.

**Testing improvements:**
- Added regression tests to confirm that changing properties on
`GridItemsLayout` and `LinearItemsLayout` after a disconnect/restore
cycle does not cause crashes in `CollectionViewHandler2`. These tests
cover various property changes and validate the fix

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #36010 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="954" height="693" alt="BeforeFix36010"
src="https://github.com/user-attachments/assets/fb32509b-ce7c-497c-9fa4-3170181e9475"
/> | <img width="947" height="689" alt="AfterFix36010"
src="https://github.com/user-attachments/assets/188f6e3b-6b72-4ead-9af0-342d5d8d7c20"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 26, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR9, .NET 10 SR10 Aug 20, 2026

This branch was previously deployed

1 inactive deployment
gh-aw-agents — 10036ea7 Deployed Jun 23, 2026 by SubhikshaSf4851 via conclusion #524
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 partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[inflight regression] CollectionViewHandler2 crashes after handler restore when adaptive GridItemsLayout.Span changes

3 participants