facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.3k stars 24.35k forks source link

[Touchable* + Text] "Touchable cannot transition" error about 20% of the time #1693

Closed uoroaix closed 1 month ago

uoroaix commented 9 years ago

Hi I am not really sure if this is an issue or not, but I thought i posted here so if anyone have the same problem, they know what was going on.

Apparently if you render some touchablebutton to be like this

render: function() {
   return (
     <View style={styles.contentContainer}>
       <TouchableOpacity onPress={this._onPressQRCode}>
         <Text style={styles.scanButtonText}>Click To Start Scanning</Text>
       </TouchableOpacity>
     </View>
   );
 },

you will run into this error very frequently

Error: Touchable cannot transition from `RESPONDER_INACTIVE_PRESS_IN` to `LONG_PRESS_DETECTED` for responder `.r[1]{TOP_LEVEL}[0].0.0.$nav2.0.1`
 stack: 
  TouchableMixin._receiveSignal                               index.ios.bundle:33197
  TouchableMixin._handleLongDelay                             index.ios.bundle:33176
  JSTimers.setTimeout.JSTimersExecution.callbacks.(anonymous  index.ios.bundle:8273
  JSTimersExecution.callTimer                                 index.ios.bundle:8062
  Object.JSTimersExecution.callTimers                         index.ios.bundle:8085
  jsCall                                                      index.ios.bundle:7511
  MessageQueueMixin._callFunction                             index.ios.bundle:7774
  <unknown>                                                   index.ios.bundle:7801
 URL: undefined
 line: undefined
 message: Touchable cannot transition from `RESPONDER_INACTIVE_PRESS_IN` to `LONG_PRESS_DETECTED` for responder `.r[1]{TOP_LEVEL}[0].0.0.$nav2.0.1`

To solve the problem just wrap the text inside the touchableopacity/touchablehighlight with a child view like this

render: function() {
   return (
     <View style={styles.contentContainer}>
       <TouchableOpacity onPress={this._onPressQRCode}>
         <View>
           <Text style={styles.scanButtonText}>Click To Start Scanning</Text>
         </View>
       </TouchableOpacity>
     </View>
   ); 

and seems to not run into that error anymore.

arypurnomoz commented 9 years ago

+1

gkrimer commented 9 years ago

This happens for me with regularity but only when running on the device and debugging in Chrome. If I run on the device without debugging this error does not occur. Anyone seeing the same behavior?

brentvatne commented 9 years ago

@spicyj - assigned you because it seems related to responders :smile:

sophiebits commented 9 years ago

I don't actually know anything about this stuff… maybe @vjeux does.

philharton commented 9 years ago

I've been getting the same error with a TouchableHighlight wrapping an Image, so it doesn't seem related to Text. I've only seen this while debugging in Chrome thus far but will update if that changes.

piyushchauhan2011 commented 9 years ago

It is same when i'm wrapping the <Icon /> from react-native-icons. I'm really stressed out with the production app we are building and the error keeps coming up :cry:

piyushchauhan2011 commented 9 years ago

@brentvatne @vjeux @spicyj The same error comes up when we try to use inspect element mode. It seems the elements there are also TouchableHighlight and when we press on one of them in random order the same error comes up. So I think this is really an issue needs to be handled immediately.

piyushchauhan2011 commented 9 years ago

??

palmovitsch commented 9 years ago

I had the same issue with Image surrounded by TouchableHighlight. Also just coming up on a real device while debugging in Chrome. Thanks uoroaix. Surrounding the Image with View solved the problem.

ilansas commented 9 years ago

Do we have an official fix or explanation ? This error is so annoying !

aleclarson commented 9 years ago

Any update on this, @vjeux? The error message is cryptic and the stack trace is useless to us.

piyushchauhan2011 commented 9 years ago

:+1:

vjeux commented 9 years ago

No update sorry, if anyone of you can investigate what is happening and figure out if you can make a fix that would be awesome!

deanmcpherson commented 9 years ago

For reference, I was seeing a heap of these warnings, and it turned out I had removed the LaunchScreen from the project (also fixed #2018 for me). No idea why the LaunchScreen would be so important, but it fixed if for me.

satya164 commented 9 years ago

Also happening on Android, real device.

ghost commented 9 years ago

Seeing this too on Nexus 6 + Chromium debugging. App is just a very simple test of Navigator, and it works without debugging, though route transitions are sluggish. As soon as I debug it, I get a red screen of death with the above message.

satya164 commented 9 years ago

@RoryHunter Check https://facebook.github.io/react-native/docs/performance.html#slow-navigator-transitions for the transitions issue

kanerogers commented 9 years ago

Encountered this same issue:

Only started happening to me this morning, but went through the following steps to resolve it:

  1. Wrapping text in a view (as mentioned above) - no success.
  2. Checking out to an earlier revision - no success.
  3. Cleaning project, quitting XCode, Chrome, etc - no success.
  4. Restarted device, re-opened app with inspector enabled - no success.
  5. Disabled inspector after restart - issue resolved.

Given that the restart and some further fiddling resolved the issue, could this be memory related?

Here's further details:

Stack Trace

Error: Touchable cannot transition from `RESPONDER_INACTIVE_PRESS_IN` to `LONG_PRESS_DETECTED` for responder `.r[1]{TOP_LEVEL}[0].2.1.0.1.0`
 stack: 
  TouchableMixin._receiveSignal           index.ios.bundle?…:41098
  TouchableMixin._handleLongDelay         index.ios.bundle?…:41077
  JSTimersExecution.callbacks.(anonymous  index.ios.bundle?…:6158
  JSTimersExecution.callTimer             index.ios.bundle?…:5942
  Object.JSTimersExecution.callTimers     index.ios.bundle?…:5965
  MessageQueue.__callFunction             index.ios.bundle?…:5574
  <unknown>                               index.ios.bundle?…:5512
  guard                                   index.ios.bundle?…:5467
  <unknown>                               index.ios.bundle?…:5512
 URL: undefined
 line: undefined
 message: Touchable cannot transition from `RESPONDER_INACTIVE_PRESS_IN` to `LONG_PRESS_DETECTED` for responder `.r[1]{TOP_LEVEL}[0].2.1.0.1.0`

Component source:

      <TouchableHighlight
        style={styles.container}
        underlayColor='#eee'
        onPress={this.props.handler}>

        <View style={styles.container}>
          <View style={styles.label}>
            <Text style={styles.labelText}>{this.props.label}</Text>
          </View>
          <View style={styles.icon}>
            <Icon name={this.props.icon} size={60} color="green" />
          </View>
        </View>

      </TouchableHighlight>

Inspector screenshot:

img_7911

Hope any of this helps!

JAStanton commented 9 years ago

+1 I have been getting this a lot lately.

piyushchauhan2011 commented 9 years ago

:+1: same here

theopolisme commented 9 years ago

:+1: have been encountering repeatedly.

abbothzhang commented 9 years ago

qq20151028-0 2x

when TouchableOpacity wraped by ScrollView,it occured still

brancusi commented 9 years ago

Not sure what changed, getting this on almost every press now. Not using ScrollView. Only happens when using chrome debug. Pretty much have to disable chrome debug now which is a big pain.

Hope there is a solution for this soon.

yychun1217 commented 8 years ago

Encountered this error as well, TextInput inside ScrollView on iOS

piyushchauhan2011 commented 8 years ago

:+1: repeated encounters

Thomas101 commented 8 years ago

Hey,

I've been doing some digging on this issue. Found out that it's because of a bug with setTimeout. When using chrome debugging they can fire in the incorrect order. (See dedicated issue and example in #4470).

What happens with this one is in the function touchableHandleResponderGrant in Components/Touchable/Touchable.js you setup two setTimeouts and when they fire in the incorrect order the touch responder graph drops out to an error state which causes the red screen of death.

I've got very much a 'paint over the cracks' fix, which most probably has unforeseen side-effects but will at least enable you to debug in chrome again. I definitely remove this before deploying to production In Components/Touchable/Touchable.js change...

RESPONDER_INACTIVE_PRESS_IN: {
    DELAY: States.RESPONDER_ACTIVE_PRESS_IN,
    RESPONDER_GRANT: States.ERROR,
    RESPONDER_RELEASE: States.NOT_RESPONDER,
    RESPONDER_TERMINATED: States.NOT_RESPONDER,
    ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN,
    LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT,
    LONG_PRESS_DETECTED: States.ERROR,
  },

to be

RESPONDER_INACTIVE_PRESS_IN: {
    DELAY: States.RESPONDER_ACTIVE_PRESS_IN,
    RESPONDER_GRANT: States.ERROR,
    RESPONDER_RELEASE: States.NOT_RESPONDER,
    RESPONDER_TERMINATED: States.NOT_RESPONDER,
    ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN,
    LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT,
    LONG_PRESS_DETECTED: States.RESPONDER_ACTIVE_LONG_PRESS_IN,//States.ERROR,
  },

Again I definitely remove this before deploying to production

kanerogers commented 8 years ago

Awesome find!! On Wed, 2 Dec 2015 at 1:06 AM, Thomas Beverley notifications@github.com wrote:

Hey,

I've been doing some digging on this issue. Found out that it's because of a bug with setTimeout. When using chrome debugging they can fire in the incorrect order. (See dedicated issue and example in #4470 https://github.com/facebook/react-native/issues/4470).

What happens with this one is in the function touchableHandleResponderGrant in Components/Touchable/Touchable.js you setup two setTimeouts and when they fire in the incorrect order the touch responder graph drops out to an error state which causes the red screen of death.

I've got very much a 'paint over the cracks' fix, which most probably has unforeseen side-effects but will at least enable you to debug in chrome again. I definitely remove this before deploying to production In Components/Touchable/Touchable.js change...

RESPONDER_INACTIVE_PRESS_IN: { DELAY: States.RESPONDER_ACTIVE_PRESS_IN, RESPONDER_GRANT: States.ERROR, RESPONDER_RELEASE: States.NOT_RESPONDER, RESPONDER_TERMINATED: States.NOT_RESPONDER, ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN, LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT, LONG_PRESS_DETECTED: States.ERROR, },

to be

RESPONDER_INACTIVE_PRESS_IN: { DELAY: States.RESPONDER_ACTIVE_PRESS_IN, RESPONDER_GRANT: States.ERROR, RESPONDER_RELEASE: States.NOT_RESPONDER, RESPONDER_TERMINATED: States.NOT_RESPONDER, ENTER_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_IN, LEAVE_PRESS_RECT: States.RESPONDER_INACTIVE_PRESS_OUT, LONG_PRESS_DETECTED: States.RESPONDER_ACTIVE_LONG_PRESS_IN,//States.ERROR, },

Again I definitely remove this before deploying to production

— Reply to this email directly or view it on GitHub https://github.com/facebook/react-native/issues/1693#issuecomment-160978459 .

alubling commented 8 years ago

@Thomas101 - seriously, great job tracking this down.

PaulBGD commented 8 years ago

Go vote for this issue so that the developers can see that it's important: https://productpains.com/post/react-native/settimeout-fires-incorrectly-when-using-chrome-debug/

satya164 commented 8 years ago

Does this still happen frequently? Haven't seen this for about a month now.

marcshilling commented 8 years ago

Lots of people saying this only happens while debugging with chrome...I don't think that's the case.

I have a production iOS app on the store and get crash reports for this pretty frequently. Latest one happened today @satya164. Unfortunately it's hard to tell exactly where it's occurring from the crash report. The app is a few versions of React Native behind.

jacob-israel-turner commented 8 years ago

Getting this while building to device and debugging in Chrome. I'm on React Native 0.13.0, so this may have been resolved in more recent versions.

corbt commented 8 years ago

@satya164 since you asked if this was still an issue, I've been running into it debugging on the device with Chrome on master. I think there's some timing issue going on more generally, as I've started running into other errors as well.

mylonasg88 commented 8 years ago

Encountered same issue. Replaced TouchableHighlight with react-native-button and set my <Icon ...> in <Button ...> <Icon ... /> </Button> works like a charm. I am not an expert, perhaps the answer to this can be found in react-native-button implementation.

I hope it helps to someone!

grabbou commented 8 years ago

Can't reproduce this on master currently.

esutton commented 8 years ago

Thank you @Thomas101 !

This bug stopped me from being able to debug into UIExplorer in react-native 0.26. Now I can continue using the debugger to learn how to modify and use NavigationExperimental. Without @Thomas101 work-around this would have taken me so much longer.

stantoncbradley commented 8 years ago

my error is slightly different: Attempted to transition from stateRESPONDER_INACTIVE_PRESS_INtoRESPONDER_ACTIVE_LONG_PRESS_IN, which is not supported. This is most likely due toTouchable.longPressDelayTimeoutnot being cancelled. @Thomas101 's solution did not work for me unfortunately. Anyone else experiencing anything similar?

tslater commented 8 years ago

@stantoncbradley, I have the same issue on react-native 0.27.0. @Thomas101 , do you have any ideas on how we can workaround this one too? I'm trying different combos to no avail.

KGALLET commented 8 years ago

got the same issue

sscaff1 commented 8 years ago

Same issue here RN 0.28 Running on iPhone 6S+

Only occurs about 20% of the time.

aprct commented 8 years ago

+1

Never realized how much tapping I did until it started crashing every 3 or 4 taps.

Attempted to transition from state 'RESPONDER_INACTIVE_PRESS_IN' to 'RESPONDER_ACTIVE_LONG_PRESS_IN', which is not supported. This is most likely due to 'Touchable.longPressDelayTimeout' not being cancelled.

RN 0.26 Running on iPhone 6 with iOS version 9.2.1

aprct commented 8 years ago

We're coming close to production and there doesn't seem to be a workaround for this when deploying to a device.

@Thomas101 @satya164 Any ideas? Solution doesn't seem to work for RESPONDER_INACTIVE_PRESS_IN to RESPONDER_ACTIVE_LONG_PRESS_IN error.

:/

Thomas101 commented 8 years ago

@aprct we found it only happens when remote debugging is enabled. Doesn't seem to happen when run under production mode

aprct commented 8 years ago

@Thomas101 Sweet. Thanks for the quick reply. Fingers crossed!

liamks commented 8 years ago

I'm just confirming that this is still an issue.

yonahforst commented 8 years ago

@Thomas101 I get this when running on the device, without remote debugging enabled

npomfret commented 8 years ago

I'm getting it remote debugging on a physical iphone

afilp commented 8 years ago

Still an issue, I hope this can be solved. I get it on an Android physical device with debugging mode on (not sure if it happens on production mode).

matt-oakes commented 8 years ago

Just started getting this after upgrading to React Native 0.30 (never saw it before that). Happens on a physical Android phone (Nexus 5X) when running in chrome debug mode. As other have said, it doesn't happen on ever tap, even if pressing for a long time.

yozi-developer commented 8 years ago

@matto1990, usage the Network Time both on device and pc fixed this issue for me