dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 977 forks source link

Performance issue with localizable controls and forms #2427

Open OliaG opened 4 years ago

OliaG commented 4 years ago

Problem description: Right now switching the Localizable property on control causes a large amount of properties moved to a .resx file. At runtime this is loaded with heavy use of reflection and deserialization which shows up in our performance profiles as the biggest reason for slow startup time. In our scenario all the controls and forms are designed using flexible layout containers that are automatically sized to fit the text. The all-or-nothing approach to localization, however, causes the control locations and sizes to be moved to .resx file as well. This results in unnecessarily high number of resources that we never localize and that also cause unnecessary re-layouts at startup.

KlausLoeffelmann commented 4 years ago

Hey @OliaG, please let's talk about this so I can get a better understanding of where this performance problem surfaces and how this is a regression from the classic framework!

elachlan commented 5 months ago

@Olina-Zhang If possible, can your team please see if they can reproduce this issue and see how big of an impact it is?

elachlan commented 5 months ago

@OliaG I think this issue is by design.

There are 19 Properties on Control with [Localizable(true)]

They are generally useful for control layouts on a per-local basis, or providing local specific UI customization.

The designer should not add entries to the resx unless the default values are changed. We should check if this is still the case.

With regards to resource file serialization, there are improvements being made to help with the BinaryFormatter being deprecated as well as the push for AOT/Trimming. I suspect this will have a positive effect on this scenario.