Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSRange Exception with onPress on Text #756

Closed
ghost opened this issue Apr 8, 2015 · 7 comments
Closed

NSRange Exception with onPress on Text #756

ghost opened this issue Apr 8, 2015 · 7 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ghost
Copy link

ghost commented Apr 8, 2015

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
@arthuralee
Copy link
Contributor

Have a feeling it's related to #749

@brentvatne
Copy link
Collaborator

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

@magicismight
Copy link
Contributor

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

@sahrens
Copy link
Contributor

sahrens commented Apr 9, 2015

@nicklockwood

@sahrens
Copy link
Contributor

sahrens commented Apr 9, 2015

Ah, @a2 is already on it.

@a2 a2 self-assigned this Apr 9, 2015
@SoulArsenic
Copy link

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

@a2
Copy link
Contributor

a2 commented Apr 9, 2015

See #749.

@a2 a2 closed this as completed Apr 9, 2015
vjeux pushed a commit to vjeux/react-native that referenced this issue Apr 13, 2015
Summary: Fix `RCTText` crashes by wholly replacing the underlying `NSTextStorage`. This fixes GitHub issues facebook#748, facebook#749, and facebook#756.

Test Plan: There are a couple sample apps in facebook#749 that I used for testing this.
@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants