-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very slow performance due to internal WPF deferred resource reference list #4468
Comments
I am currently trying to solve this. Original (remove): Modified (add): Modified (remove): Switching tabs in the repro application takes about 42 seconds in the original version and about 4 seconds in the modified version. Please note: If the WPF team would be interested in a PR i would be happy to create one. |
Allocations are also down from 121 MB to 95 MB during add. Didn't profile the other operations. |
And i guess perf could be further improved when |
You know the WPF team batzen... If you write this here you never get an answer. Create a PR and see how it goes. |
We have been facing this issue for years. I have hoped for such a long to see this corrected. |
FYI: Will create a PR during Hacktoberfest |
Is there any news about this issue? We are running our application in .NET 4.6.2 and it seems to be this same issue. We seemed to have started seeing it once we migrated to using DynamicResources in more places for common components, but it only gets worse and worse over time after extended use of the application. |
Apologies, this got dropped from our radar. We will review this in upcoming CTP(s) cycles. Since some of the PR(s) affect WPF core, we believe our existing tests may not be adequate in highlighting any problems early-on. That being said, is still not an excuse for extended radio silence on such PR(s). We will work on improving the situation. |
Any news? |
@pchaurasia14 Another year passed. Any news? |
@dipeshmsft Should this be closed now as #5610 has been merged? |
Problem description:
Opening, closing and moving between views in a WPF application becomes extremely slow.
Actual behavior:
Debugging tools show that considerable time is spent in FindWeakReference() iterating over items in ResourceDictionary._deferredResourceReferences.
The list accumulates tens of thousands of entries.
Expected behavior:
No delays as described above. From browsing the source code, we believe that entries in
_deferredResourceReferences
are intended to be short lived.Minimal repro:
https://github.com/oatkins/WpfDeferredResourceLookupRepro/tree/repro
The above repro is a bit contrived, but reproduces delays of the same order of magnitude as we are seeing in a real LOB application. It seems that all of the following are needed to reproduce this:
DynamicResource
references.DynamicResource
reference.Steps 1-3 cause the list of
_deferredResourceReferences
to become long, but this doesn't actually affect performance without step 4.This is easy to reproduce using the popular MahApps.Metro UI toolkit for the following reasons:
In our application, this performance bottleneck is typically responsible for adding an additional 7 seconds to the time it takes to open a form, bringing the total time to 10 seconds. It accounts for an even longer delay closing the same form.
Note that, while an application using MahApps is particularly likely to exhibit this behaviour, I'm reporting it here because its quite easily reproducible in an application that doesn't deviate from normal WPF coding practices.
We are hoping to work around this by modifying our styles (and overriding default MahApps styles) to reduce the number of dependency properties that are assigned a value using
DynamicResource
when that value is not read almost immediately. Our application currently runs on .NET Framework 4.8, but we hope, in time, to migrate it to .NET 5 or 6. However, the repro linked above shows that the problem is currently manifest in both flavours of WPF.This issue is to do a few things:
FindWeakReference()
?The text was updated successfully, but these errors were encountered: