Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log a soft exception from accessibility event exceptions (facebook#37002
) Summary: This PR attempts to solve [this issue](facebook#33021) I created last year, where accessibility events can fire after a view has been unmounted, causing the entire application to crash. This newly added try/catch block is modeled and copies verbiage exactly from the Fabric implementation of accessibility events [here](https://github.com/facebook/react-native/blob/2d9c81780c2bb3c2c2dc8875147261c9a1843eb4/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/SendAccessibilityEventMountItem.java#L30-L43) and [here](https://github.com/facebook/react-native/blob/2d9c81780c2bb3c2c2dc8875147261c9a1843eb4/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/SendAccessibilityEventMountItem.java#L30-L43). ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Fixed an issue where calling `Accessibility.setAccessibilityFocus` on an unmounted component would crash Pull Request resolved: facebook#37002 Test Plan: 1. I reimplemented the crash demo from the Snack showcased in [this issue](facebook#33021). I created the branch [here](https://github.com/Abbondanzo/react-native/pull/1/files), although I may archive or delete this repo in the future so the link is not permanent 1. I disabled the new Fabric architecture. This crash only occurs in the old architecture 1. I pressed the button that would set accessibility focus on an unmounted component, and it logs a soft exception as seen in the screenshot below. I've also attached a screenshot from an identical soft exception that already gets logged by Fabric 1. In both cases, the app continues to function as expected |Example SoftException from this change|Example SoftException from Fabric (no changes to this code)| |-|-| |![image](https://user-images.githubusercontent.com/10366495/233423632-9eaa7c06-90a0-4e5c-ad65-5cc98ea52dc6.png)|![image](https://user-images.githubusercontent.com/10366495/233423233-f8f0bdb4-7f90-44f8-92aa-27992f60ccf3.png)| Reviewed By: cipolleschi Differential Revision: D49270491 Pulled By: cortinico fbshipit-source-id: a489f160be44d78afb751527f70aa88e8a463ee0
- Loading branch information