Skip to content
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

[iOS] NullReferenceException in TemplatedCell #20606

Closed
naaeef opened this issue Feb 15, 2024 · 10 comments · Fixed by #20900
Closed

[iOS] NullReferenceException in TemplatedCell #20606

naaeef opened this issue Feb 15, 2024 · 10 comments · Fixed by #20900
Assignees
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 high It doesn't work at all, crashes or has a big impact. i/regression This issue described a confirmed regression on a currently supported version platform/iOS 🍎 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@naaeef
Copy link

naaeef commented Feb 15, 2024

Description

CollectionView crashes on iOS with the SR 2 release.

2024-02-15 10:44:10.513912+0100 AppName[14329:382545] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.UpdateSelectionColor()
   at Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.set_Selected(Boolean value)
2024-02-15 10:44:10.513983+0100 AppName[14329:382545]    at UIKit.UICollectionView.DequeueReusableCell(NSString reuseIdentifier, NSIndexPath indexPath) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UICollectionView.g.cs:line 232
2024-02-15 10:44:10.514065+0100 AppName[14329:382545]    at UIKit.UICollectionView.DequeueReusableCell(String reuseIdentifier, NSIndexPath indexPath) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UICollectionView.cs:line 23
2024-02-15 10:44:10.514142+0100 AppName[14329:382545]    at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController`1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetCell(UICollectionView collectionView, NSIndexPath indexPath)
2024-02-15 10:44:10.514208+0100 AppName[14329:382545]    at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
2024-02-15 10:44:10.514260+0100 AppName[14329:382545]    at UIKit.UIApplication.Main(String[] args, String principalClassName, String delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 84
   at AppName.iOS.Application.Main(String[] args) in /Users/UserName/Documents/workspaces/zak-app/src/Zak/Platforms/iOS/Main.cs:line 17

Steps to Reproduce

I'm currently working on a reproduction sample, but I could reproduce the issue in a blank application yet.

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.6 SR1

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

Use 8.0.6 SR1

Relevant log output

No response

@naaeef naaeef added the t/bug Something isn't working label Feb 15, 2024
@jsuarezruiz jsuarezruiz added area-controls-listview ListView and TableView high It doesn't work at all, crashes or has a big impact. labels Feb 15, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Feb 15, 2024
@jsuarezruiz jsuarezruiz self-assigned this Feb 15, 2024
@ghost
Copy link

ghost commented Feb 15, 2024

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@jsuarezruiz
Copy link
Contributor

Will be fixed by https://github.com/dotnet/maui/tree/fix-20606

@samhouts samhouts added platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Feb 15, 2024
@PureWeen
Copy link
Member

@naaeef can you try the latest nightly?

https://github.com/dotnet/maui/wiki/Nightly-Builds

@jsuarezruiz jsuarezruiz added the s/needs-repro Attach a solution or code which reproduces the issue label Feb 22, 2024
@ghost
Copy link

ghost commented Feb 22, 2024

Hi @naaeef. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView and removed area-controls-listview ListView and TableView labels Feb 22, 2024
@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Feb 26, 2024
@ghost
Copy link

ghost commented Feb 26, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@SamuelJames101
Copy link

I can see this issue on Mac as well

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity labels Feb 26, 2024
@czmirek
Copy link

czmirek commented Feb 28, 2024

@jsuarezruiz @PureWeen I created a reproduction repo!

https://github.com/czmirek/mauiiOScollectionviewbug

Steps to repro:

  • Run app on iPhone or on iPhone Simulator 15 17.2
image
  • Click on Clear & Load items --- everything works.
  • If you click now on Load items and select --- everything works.

Close the app and start debuggin again.

  • Now click directly on "Load items and select"
  • Boom.

@czmirek
Copy link

czmirek commented Feb 28, 2024

Workaroud for this is:

#IF IOS
await Task.Delay(500);
#endif

Apparently it is some kind of racing condition bug, I was not able to find a better workaround.

@PureWeen PureWeen modified the milestones: Backlog, .NET 8 SR3 Feb 28, 2024
@PureWeen
Copy link
Member

This looks specific to being nested in a VSL

For now, do you need to nest your CollectionView inside a VerticalStackLayout?

@czmirek
Copy link

czmirek commented Feb 28, 2024

Of course not, if the problem is CollectionView being inside VeritcalStackLayout I can use something else instead to position different UI elements under the CollectionView...like a Grid or CollectionView's footer.

Is placing CollectionView inside VeritcalStackLayout bad practice?

@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2024
@samhouts samhouts added i/regression This issue described a confirmed regression on a currently supported version and removed fixed-in-8.0.14 fixed-in-8.0.40 fixed-in-9.0.0-preview.2.10247 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 high It doesn't work at all, crashes or has a big impact. i/regression This issue described a confirmed regression on a currently supported version platform/iOS 🍎 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
Status: Done
6 participants