Open fischberg opened 1 year ago
FYI: The corresponding StackOverflow question is https://stackoverflow.com/questions/76560978/how-to-find-cause-of-app-crashing-on-ios-device-but-not-on-simulator-no-crash.
Hi @fischberg. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
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.
@PureWeen I'm running VS Studio for Mac. If I go to updates, it shows no updates available. On your release page, it shows that VS 17.6 build 1569 is the latest release which is what I'm running. Are you suggesting I manually install the latest preview version of .NET 8?
I installed .NET SDK version 8 preview 5 and installed the MAUI workload. I get the same error messages and the same crash behavior. Unfortunately, no change.
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.
I have determined definitively that those error messages are not related to the cause of my app crashing.
Verified this on Visual Studio Enterprise 17.7.0 Preview 5.0. Repro on iOS 16.4 .NET 8, not repro on Android 13.0-API33 and Windows 11 with below Project: CollectionViewDemos.zip
Having the same issue. With NET 8 RC2
This is API misuse.
In the UICollectionViewDataSource.collectionView(_ collection: UICollectionView, cellForItemAt indexPath: IndexPath)
method implementation, the index path you pass to collection.dequeueReusableCell
when getting the cell should be exactly the same as index path you received in indexPath
parameter.
I've hit exactly the same issue developing natively for iOS. Since this thread is the only relevant result on entire google, decided to post possible solution here for future seekers.
In complex, compound data sources containing separate section sources, it's easy to miss proper section
value in index path, and ask collection view to return cell for path that doesn't exist in reality.
When user scrolls, collection view first uses its UICollectionViewLayout
instance to determine what cells are going to appear next, and then asks its data source for these cells. When you call dequeueReusableCell
in your data source implementation, collection view prepares the cell and assigns cached layout attributes to it before returning the cell to you (for optimization purposes).
However, when you pass index path that is wrong (for example, when you have multiple sections with different item counts), collection layout could not figure out proper attributes for these cells and issues tons of warnings.
Here's the possible cause in project sources: section 0 is always used when fetching a view. https://github.com/dotnet/maui/blob/71687020392deca465f051bc808906836068cc39/src/Controls/src/Core/Handlers/Items/iOS/GroupableItemsViewController.cs#L184
In grouped collections where all groups contains same items: no logic impacts, small extra autolayout overhead. Serious scrolling slowdown when debugger is attached to the app (due to synchronous nature of xcode log reader). No performance drop when app runs on its own.
In collections where groups contains different cell types, especially for sections with orthogonal scrolling behavior: visual artifacts, broken orthogonal scrolling. Even hit a collection view total hang (only once). Same performance penalty when debugger attached.
So, just make sure that you always pass valid index paths when asking for reusable cells.
Hope this helps.
Is there any thoughts on how to fix this so far? Thx @wsb9 for detailing the guts of the problem... BUT... not sure how to take this information and do anything with it other than to complain to Microsoft to fix it?
+1 This is occurring on an iOS simulator using 17.2. It seems to work on simulators using 16.4 Edit: It is not crashing on simulators using 16.4, however it is throwing the message in the application output, and the simulator slows down dramatically if it has to render several controls in the collection.
Any news?
Any news on this big problem with grouped data in collectionview ?
Same issue, app works perfectly on Android but iOS crashes 😕 need a fix or work around badly, this is blocking.
@LeoJHarris - while I still get these error messages on iOS, my app never crashes because of them. May want to verify that your crash isn’t due to something else.
@fischberg I will investigate this further, I was not having the issue Android, given that we have just completed out app migration from Xamarin, I have a few niggly issues that I probably need to diagnose further to understand if its a framework issue or not.
Description
If I use a CollectionView with IsGrouped="true", when rendering the CollectionView, the app generates the following error message twice for each Group.
[Assert] UICollectionView internal inconsistency: attempting to apply nil layout attributes to view. View: <Microsoft_Maui_Controls_Handlers_Items_VerticalSupplementaryView: 0x7fd35db14c60; baseClass = UICollectionViewCell; frame = (0 0; 0 0); layer = <CALayer: 0x600000941b00>>; current attributes from view: (null); collection view: <UICollectionView: 0x7fd3662b8800; frame = (0 0; 374 896); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000d83bd0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000098f940>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_ListViewLayout: 0x7fd35e12cec0>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x7fd35daaf2d0>>
When I deploy a Release or Debug build to my physical iPhone, I can render the offending page 4 times. On the 5th attempt it crashes. I've been unable to determine the exact cause of the crash because no crash report is generated. These error messages are generated on the 1st 4 renderings and appear on the 5th attempt just before the app crashes. Regardless of whether or not these error messages are related to cause of my app crashing, the root cause should be resolved.
These error messages are generated when using Release and Debug builds and on both a physical device and simulator. However, the app only crashes on a physical device. Again, I'm not sure if this is the cause of the crash.
The error message I pasted above is generated from the repro code that I provided in this report. The error messages for my app are very similar. Below, I pasted the relevant output from the repro, not my actual app.
Steps to Reproduce
Build the CollectionViewDemos app from the provided repository. This is an exact copy from the Maui Samples GitHub repository. Start the app Select the "Grouping, Vertical list with DataTemplates" menu item. Observe the error messages in the Application Output.
Link to public reproduction project repository
https://github.com/fischberg/CollectionViewDemos.git
Version with bug
7.0.86
Last version that worked well
Unknown/Other
Affected platforms
I was not able test on other platforms
Affected platform versions
iOS 16.4
Did you find any workaround?
None.
Relevant log output