Critical decrease in the performance of the UWP application when opening large text files in RichEditBox

Евгений Алексеев 81 Reputation points
2022-01-29T17:20:31.407+00:00

Hello, you guys!

So, I have an UWP app that contains a RichEditBox component. I've noticed that there's a critical performance decrease every time I open large text files. The app seem to be working more or less fine if the file is less than 10 Mb, but if the file is larger, then the app becomes extremely slow. Not only during the opening of the file, but even later. If the file is about 50 Mb, believe it or not, but the opening takes about a minute on my machine! It's just not possible to work with the file even after you opened it, because the entire app just pretty much freezes and sometimes even crashes. And let's be honest, 10 Mb or even 50 Mb is not that much. It's not supposed to cause such serious performance issue that affects the whole app. I know there are some limitations with certain components. I know that RichEditBox of a Win32 app is also limited to work with the files less than 1 Gb (some sources claim that performance issues start to occur from 512 Mb files). I get it, there are some limitations and that's understandable, but Win32 apps are able to deal with large files of hundreds of Mb of weight, but what about UWP? Why can't I normally work with files of at least 100 Mb? This is unacceptable! So, my question is, whether or not there's a way to fix this issue? And where can I learn about limitations of components?

EDIT:

The code snippet in MainPage.xaml.cs:

private async void FileOpen_Click(object sender, RoutedEventArgs e)
        {
            // Open a text file. 
            Windows.Storage.Pickers.FileOpenPicker open = new
               Windows.Storage.Pickers.FileOpenPicker();
            open.SuggestedStartLocation =
               Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            open.FileTypeFilter.Add(".rtf");
            Windows.Storage.StorageFile file = await open.PickSingleFileAsync();

            if (file != null)
            {
                Windows.Storage.Streams.IRandomAccessStream randAccStream = await
                   file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                // Load the file into the Document property of the RichEditBox.
                ContentPage.current.SetText(randAccStream);
            }
        }

The code snippet of ContentPage.xaml.cs:

    public sealed partial class ContentPage : Page
    { 
    public static ContentPage current { get; set; }

    public ContentPage()
    {
        this.InitializeComponent();
        current = this;
    }

        public void SetText(IRandomAccessStream randAccStream)
        {
            editor.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.FormatRtf, randAccStream);
        }
Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,466 Reputation points Microsoft Vendor
    2022-02-14T03:06:15.267+00:00

    Hello,

    Welcome to Microsoft Q&A!

    To confirm this behavior, I've tested this in a WinUI3 app as well. It thas the same behavior. I've talked to the team and reported this behavior. Now, this has been logged as a known issue on our side. But I have to say that there are no more actions that we could do. Our suggestion now is that you might need to cut the long text file into small parts and load them one by one.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful