Skip to content

Commit

Permalink
Fix edge case when we enqueue a pending event to views on stopped sur…
Browse files Browse the repository at this point in the history
…face

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
  • Loading branch information
ryancat authored and facebook-github-bot committed Jun 6, 2022
1 parent 8a2be3e commit ea7c9f2
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,12 @@ public void printSurfaceState() {
public void enqueuePendingEvent(int reactTag, ViewEvent viewEvent) {
UiThreadUtil.assertOnUiThread();

// When the surface stopped we will reset the view state map. We are not going to enqueue
// pending events as they are not expected to be dispatched anyways.
if (mTagToViewState == null) {
return;
}

ViewState viewState = mTagToViewState.get(reactTag);
if (viewState == null) {
// Cannot queue event without view state. Do nothing here.
Expand Down

0 comments on commit ea7c9f2

Please sign in to comment.