Skip to content

WPF Application FailFast in System.Windows.Controls.TextBoxView.GetFormattedLine when using Hebrew text and non-adorner based text selection #2314

Open

Description

@arpitmathur

The WPF application is using a Textbox component with the text in Hebrew language. The text contain a combination of text and date and month separated by ‘/’. The application is crashing when the user select the ‘/’ along with the number(i.e. date and month). In Windows 10 1909, with the .Net Framework version 4.8 is the environment where the application is experiencing the crash.
 
Steps to reproduce:

Create a WPF application.
Use a Textbox with the below properties and text.

TextWrapping="Wrap" FlowDirection="RightToLeft" Margin="10" Text="נסה לסמן את הלוכסן שבין הספרות 07/1997 והתוכנה תקרוס"

(Text Translation: Try to mark the slash between the digits 07/1997 and the software will crash)
Set the window size as below

Height="200" Width="250"
Please the below code, in App.xaml.cs

      private void Application_Startup(object sender, StartupEventArgs e)

    {

        AppContext.SetSwitch("Switch.System.Windows.Controls.Text.UseAdornerForTextboxSelectionRendering", false);

    }

Please the below code in App.xaml

Startup="Application_Startup"
Run the application and select the text including the '/' in the text using the mouse.
The application will crash in few seconds

Notes:

  1. This does appear to be specific to Hebrew. I was unable to reproduce this with Arabic, which is another RTL language.

  2. RTL doesn't actually matter. You can use the same text and change from RTL to LTR. Still repros.

  3. This is specific to non-adorner selection of text.

Activity

  1. added
    Bug
    on Dec 17, 2019
  2. added this to the 5.0 milestone on Dec 17, 2019
  3. modified the milestones: 5.0.0, 7.0.0 on Aug 26, 2021
  4. jschroedl commented on Dec 19, 2024

    @jschroedl

    We are seeing errors with Latin (English) text as well where we crash in the same code. .NET Framework 4.8 here. We have no way to workaround or catch this exception.

    Can anyone from Microsoft advise on how we can at least avoid the crash?

  5. jschroedl commented on Dec 19, 2024

    @jschroedl

    We found a workaround which works for our case. It seems that using bad line information in MeasureOverride can be avoided if you delay when you do a SelectAll and set Focus to the TextBox. We use BeginInvoke at ApplicationIdle priority and it appears that the TextBox has the correct font info for its first MeasureOverride and the crash is avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NET FrameworkBug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions