Users of our app are experiencing crashes when long pressing an editor with an Apple Pencil.
There is not known workaround and is affecting us very badly given the users lose all what they have been typing when this happens given we are not able to catch the exception.
I'm able to reproduce this all the times and on a brand new project.
Assertion failure in void __NSTextContentStorageCacheElementIndexRange(NSTextContentStorage , NSRange, const NSTextElement , NSInteger)(), NSTextContentManager.m:707
2023-05-10 10:53:01.037 CrashReproduction.iOS[823:139035] Xamarin.iOS: Aborting due to unhandled Objective-C exception:
NSTextContentStorage: Inconsistent element cache state. Elements for range {0, 4} are already cached while trying to insert
Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
at <unknown> <0xffffffff>
at UIKit.UIApplication:xamarin_UIApplicationMain <0x00007>
at UIKit.UIApplication:UIApplicationMain <0x0004b>
at UIKit.UIApplication:Main <0x000df>
at CrashReproduction.iOS.Application:Main <0x0007f>
at System.Object:runtime_invoke_dynamic <0x0010f>
Steps to reproduce
Write something on the editor and then proceed to try to select it with a long press, the editor will seem like adding extra spaces to complete the line you're writing and another following line and then will crash.
Expected behaviour
The app highlights the text and doesn't crash.
Actual behaviour
App crashes and data that was input previously is lost.
Basic Information
Version with issue: 5.0.0.2196 - (also happens with the latest version)
Last known good version: -
Environment
Visual Studio for Mac version 17.5.4 build 8
This is a bug in the Apple UIKit framework and nothing Microsoft could or should fix with their .NET bindings.
Best way to overcome this issue is probably to force TextKit 1, see here.
Description
Users of our app are experiencing crashes when long pressing an editor with an Apple Pencil. There is not known workaround and is affecting us very badly given the users lose all what they have been typing when this happens given we are not able to catch the exception.
I'm able to reproduce this all the times and on a brand new project.
Assertion failure in void __NSTextContentStorageCacheElementIndexRange(NSTextContentStorage , NSRange, const NSTextElement , NSInteger)(), NSTextContentManager.m:707 2023-05-10 10:53:01.037 CrashReproduction.iOS[823:139035] Xamarin.iOS: Aborting due to unhandled Objective-C exception: NSTextContentStorage: Inconsistent element cache state. Elements for range {0, 4} are already cached while trying to insert
================================================================= Native Crash Reporting
Got a abrt while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
================================================================= Native stacktrace:
================================================================= Basic Fault Address Reporting
Memory around native instruction pointer (0x1e224f558):0x1e224f548 ff 0f 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4 .......)...... 0x1e224f558 03 01 00 54 7f 23 03 d5 fd 7b bf a9 fd 03 00 91 ...T.#...{...... 0x1e224f568 07 ed ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6 .........{..... 0x1e224f578 c0 03 5f d6 7f 23 03 d5 fd 7b bf a9 fd 03 00 91 ....#...{......
================================================================= Managed Stacktrace:
=================================================================
Steps to reproduce Write something on the editor and then proceed to try to select it with a long press, the editor will seem like adding extra spaces to complete the line you're writing and another following line and then will crash.
Expected behaviour The app highlights the text and doesn't crash.
Actual behaviour App crashes and data that was input previously is lost.
Basic Information Version with issue: 5.0.0.2196 - (also happens with the latest version) Last known good version: -
Environment Visual Studio for Mac version 17.5.4 build 8
Crash reproduction project CrashReproduction.zip
Reproduction Video https://github.com/xamarin/Xamarin.Forms/assets/36721479/f1a3a93f-88c6-4dd6-84e2-07ab811f38ea