-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Init the flex item before adding it to the layout #21737
Conversation
Fixes #21711 In some cases, adding an item before may trigger an update before the add operation is complete. For example, adding a label with HTML text may cause the layout to run while the label is being constructed. To prevent that layout pass from crashing because the flex item is not yet set, we make sure to first set the flex item, and then add it to the layout. Then, when the layout pass runs, the item is ready to be used. This error might not typically appear in normal XAML layouts because the items are first set, and then the entire page is inflated. However, if the layout is part of a CollectionView or items are added dynamically after the UI is loaded, this layout during add may occur.
(Not want to hijack this PR but I wrote this comment #9075 (comment) and perhaps "it's obviously wrong there"1 and thus an opportunity to kill two bugs with one PR.) Footnotes
|
@MartyIX Oh wow, that is interesting... Layout being called in a measure... which may call measure... But I think this is unrelated since this is iOS and that was Windows. I also found something that is probably the reason for this issue on iOS (not saying there is not another issue with measure/layout, just there are probably more than one):
Seems the HTML type for maui/src/Core/src/Platform/iOS/LabelExtensions.cs Lines 76 to 90 in 8410edb
|
IOS UI tests are all green. Android and Windows are not adding items (or the test is broken) so there is some issue with adding items at runtime. |
Hmm, I blame Appium. Manually running the tests and clicking on buttons work. Appium times out. Time to investigate! |
Looks like Android and Windows are now passing after I added the AutomationId. |
Failing test not related |
Description of Change
In some cases, adding an item before may trigger an update before the add operation is complete. For example, adding a label with HTML text may cause the layout to run while the label is being constructed.
To prevent that layout pass from crashing because the flex item is not yet set, we make sure to first set the flex item, and then add it to the layout. Then, when the layout pass runs, the item is ready to be used.
This error might not typically appear in normal XAML layouts because the items are first set, and then the entire page is inflated. However, if the layout is part of a CollectionView or items are added dynamically after the UI is loaded, this layout during add may occur.
Issues Fixed
Fixes #21711