-
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
PresentationFramework.TextStore.GrantLock hangs application on Windows 11 #10032
Comments
I can repro your issues. I debug the code and find the width of the result from GetLineBounds is zero. And the position = textView.GetPositionAtNextLine(thisPointer, Double.NaN, count, out newSuggestedX, out count);
if (!position.IsAtInsertionPosition)
{
if (!respectNonMeargeableInlineStart ||
(!IsAtNonMergeableInlineStart(position) && !IsAtNonMergeableInlineEnd(position)))
{
position.MoveToInsertionPosition(position.LogicalDirection);
}
} wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextPointerBase.cs Lines 804 to 854 in 68baa81
But the arrange alogrithm of RichTextBox is too complex, that I can not find the main reason. It seems that the |
Hey @cbra-caa is this issue reproducible in .NET Core as well? |
@himgoyalmicro Yes, it can repro in .NET 8 and .NET 9 |
@himgoyalmicro I can reproduce it in .NET 8 as well |
@harshit7962 Any news on this one? We have customers who are moving from Win10 due to EOL so this is not optimal. |
Description
We have a AutoCompleter in our project which uses a RichTextBox internally. When the user writes text we search, and return an object which matches the entered text. In that case we delete the text and replace it with an InlineUIContainer which then displays the found item. The items are interactive and the user might use their contextmenu or copy them to another place.
Currently when users try to perform either of these actions the client hangs, and finally is killed of by the OS.
I have created a MVP which displays the problem which can be seen in the following gif:
If you take a dump of the file, or pauses the Application with a debugger attached the stalling seems to originate from the following stacktrace where the 3 highlighted lines always are present:
PresentationFramework.dll!System.Windows.Documents.TextSchema.IsNonMergeableInline(System.Type elementType) Unknown PresentationFramework.dll!System.Windows.Documents.TextSchema.IsMergeableInline(System.Type elementType) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointerBase.GetBorderingElementCategory(System.Windows.Documents.ITextPointer position, System.Windows.Documents.LogicalDirection direction) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointerBase.IsAtNormalizedPosition(System.Windows.Documents.ITextPointer position, bool respectCaretUnitBoundaries) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointerBase.NormalizePosition(System.Windows.Documents.ITextPointer thisNavigator, System.Windows.Documents.LogicalDirection direction, bool respectCaretUnitBoundaries) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointer.MoveToInsertionPosition(System.Windows.Documents.LogicalDirection direction) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointer.System.Windows.Documents.ITextPointer.MoveToInsertionPosition(System.Windows.Documents.LogicalDirection direction) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointerBase.MoveToLineBoundary(System.Windows.Documents.ITextPointer thisPointer, System.Windows.Documents.ITextView textView, int count, bool respectNonMeargeableInlineStart) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointer.MoveToLineBoundary(int count) Unknown PresentationFramework.dll!System.Windows.Documents.TextPointer.System.Windows.Documents.ITextPointer.MoveToLineBoundary(int count) Unknown PresentationFramework.dll!System.Windows.Documents.TextStore.MS.Win32.UnsafeNativeMethods.ITextStoreACP.GetTextExt(int viewCookie, int startIndex, int endIndex, out MS.Win32.UnsafeNativeMethods.RECT rect, out bool clipped) Unknown [Native to Managed Transition] [Managed to Native Transition]
PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLock() Unknown PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLockWorker(MS.Win32.UnsafeNativeMethods.LockFlags flags) Unknown PresentationFramework.dll!System.Windows.Documents.TextStore.RequestLock(MS.Win32.UnsafeNativeMethods.LockFlags flags, out int hrSession) Unknown
[Native to Managed Transition] [Managed to Native Transition] WindowsBase.dll!System.Windows.Threading.Dispatcher.GetMessage(ref System.Windows.Interop.MSG msg, System.IntPtr hwnd, int minMessage, int maxMessage) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Unknown PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Unknown PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Unknown PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) Unknown PresentationFramework.dll!System.Windows.Application.Run() Unknown Win11TextPointerHang.exe!Win11TextPointerHang.App.Main() Unknown
Inspecting it in the Windows Event Log it seems to be a 4-step cycle:
Problem signature
Problem Event Name: AppHangB1
Application Name: Win11TextPointerHang.exe
Application Version: 1.0.0.0
Application Timestamp: 6720fc2b
Hang Signature: bec4
Hang Type: 134217728
OS Version: 10.0.22631.2.0.0.768.101
Locale ID: 1030
Additional Hang Signature 1: bec4eacce45c87d222cf0c1d657a150a
Additional Hang Signature 2: c247
Additional Hang Signature 3: c24739b36124a85c61b2550e90c2503b
Additional Hang Signature 4: bec4
Additional Hang Signature 5: bec4eacce45c87d222cf0c1d657a150a
Additional Hang Signature 6: c247
Additional Hang Signature 7: c24739b36124a85c61b2550e90c2503b
Reproduction Steps
Can be repoduced as follows.
Expected behavior
You can delete text in a textrun via the TextPointer.DeleteTextInRun.
Actual behavior
Deleting text with TextPointer.DeleteTextInRun hangs the applicaiton.
Regression?
Works in Windows 10 - seems isolated to Windows 11
Known Workarounds
No response
Impact
The bug impacts all users on Windows 11 which try to interact (selection or context menu) with an item which has just been created in a RichTextBox.
Configuration
.Net:
Framework 4.8
OS:
Windows 11 Pro for Workstations
23H2 - 22631.4391
**Architecture **
x64
Configuration
Observed across multiple different computers which all runs Windows 11. Windows 10 cannot reproduce the problem.
First observed around mid June this year, but we have few customers on Windows 11 so might have existed for longer.
Other information
OBS: There seems to be some limitations to the problem.
The text was updated successfully, but these errors were encountered: