Open mbalous opened 4 years ago
Hi @mbalous - thanks for submitting this issue! I wasn't able to reproduce the exception that you're seeing on UWP. Would you be able to share a screen recording and provide any other details of the occurrence, so that we can try to better understand what you're experiencing? Thanks :)
Hello @rachelkang , sure thing. Here you go: https://www.youtube.com/watch?v=WEWC6AKKjhM
You can see the screen, keyboard and the mouse at the same time. At the end of the video I had to increase my typing and selecting speed for the bug to occur.
Hello, it happened to me too ... Do we know when it will be corrected?
An easier way to (unfortunately) reproduce it:
Enter some text in an IsPassword entry. Select all of that text, and then type a couple of characters quickly (pressing two keys at once might do the trick; or just mash the keyboard). It will crash, likely even on the first try; if not, repeat. It won't take long, a few tries at most.
Parameter name: count
at System.String.Remove(Int32 startIndex, Int32 count)
at Xamarin.Forms.Platform.UWP.FormsTextBox.OnKeyDown(KeyRoutedEventArgs e)
Having an intermediate control that does obfuscation, has internal race conditions and no error handling is not cool, Xamarin people. Not cool at all.
I "solved" it by doing this in UWP App.xaml.cs, and it doesn't seem that it has bad consequences. It might, I'm not sure. It's probably better than crashing the application entirely and making users call our tech support to complain that our app is unstable (which it is, due to many many bugs like this one).
private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
var exceptionStackTrace = e.Exception.StackTrace;
e.Handled = true;
if (exceptionStackTrace.Contains("at Xamarin.Forms.Platform.UWP.FormsTextBox.OnKeyDown(KeyRoutedEventArgs"))
{
System.Diagnostics.Debug.WriteLine("FormsTextBox crash handled");
return;
}
...
BTW, if anyone's having problems with logging UWP crashes, make sure that var foo = e.Exception.StackTrace is the first line in your handler. Took me a long time to figure out.
Also note the "unfinished" string in the Contains method above. That's because I have production errors like this:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at System.String.Remove(Int32, Int32) + 0x12e
at Xamarin.Forms.Platform.UWP.FormsTextBox.OnKeyDown(KeyRoutedEventArgs) + 0x201
at Windows.UI.Xaml.Automation.Peers.AutomationPeer.global::Windows.UI.Xaml.Automation.Peers.IAutomationPeerOverrides.IsEnabledCore() + 0x7
at foo!<BaseAddress>+0x3e066a2
Which is just slightly different than the exception above ("(KeyRoutedEventArgs e)" vs. "(KeyRoutedEventArgs)" and might be a debug-release thing.
Description
Writing into Xamarin.Forms Entry on UWP with
IsPassword
set totrue
causes ArgumentOutOfRangeExceptionSteps to Reproduce
<Entry IsPassword="True"/>
FormsTestBench.zip
Expected Behavior
No exception to occur.
Actual Behavior
Exception occurs.
Stacktrace:
Basic Information
Reproduction Link
Run FormsTestBench.UWP and use the Entry provided FormsTestBench.zip
Workaround
Workaround for this issue could be similar to this: https://github.com/xamarin/Xamarin.Forms/issues/8644 https://github.com/xamarin/Xamarin.Forms/pull/8645