question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance degradation when using Spell Checker

See original GitHub issue
  • .NET Framework 4.8
  • Windows version: 2004 (OS Build 19041.450) (yes, it includes KB4562899)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? No

Problem description:

Application freezes for a few seconds when typing text into a TextBox with SpellChecker enabled.

For example, when I do Ctrl-V with a following snippet from the clipboard: image

Text includes apostrophes before and after code snippet (I work with markdown text). I took the snippet from your codebase, but it does not matter what is inside apostrophes.

Actual behavior:

After Ctrl-V application freezes for a few seconds and I cannot type further text. I also observe sporadic delays when text contains words in apostrophes. When I pause application, stacktrace points (multiple times) to the code added in 751153802c4e4d06484743c351266c9831ade85d

NdrClientCall2 Unknown ObjectStublessClient C++ _ObjectStubless@0 Unknown 589966ef() Unknown [Frames below may be incorrect and/or missing, native debugger attempting to walk managed call stack] Unknown 589966ef() Unknown [Managed to Native Transition] System.Windows.Documents.MsSpellCheckLib.Extensions.ToList Unknown System.Windows.Documents.MsSpellCheckLib.SpellChecker.ComprehensiveCheckImpl Unknown System.Windows.Documents.MsSpellCheckLib.SpellChecker.ComprehensiveCheckImplWithRetries.AnonymousMethod__0 Unknown System.Windows.Documents.MsSpellCheckLib.RetryHelper.TryExecuteFunction<System.__Canon> Unknown System.Windows.Documents.MsSpellCheckLib.SpellChecker.ComprehensiveCheckImplWithRetries Unknown System.Windows.Documents.WinRTSpellerInteropExtensions.ComprehensiveGetTokens Unknown System.Windows.Documents.WinRTSpellerInterop.SpellerSentence.Segments.get Unknown System.Windows.Documents.WinRTSpellerInterop.EnumTextSegments Unknown System.Windows.Documents.Speller.SearchForWordBreaks Unknown System.Windows.Documents.Speller.ExpandToWordBreakAndContext Unknown System.Windows.Documents.Speller.ScanRange Unknown System.Windows.Documents.Speller.OnIdle Unknown

I’m not sure if it makes many different COM calls or there is a single COM call inside OnIdle which takes too long. I’m not sure if it is somehow caused by my environment. Please let me know if you need extra details. Any workaround is appreciated.

Expected behavior:

Text typing does not have delays.

Minimal repro:

It 100% reproduces on a WPF sample application in Visual Studio 2017/2019. I can attach a full example, but I think this XAML is enough because the rest is auto-generated code. <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <TextBox x:Name="textBox" TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" SpellCheck.IsEnabled="True"/> </Grid> </Window>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:33 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
garzoomacommented, Oct 2, 2020

We spoke with Microsoft, and they gave us an undocumented switch to set in app.config:

<runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.Controls.DoNotAugmentWordBreakingUsingSpeller=true"/>
</runtime>

It seems to make the problem go away for us. I’d be interested to know what it shows in @JesikaDG’s profiling.

4reactions
SamBentcommented, May 21, 2021

I’ll try to get it into the next .NET 5 servicing update. It may slip to the one after that, if the deadline is too close.

Thanks for the reminder. I hadn’t realized this was blocking .NET 5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spell check textbox in Win10 - Slow
As a result, registering the same set of dictionaries over and over for each control is wasteful and can potentially degrade your performance....
Read more >
Improving The Performance of Spell Checking
We've built a comprehensive, on-demand spell checker for Bipsync. Why did we do this when we get spell checking in the operating system...
Read more >
EJ1149890 - Effects of Spell Checkers on English as a ... - ERIC
In this study, effects of spelling aids on detecting and correcting misspelled words were examined by comparing English as a second language students' ......
Read more >
Notes Spell Checker loads slowly
Over time, the number of temp files can grow causing the spell check performance issue. The workaround is to ename the User.dic in...
Read more >
Performance issue with Chrome v96
Bumping that I see massive degradation but mostly in documents that have a lot of text that is triggering chromes auto spell checker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found