uno
uno copied to clipboard
[Skia] `SettingsExpander` freezes app
Current behavior
Loading SettingsExpander freezes app completely
Expected behavior
Should not happen
How to reproduce it (as minimally and precisely as possible)
- Check out https://github.com/MartinZikmund/uno-bug-repros/tree/bug/settings-expander-freeze
- Try to run the desktop target
- Notice it never loads
Workaround
No response
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
No response
Affected platforms
No response
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response
This is a templated parent bug that causes SettingsCard.Header to be set to the SettingsCard itself, causing a cycle in the tree then we get into an infinite loop while walking the tree up.
It all starts from ContentPresenter.SynchronizeContentTemplatedParent which sets the wrong TemplatedParent.
To elaborate more:
https://github.com/CommunityToolkit/Windows/blob/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsExpander/SettingsExpander.xaml#L87-L96
Here, SettingsCard.Header is bound to TemplatedParent.Header.
In this context, the correct TemplatedParent is SettingsExpander (NOT Expander)
BUT, ContentPresenter is setting its Content templated parent to Expander incorrectly.
This basically means that SettingsCard.TemplatedParent is becoming Expander.
So, when we set SettingCard.Header to TemplatedParent.Header while the templated parent is Expander, we end up setting SettingCard.Header to the SettingCard itself.
We either need to expose the FreezeTemplatedParent hack so that it's used in the implementation here: https://github.com/CommunityToolkit/Windows/blob/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsCard/SettingsCard.cs#L69, or we need to fix TemplatedParent.
This would likely be fixed by https://github.com/unoplatform/uno/issues/1621