Skip to content

Commit ea7c9f2

Browse files
ryancatfacebook-github-bot
authored andcommitted
Fix edge case when we enqueue a pending event to views on stopped surface
Summary: This diff address an edge case when the pending events are enqueued when the surface is stopped. In this case we will reset map that holds view state to null, which will cause NPE. Changelog: [Android][Fixed] - Fix edge case when we enqueue a pending event to views on stopped surface Reviewed By: javache, gorodscy Differential Revision: D36912786 fbshipit-source-id: 3ae5a4b08a0a6bf55538d69ac80a101c2c3d899a
1 parent 8a2be3e commit ea7c9f2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,12 @@ public void printSurfaceState() {
10921092
public void enqueuePendingEvent(int reactTag, ViewEvent viewEvent) {
10931093
UiThreadUtil.assertOnUiThread();
10941094

1095+
// When the surface stopped we will reset the view state map. We are not going to enqueue
1096+
// pending events as they are not expected to be dispatched anyways.
1097+
if (mTagToViewState == null) {
1098+
return;
1099+
}
1100+
10951101
ViewState viewState = mTagToViewState.get(reactTag);
10961102
if (viewState == null) {
10971103
// Cannot queue event without view state. Do nothing here.

0 commit comments

Comments
 (0)