[Android] Crash when replacing a Layout (Grid or Stacked) in an existing layout #21338
Labels
area-layout
StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter
high
It doesn't work at all, crashes or has a big impact.
platform/android 🤖
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
On Android when the new Layout is added to the existing layout the following error occurs:
![image](https://private-user-images.githubusercontent.com/1641428/314581074-25423e75-fa12-4329-830a-f367727980f2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2ODEwOTYsIm5iZiI6MTcyMDY4MDc5NiwicGF0aCI6Ii8xNjQxNDI4LzMxNDU4MTA3NC0yNTQyM2U3NS1mYTEyLTQzMjktODMwYS1mMzY3NzI3OTgwZjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTFUMDY1MzE2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDI4NjMzOWFkMzczYmU2NjZmYTY0OTMzNmE0OTVkNDlkNGVmNzNmMDI2NTNkN2RlNTJiN2FhZGE1ODc1N2I3YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.BuLn6vd54SZrTKDXEX47Y9dBvsldLTi7rehP3jpQ0FQ)
This works on iOS
Steps to Reproduce
Create a file > new Net Maui App. Change the MainPage to:
and run it. The error occurs for both the Grid code and the commented out VerticalStackLayout code.
If the line in SetOrientation that creates the new Layout Control is commented out the error does not occur. This isn't a workaround because in my use case I'm changing the Inner layout based on the orientation.
Stepping through the SetOrientation code the InnerGrid is successfully removed from the children of the outer grid by the Remove() command - OuterGrid.Children.Count goes from 1 to 0. It is also successfully added back at the Add command - OuterGrid.Children.Count goes from 0 back to 1 - as the error is thrown; it's as if it's trying to add the InnerGrid twice.
Link to public reproduction project repository
No response
Version with bug
8.0.10 SR3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Tested on Android 12.1 and 14.0
Did you find any workaround?
If I don't remove and re-add the
Relevant log output
No response
The text was updated successfully, but these errors were encountered: