linkedin / Hakawai

A powerful, extensible UITextView.
Apache License 2.0
781 stars 104 forks source link

Crash in HKWTextView when editing in Arabic language #240

Open er-aman-gupta opened 2 years ago

er-aman-gupta commented 2 years ago

After writing a couple of lines in the Arabic language in HKWTextView, the app crashes. Call stack -

2021-10-14 12:54:40.198309+0530 HakawaiDemoSwift[26165:187932] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteTextStorage attributesAtIndex:effectiveRange:]: Range or index out of bounds'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff2043a126 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20177f78 objc_exception_throw + 48
    2   UIFoundation                        0x00007fff23a1512c -[NSConcreteTextStorage attributesAtIndex:longestEffectiveRange:inRange:] + 0
    3   Foundation                          0x00007fff20740186 -[NSAttributedString enumerateAttributesInRange:options:usingBlock:] + 173
    4   Hakawai                             0x0000000101ba7004 -[HKWLayoutManager roundedRectBackgroundAttributeTuplesInTextStorage:withinRange:] + 484
    5   Hakawai                             0x0000000101ba655c -[HKWLayoutManager drawBackgroundForGlyphRange:atPoint:] + 252
    6   UIKitCore                           0x00007fff24992461 __40-[_UITextViewCanvasView drawTextInRect:]_block_invoke + 307
    7   UIFoundation                        0x00007fff23a13970 -[NSTextStorage coordinateReading:] + 42
    8   UIKitCore                           0x00007fff249922b2 -[_UITextViewCanvasView drawTextInRect:] + 424
    9   UIKitCore                           0x00007fff24991e1d -[_UITextCanvasView drawRect:] + 323
    10  UIKitCore                           0x00007fff24bcc721 -[UIView(CALayerDelegate) drawLayer:inContext:] + 625
    11  UIKit                               0x0000000104a2828a -[UIViewAccessibility drawLayer:inContext:] + 74
    12  QuartzCore                          0x00007fff27a5a1e5 -[CALayer drawInContext:] + 288
    13  UIKitCore                           0x00007fff2499434a -[_UITextTiledLayer _drawInContext:offset:clip:] + 124
    14  UIKitCore                           0x00007fff2499403a -[_UITileLayer drawInContext:] + 146
    15  QuartzCore                          0x00007fff27917051 CABackingStoreUpdate_ + 190
    16  QuartzCore                          0x00007fff27a63891 ___ZN2CA5Layer8display_Ev_block_invoke + 53
    17  QuartzCore                          0x00007fff27a59a22 -[CALayer _display] + 2111
    18  QuartzCore                          0x00007fff27a6d1ff _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 463
    19  QuartzCore                          0x00007fff279ad158 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 496
    20  QuartzCore                          0x00007fff279e3ef3 _ZN2CA11Transaction6commitEv + 783
    21  QuartzCore                          0x00007fff279e50af _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 79
    22  CoreFoundation                      0x00007fff203a76b3 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    23  CoreFoundation                      0x00007fff203a1f3f __CFRunLoopDoObservers + 547
    24  CoreFoundation                      0x00007fff203a24e2 __CFRunLoopRun + 1113
    25  CoreFoundation                      0x00007fff203a1b9e CFRunLoopRunSpecific + 567
    26  GraphicsServices                    0x00007fff2b793db3 GSEventRunModal + 139
    27  UIKitCore                           0x00007fff2466d40f -[UIApplication _run] + 912
    28  UIKitCore                           0x00007fff24672320 UIApplicationMain + 101
    29  HakawaiDemoSwift                    0x0000000101908f98 main + 72
    30  libdyld.dylib                       0x00007fff20257409 start + 1
    31  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteTextStorage attributesAtIndex:effectiveRange:]: Range or index out of bounds'
terminating with uncaught exception of type NSException

How to replicate:-