unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.93k stars 725 forks source link

Uno Islands don't fire SizeChanged when window is resized #18426

Open ramezgerges opened 3 weeks ago

ramezgerges commented 3 weeks ago

Current behavior

When a window is resized (e.g. by dragging its end), elements that are resized with the window won't get SizeChanged. Their RenderSize will change, but without an accompanying SizeChanged.

Expected behavior

No response

How to reproduce it (as minimally and precisely as possible)

No response

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

Youssef1313 commented 3 weeks ago

This is curious. If RenderSize got updated, then SizeChanged should be enqueued. That then means it's enqueued but there is no new frame so it's not fired.

After we set RenderSize, we call EnqueueForSizeChanged here

https://github.com/unoplatform/uno/blob/09d5d7c1913f469ec77d9f8302b22571e8b8b554/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs#L593-L596

Maybe RequestAdditionalFrame is needed at the end of EnqueueForSizeChanged? But RequestAdditionalFrame isn't done in this code path in WinUI 😕

Youssef1313 commented 3 weeks ago

Thnking about this again, RequestAdditionalFrame shouldn't be needed. RenderSize is supposed to change during Arrange. Then, after arrange is completed, we should be hitting this path:

https://github.com/unoplatform/uno/blob/5fd8ce0b9eb632829840cdd491af2275b4b38909/src/Uno.UI/UI/Xaml/UIElement.cs#L860