You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce the per-reference cost of applying {ThemeResource} #25396
Make applying {ThemeResource} references cheaper per element. For each reference, today's mechanism:
registers a ResourceBinding, and ResourceBinding derives from BindingBase, so each one is a full DependencyObject with its own property store,
keeps those bindings in a Dictionary<DependencyProperty, Dictionary<Precedence, ResourceBinding>>,
allocates a new WeakReference<ResourceDictionary> for every ThemeResourceReference pinned to a dictionary,
allocates a GetResourceDictionaries iterator for each ancestor walk in UpdateThemeReference,
runs UpdateAllThemeReferences twice for every element: once at Enter (the WinUI behavior, depends.cpp:1056-1060) and again in FrameworkElement.OnLoadingPartial.
Why is this needed? 🤔
Templates with many theme references pay this cost for every container. The WinUI ListViewItemPresenter template (adopted by the default ListView/GridView styles in #25389) carries 41 {ThemeResource} attributes per item. A 1,000-tile GridView realize allocation trace attributes about 145 MB to ResourceBinding, 100 MB to the iterator, 40 MB to ThemeResourceReference and about 120 MB to the nested dictionaries. The Loading-time pass is about 20% of first-frame CPU.
For which platforms 📱💻🖥️
Skia (all heads)
Anything else we need to know? 💬
Measured with a local GridView/ListView harness on Win32 Skia, as part of the #25389 performance work.
Activity