Completed
Last Updated: 05 Oct 2022 13:06 by ADMIN
Adam
Created on: 23 Sep 2022 22:14
Category: RichTextBox
Type: Bug Report
0
Windows11Theme and RadRichTextBox Performance Degraded

A user reported a significant performance impact with the RichTextBox in our recent update. The UI hangs repeatedly while typing.

Profiling showed a lot of garbage collections, and profiling highlighted the the Telerik class Telerik.Windows.Controls.MarkupExtensions.DocumentsResourceProvider.


#if NETCORE
        private static Style ThemeStyle
        {
            get
            {
                if (themeStyle == null)
                {
                    themeStyle = GetStyleFromApplicationTheme();
                }
                return themeStyle;
            }
        }

        private static Style GetStyleFromApplicationTheme()
        {
            if (StyleManager.IsEnabled && StyleManager.ApplicationTheme != null)
            {
                var themeName = StyleManager.ApplicationTheme.GetType().Name.Trim('_').ToLower();
                themeName = themeName.Replace("theme", string.Empty);

                var themesGeneric = Application.LoadComponent(new Uri("/Telerik.Windows.Controls.RichTextBox;component/themes/generic.xaml", UriKind.Relative)) as ResourceDictionary;
                if (themesGeneric != null)
                {
                    var currentThemeDictionary = themesGeneric.MergedDictionaries.FirstOrDefault(rd => rd.Source != null && rd.Source.OriginalString.ToLower().Contains(themeName));
                    if (currentThemeDictionary != null)
                    {
                        return currentThemeDictionary[typeof(DocumentsResourceProvider)] as Style;
                    }
                }
            }
            return null;
        }

 

I copied this code into my project to debug it, and found:

  1. themeName is correctly calculated to "windows11".
  2. themesGeneric is correctly loaded from the XAML.
  3. currentThemeDictionary gets null because windows11 isn't included in the merged dictionaries.

As the method returns null, it means themeStyle is always null, and it will try again on the next caller. This code is called repeatedly while typing. Using my code (and reflection) to force this ThemeStyle to Fluent fixes the performance, though obviously is a huge workaround.

 

1 comment
ADMIN
Masha
Posted on: 27 Sep 2022 08:58

Hello Adam,

Thank you for the provided details and code snippet - they were of great help.

I investigate the described behavior and can confirm that the problem comes from our side. It is already brought to the attention of our development team. The fix is expected to be a part of the next LIB, scheduled for the beginning of the next week.

As a small gesture of gratitude for bringing this to our attention, I am awarding you with some Telerik points.

Regards,
Masha
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.