From 595b569eadbdfc57778caf055172fb20c6f9814d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 22 Jan 2021 19:29:00 -0800 Subject: [PATCH] Fix EventEmitter crash for events that are sent to a stopped surface Summary: In SurfaceMountingManager/MountingManager/FabricUIManager infra, we try to blackhole events that are sent to a stopped surface. In this case I just forgot to add a null check. Add here to protect against events sent to stopped surfaces - for example, if a TextInput is focused when the surface is stopped, a "blur" event will be sent and will crash here otherwise. Now it blackholes silently, as expected. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26031260 fbshipit-source-id: 9936466ca2d00267efaf7fa594c9bcd59f7aad2a --- .../facebook/react/fabric/mounting/SurfaceMountingManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 1b73122f8cb..3cbc20118e0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -766,6 +766,9 @@ public class SurfaceMountingManager { } private @Nullable ViewState getNullableViewState(int tag) { + if (mTagToViewState == null) { + return null; + } return mTagToViewState.get(tag); }