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

[Only in Android] setAccessibilityFocus app crash #22807

Closed
3 tasks done
raj-badri opened this issue Dec 27, 2018 · 6 comments
Closed
3 tasks done

[Only in Android] setAccessibilityFocus app crash #22807

raj-badri opened this issue Dec 27, 2018 · 6 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@raj-badri
Copy link

raj-badri commented Dec 27, 2018

Environment

React Native Environment Info:
System:
OS: macOS 10.14
CPU: (4) x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
Memory: 129.71 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.3.2 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.0, 26.0.3, 27.0.3, 28.0.3
System Images: android-23 | Google APIs Intel x86 Atom_64, android-25 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ^16.6.1 => 16.7.0
react-native: ^0.57.5 => 0.57.8
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-create-library: 3.0.2
react-native-git-upgrade: 0.2.7

Description

Android app crashes while using setAccessibilityFocus.

const reactTag = findNodeHandle(ref); AccessibilityInfo.setAccessibilityFocus(reactTag);

Error:
E/unknown:ReactNative: Exception in native call com.facebook.react.bridge.JSApplicationIllegalArgumentException: Could not find view with tag 1135 at com.facebook.react.uimanager.NativeViewHierarchyManager.sendAccessibilityEvent(NativeViewHierarchyManager.java:843) at com.facebook.react.uimanager.UIViewOperationQueue$SendAccessibilityEvent.execute(UIViewOperationQueue.java:582) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:894) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1001) at com.facebook.react.uimanager.UIViewOperationQueue.access$2400(UIViewOperationQueue.java:46) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1061) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:134) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:105)

screen shot 2018-12-26 at 10 50 40 pm

@react-native-bot react-native-bot added the Platform: Android Android applications. label Dec 27, 2018
@bartolkaruza
Copy link

Can you post a demo which includes the part where you are getting a ref from a view?

@joseygordev
Copy link

Any update ?

@draperunner
Copy link
Contributor

It would at least be good to be able to catch the error. The following does not work, and will crash the app:

try {
    const reactTag = findNodeHandle(ref)
    AccessibilityInfo.setAccessibilityFocus(reactTag)
} catch (e) {
    // do nothing
}

@estevaolucas
Copy link

I was not able to catch this error while passing a valid reactTag, so I don't think it's as a bug.

But I do agree it could be improved to be able to catch those errors with a Promise reject.

4 different methods in NativeViewHierarchyManager.java just throw an error when a reactTag is not found in the tree.

if (view == null) {
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + tag);
}

@Titozzz
Copy link
Collaborator

Titozzz commented Mar 19, 2019

I believe the issue came from an invalid reactTag, so I'll close it. I do think it would be bad if your code had this issue so throwing might not be such a bad thing? Feel free to PR if you want to make it better 👍

@Belobobr
Copy link

Belobobr commented May 27, 2019

I've fixed it by adding <View accessible={true} />. I think react-native should provide some description for common sources of such errors. "Could not find view with tag" useless for me. This is not user friendly.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants