React-native: App crashes when touching screen with 3 fingers on some OnePlus, Oppo, Xiaomi, Samsung devices

Created on 17 Jul 2017  路  71Comments  路  Source: facebook/react-native

Error: "Cannot record touch end without a touch start"

Environment

[skip envinfo]

Issue has been reproduced as far back as [email protected], and up through [email protected].

Steps to Reproduce

  1. Use "One Plus 2" phone
  2. Open React Native 0.45.1 app
  3. Use three-finger screenshot gesture

Expected Behavior

App does not crash

Actual Behavior

Red screen error

error screenshot

Reproducible Demo

Any project on this phone with this gesture

Known Affected Devices

OnePlus:

Oppo:

Samsung:

Wiko:

Xiaomi:

Bug Good first issue Help Wanted Partner Android Ran Commands Expo 馃摦Known Issues

Most helpful comment

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

All 71 comments

how can we fix this problem, i meet this problem too

i got the same problem on android with a wiko pure.
any solution ?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

Happening to me too, captured by Sentry's RN logging

I got the same problem.

any solution for this problem??? i got the same problem with CRNA application, my application crash when try to take a screen shot wit 3 fingersgesture...

I have this issue on a OnePlus 3

This is happening more and more frequently. Here's a couple of stack traces:

https://sentry.io/share/issue/be6ff067877948cb9f68d1ef66c7082b/
https://sentry.io/share/issue/6ff3cd627faf4ccf80589c8cfed780b7/

The error appears to be happening in Libraries/Renderer/src/renderers/shared/shared/event/eventPlugins/ResponderTouchHistoryStore.js around line 203.

Here are devices we are seeing:

  • Samsung SM-G955U (NRD90M) on Android 7.0
  • OnePlus ONEPLUS A3000 (OPR6.170623.013) on Android 8.0.0
  • Samsung SM-G925I (NRD90M) on Android 7.0
  • Xiaomi Redmi 4X (N2G47H) on Android 7.1.2
  • Xiaomi Redmi Note 3 (MMB29M) on Android 6.0.1
  • OPPO F1f on Android 5.1.1
  • OPPO A1601 (LMY47I) on Android 5.1
  • OPPO A1603 (LMY47I) on Android 5.1
  • OPPO 1201 (LMY47I) on Android 5.1

The issue also persists on One Plus 5 phone (A5000, Android 7.1.1).

See issue -> https://github.com/expo/expo/issues/1223

The issue also persists on One Plus 3T phone

This file is no longer (as of 3 days ago?) in React Native master. There seems to have been a major reorg due to React 0.16/Fiber(?) and the code for ResponderTouchHistoryStore is now in https://github.com/facebook/react-native/blob/13829751b11330f8e1400c5c70c59c49ac2f091f/Libraries/Renderer/ReactNativeRenderer-prod.js

We haven't tested yet to see if the behavior is different, but any patches would definitely have a new target.

Ok, I have the same problem so I checked it out to try to find a solution. I figured out that:

What do you think? Can that changes be proposed as a solution?

@gregoriohc in your testing, is this actually causing a crash or a failure in RN apps or is it simply that the logging is set to console.error? I was under the impression this was causing a crash in Android RN apps?

@ghidinelli It's only that logging is set to console.error, that's the reason that I'm suggesting the change only in the dev file, because when you use Expo it shows console errors on that full red screen, so you can't capture an screenshot using the three fingers gesture.
But I realize that being such a specific error (OnePlus + Expo + Three fingers gesture), it is not worth changing anything in react-native or expo to solve it.
I guess that OnePlus' owners will have to disable the three fingers screenshot gesture, or wait for OnePlus to solve the problem in OxygenOS.

@gregoriohc it isn't OnePlus only - see my list of devices we have seen this with at https://github.com/facebook/react-native/issues/15059#issuecomment-354553812. FWIW, we don't use Expo in our builds. I'm in favor of changing it from error to warn.

@brentvatne - if a PR changing the log from error to warn was submitted, would you accept?

@ghidinelli I agree with you. But changing from error to warn seems to be only a "temporary patch" because it doesn't solve the root of the problem.
Does anyone knows how Android native handles this? Does it ignores silently any touch event that doesn't follow the regular flow (start-move-end)?

At a glance, it seems like warning might be a good approach here, but as you said this seems to be a temporary patch that does not address the actual problem. You may also want to consider that warning instead of crashing might leave the response in an invalid state.

This should not crash the app, it also happens when the app lags and the user touches in the meantime.
Surely there is a way to clear the state and continue working with a warning @hramos ?

Same with OnePlus 3t oxygenOS 5.0.1, Android 8.0.0
Happens when touching a View with flexDirection: 'column'
"react-native": "~0.54.1"

import React, {Component} from 'react';
import { StyleSheet, Text, View, Image } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Image source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'}} style={{width: 193, height: 110}}/>
        <View style={{flex: 1, backgroundColor: 'red'}} >
          <Text>Another text1</Text>
        </View>
        <View style={{flex: 3, backgroundColor: 'powderblue'}} >
          <Text>Another text3</Text>
        </View>
        <View style={{flex: 2, backgroundColor: 'blue'}} >
          <Text>Another text2</Text>
        </View>
        <Text>This is text</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    flexDirection: 'column'
  }
});

The same problem on Mi.Any Solutions???!!

Happens on Oneplus 6 also.

Did anyone solved this problem

The same problem on version 0.55.2

Same issue on Oneplus 5. I think its a problem on all one plus phones.

Same issue on Xiaomi Redmi Note 5 (Global Version)
MIUI 9.6.4.0

I suppose it happens to all Xiaomi's devices

FYI: I enabled screen capture which is supported by MIUI by touching screen with 3 fingers

Thanks for letting us know which devices are affected by this. At this point, we should start talking about potential solutions. Please link back to this issue on any PR that attempts to fix this.

If you run into this issue on a device that is already covered by the comments above, don't feel pressured into commenting here.

so are we getting any solution in this issue. I am also facing same issue when developing app and testing in oneplus 5t

The same problem on version 0.57.1

0yewk

Can confirm that this also happens on a OnePlus6 running Android 9

Happens on xiaomi redmi not 5 plus Android 8 Also

Also on Oppo A73

There is no issue on simple/plain static screen. I am facing this error only on those screens where we are using thread.
`
Like do something continuously or change UI with setinterval ()
Use of setTimeout()

on these screens where i start or use thread when i take screenshot my application giving me this error.

Ended a touch event which was not which was not counted in 'trackedTouchcount'

Even I am facing the same issue while taking screenshots.
Mi note 4
Samsung note 5

This is issue is happening on the newly released OnePlus 6T as well.

Did anyone find a fix for this? I tried the above suggestions but no dice.

Samsung SM-G950U same problem, android 8.0.0.

This issue has been under discussion for more than a year... Did anyone find a fix? please share thanks.

I found on another thread that this only happens in development mode 馃Can anyone confirm? I will test it out myself when I have time.

@rasmuswoelk Yes for me the error does not occur when using a production build

Can someone summarize the solution about this?

Some on one plus 5

Hey folks, thanks for chiming in with information about the devices you are seeing this on. I've edited the original post with a list of known affected devices. I think it's safe to say this affects several devices from manufacturers such as OnePlus, Xiaomi, Oppo, and Samsung. At this point, adding a comment mentioning this can be reproduced on a device covered above is of diminishing returns.

Following up on my earlier comment, please limit comments to any efforts to fix the underlying issue. Otherwise, we may find the need to limit comments to collaborators. Thanks for your understanding.

I can verify that the production build of my Expo app (which of course relies on React Native) does not encounter this sort of issue On my OnePlus 5, or if it does it's silent and the screenshot is captured successfully.

In development mode however, I get an error identical to the issue reported in this thread.

My device is running Android v8.1 (Oxygen OS v5.1.7)

Hey guys, having same problem on One Plus 6, any fix ?

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

It does works. Thank you.

Maybe will be useful for someone - this issue can be fixed/hidden for release builds by adding transform-remove-console babel plugin
https://facebook.github.io/react-native/docs/performance#using-consolelog-statements

@brentvatne console.reportErrorsAsExceptions = false; this worked for me!

Seeing this as well on Samsung SM-G950U Android 9.0 using pinch to zoom. I've turned off the console logs as mentioned in earlier posts.

I get this in an image gallery component I've made using react-native-image-view. It doesn't appear to crash the app now that I've turned the console logs off but pinch to zoom stops working until I open a new image.

Are there any implications to adding console.reportErrorsAsExceptions = false;? Would this result in some other exceptions not getting reported that should be?

Same problem in Redmi note 7, android 9.0.0.

two years and any solution?

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

working for oneplus 7 pro thanks mate

I've been looking at this on my Oneplus 6. If three finger screenshots are enabled, Android is firing two touchstart events, then a touchcancel with three touches. I can see in logcat that it gives the error D/ViewRootImpl: Gesture Screenshot triggered, ignore event. This is clearly a bug in the OS. It's worth noting that Flutter has run into the same bug: https://github.com/flutter/flutter/issues/20517

I would suggest that the best approach here is to be more forgiving on these kind of touchcancel events. Is there a reason we have to throw an error? It isn't something that the developer can do anything with. I'd argue that particularly with touchcancel events, we should silently ignore if it tries to cancel an unknown touch. Even if we restrict it to cases where there are more than two touches it would solve this. If it's agreed that we should do this, I'm happy to do a PR to fix it.

I think the simplest solution here would be to change this to a console.warn, to match other similar touch event errors. The core problem is that the OS is only sending two touchStart events if TFS is enabled. We can't get around this.

I'm going to be bold and open a PR to do this. The main drawback here is that it's still going to give warnings for what is an OS bug, so we could consider ignoring it silently if it's a touchCancel event. I could add this if there's an agreement that this is the best approach. I don't think there's a problem using a "temporary fix" like this when the underlying problem is an OS bug that we can't fix.

I completely agree with you but I'm afraid not everyone does so. I sincerely hope your pr makes it through!

perhaps some kind of state needs to be cleared when this happens to prevent further instability.

https://github.com/facebook/react-native/issues/15059#issuecomment-370523450

At a glance, it seems like warning might be a good approach here, but as you said this seems to be a temporary patch that does not address the actual problem. You may also want to consider that warning instead of crashing might leave the response in an invalid state.

@ThaJay I hope so too. The problem here is that this is an OS bug. We can't do anything except work around it. Even if there were a fix available for the underlying bug, we'd still need to be able to handle cases where the fix wasn't applied. In any case, this is currently the only touch error that gets a console.error rather than a console.warn, and there doesn't seem to be any logic behind this.

I think we're ok without clearing state. By its nature, this error only happens when all of the touches have been ended. The whole problem is that we don't have any more touches to cancel.

this worked for me console.reportErrorsAsExceptions = false. I have written in root file that is in index.js file

@vikassahutech
Obviously that works but it's not a fix. That setting will suppress all other exceptions as well. This is why I will not use this proposed solution and I hope others will not put it in production either.

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

Its work well

Put this in app.js or root file of your app.
console.reportErrorsAsExceptions = false;

Would this result in some other exceptions not getting reported that should be?

The fix for this has now been merged into React, so hopefully we can close this soon.

hei锛実uys, you also can report errors to sentry

console.error = data => { Sentry.captureException(new Error(data), { logger: "console.error" }); };

@ascorbic can you add a link to PR with this fix?

@AleksandrZhukov It's the one referenced just above: https://github.com/facebook/react/pull/16750

This issue can be closed now. I am getting no crash when I am touching screen with 3 fingers in OnePlus device. I am using RN version 0.61.4

The problem still persists for me in RN version 0.61.4.

hello everyone , can any have any update on this issues, i tried everything still getting crashed in released mode

hello everyone , can any have any update on this issues, i tried everything still getting crashed in released mode

console.reportErrorsAsExceptions = false; is the only solution right now, but if exists another problem/error it's not show up.

The same problem in MI 8 Lite, android 9 PKQ. Any solution?

Happening in Redmi Note 8.

Was this page helpful?
0 / 5 - 0 ratings