react-native icon indicating copy to clipboard operation
react-native copied to clipboard

NSRange Exception with onPress on Text

Open ghost opened this issue 11 years ago • 7 comments

The following code worked in 0.3.4 but stopped working with any newer version:

 <TouchableHighlight style={styles.button}
                                  underlayColor='#99d9f4'>
                <Text style={styles.buttonText}
                      onPress={this._onSync.bind(this)}
                    >Sync</Text>
</TouchableHighlight>

The problem is the onPress handler on the Text element. It works if the onPress handler is moved to the TouchableHighlight element.

BTW: the stack trace is

(
    0   CoreFoundation                      0x000000010c950a75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c1dbbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010c9509ad +[NSException raise:format:] + 205
    3   UIFoundation                        0x00000001143adc8f _NSBlockNumberForIndex + 84
    4   UIFoundation                        0x000000011436ce27 -[NSLayoutManager(NSPrivate) _invalidateGlyphsForExtendedCharacterRange:changeInLength:includeBlocks:] + 786
    5   UIFoundation                        0x000000011439a692 -[NSLayoutManager _invalidateGlyphsForCharacterRange:editedCharacterRange:changeInLength:actualCharacterRange:] + 176
    6   UIFoundation                        0x000000011439c934 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 208
    7   UIFoundation                        0x00000001143c30ba -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 152
    8   UIFoundation                        0x00000001143c2bf2 -[NSTextStorage processEditing] + 367
    9   UIFoundation                        0x00000001143c2a4c -[NSTextStorage edited:range:changeInLength:] + 305
    10  Foundation                          0x000000010bd852f8 -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 330
    11  UIFoundation                        0x00000001143c4919 -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 78
    12  AwesomeProject                      0x000000010ae7050a -[RCTText setAttributedText:] + 106
    13  AwesomeProject                      0x000000010ae6f7d9 __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke_2 + 201
    14  AwesomeProject                      0x000000010aca57e3 __45-[RCTSparseArray enumerateObjectsUsingBlock:]_block_invoke + 147
    15  CoreFoundation                      0x000000010c891ec6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
    16  CoreFoundation                      0x000000010c891dcc -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    17  AwesomeProject                      0x000000010aca570f -[RCTSparseArray enumerateObjectsUsingBlock:] + 415
    18  AwesomeProject                      0x000000010ae6f6c0 __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke + 208
    19  AwesomeProject                      0x000000010ae6fabb __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke137 + 443
    20  AwesomeProject                      0x000000010acd2dcc __27-[RCTUIManager addUIBlock:]_block_invoke + 124
    21  AwesomeProject                      0x000000010acdbd16 __29-[RCTUIManager flushUIBlocks]_block_invoke + 342
    22  libdispatch.dylib                   0x000000010f38d186 _dispatch_call_block_and_release + 12
    23  libdispatch.dylib                   0x000000010f3ac614 _dispatch_client_callout + 8
    24  libdispatch.dylib                   0x000000010f394a1c _dispatch_main_queue_callback_4CF + 1664
    25  CoreFoundation                      0x000000010c8b8749 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    26  CoreFoundation                      0x000000010c87b62b __CFRunLoopRun + 2043
    27  CoreFoundation                      0x000000010c87abc6 CFRunLoopRunSpecific + 470
    28  GraphicsServices                    0x000000010fe2ea58 GSEventRunModal + 161
    29  UIKit                               0x000000010dfc9580 UIApplicationMain + 1282
    30  AwesomeProject                      0x000000010ac4c193 main + 115
    31  libdyld.dylib                       0x000000010f3e1145 start + 1

ghost avatar Apr 08 '15 19:04 ghost

Have a feeling it's related to #749

arthuralee avatar Apr 08 '15 20:04 arthuralee

Indeed, same issue - you'll need to downgrade for now @rogergl

brentvatne avatar Apr 08 '15 20:04 brentvatne

same issue! found in 0.3.7

'NSRangeException', reason: '*** NSRunStorage, _NSBlockNumberForIndex(): index (2) beyond array bounds (0)' *** First throw call stack: ( 0 CoreFoundation 0x014ba466 __exceptionPreprocess + 182 1 libobjc.A.dylib 0x00973a97 objc_exception_throw + 44 2 CoreFoundation 0x014ba38d +[NSException raise:format:] + 141 3 UIFoundation 0x08d872c2 _NSBlockNumberForIndex + 89 4 UIFoundation 0x08d40fe5 -[NSLayoutManager(NSPrivate) _invalidateGlyphsForExtendedCharacterRange:changeInLength:includeBlocks:] + 727 5 UIFoundation 0x08d412d1 -[NSLayoutManager(NSPrivate) _invalidateGlyphsForExtendedCharacterRange:changeInLength:] + 64 6 UIFoundation 0x08d71b34 -[NSLayoutManager _invalidateGlyphsForCharacterRange:editedCharacterRange:changeInLength:actualCharacterRange:] + 167 7 UIFoundation 0x08d73c34 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 221 8 UIFoundation 0x08d73fce -[NSLayoutManager processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:] + 85 9 UIFoundation 0x08d9e3db -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 153 10 UIFoundation 0x08d9defa -[NSTextStorage processEditing] + 458 11 UIFoundation 0x08d9dcfd -[NSTextStorage edited:range:changeInLength:] + 353 12 UIFoundation 0x08d9d2e8 -[NSConcreteNotifyingMutableAttributedString edited:range:changeInLength:] + 73 13 Foundation 0x005652bb -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 441 14 UIFoundation 0x08d9ff55 -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 95 15 Foundation 0x005ab60d -[NSMutableAttributedString setAttributedString:] + 91 16 zhuanla 0x0014807d -[RCTText setAttributedText:] + 109 17 zhuanla 0x0014724f __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke_2 + 191 18 zhuanla 0x000dd4dd __45-[RCTSparseArray enumerateObjectsUsingBlock:]_block_invoke + 141 19 CoreFoundation 0x013ea93a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106 20 CoreFoundation 0x013ea83c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204 21 CoreFoundation 0x013e1e95 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53 22 zhuanla 0x000dd410 -[RCTSparseArray enumerateObjectsUsingBlock:] + 400 23 zhuanla 0x0014713f __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke + 207 24 zhuanla 0x0014754b __55-[RCTTextManager uiBlockToAmendWithShadowViewRegistry:]_block_invoke137 + 427 25 zhuanla 0x0010d7c0 __27-[RCTUIManager addUIBlock:]_block_invoke + 112 26 zhuanla 0x00116b4f __29-[RCTUIManager flushUIBlocks]_block_invoke + 335 27 libdispatch.dylib 0x041635ea _dispatch_call_block_and_release + 15 28 libdispatch.dylib 0x04185bef _dispatch_client_callout + 14 29 libdispatch.dylib 0x0416b6bb _dispatch_main_queue_callback_4CF + 993 30 CoreFoundation 0x0141413e CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 14 31 CoreFoundation 0x013d2f10 __CFRunLoopRun + 2256 32 CoreFoundation 0x013d237b CFRunLoopRunSpecific + 443 33 CoreFoundation 0x013d21ab CFRunLoopRunInMode + 123 34 GraphicsServices 0x04b792c1 GSEventRunModal + 192 35 GraphicsServices 0x04b790fe GSEventRun + 104 36 UIKit 0x02dbe9b6 UIApplicationMain + 1526 37 zhuanla 0x0007c4ed main + 141 38 libdyld.dylib 0x041b1ac9 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

magicismight avatar Apr 09 '15 00:04 magicismight

@nicklockwood

sahrens avatar Apr 09 '15 07:04 sahrens

Ah, @a2 is already on it.

sahrens avatar Apr 09 '15 07:04 sahrens

+1. Got the same issue _NSBlockNumberForIndex on click the cell in demo project.

SoulArsenic avatar Apr 09 '15 08:04 SoulArsenic

See #749.

a2 avatar Apr 09 '15 13:04 a2