unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.76k stars 704 forks source link

`DependencyObjectStore` is realized for all UIElements #13787

Open Youssef1313 opened 11 months ago

Youssef1313 commented 11 months ago

What would you like to be added

DependencyObjectStore is evaluated lazily for performance reasons:

https://github.com/unoplatform/uno/blob/a252c67d11ce9f2a8a6444881b58af0065262bbd/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs#L792-L804

However, all UIElements will access the store in the constructor.

image

It's worth investigating if we can avoid the UpdateHitTest call in UIElement constructor to avoid realizing many DependencyObjectStores

Why is this needed

No response

For which platform

No response

Anything else we need to know?

No response

Youssef1313 commented 11 months ago

cc @dr1rrb

dr1rrb commented 11 months ago

Looking at the code, the UpdateHitTest in invoked in the ctor in order to properly initialize (i.e. invoke the coerce method that depends on multiple other properties) of the HitTestVisibilityProperty. It could probably be deferred to the loading.