Skip to content

Commit

Permalink
Guard against null rootShadowNode in IntersectionObserverManager for …
Browse files Browse the repository at this point in the history
…initial notifications (facebook#44528)

Summary:

Changelog: [internal]

In the `IntersectionObserver` API we dispatch the initial notification in the `observe` method, but it might be possible that the surface has been removed from the registry by the time we execute that code.

This guards against that case to possibly fix a crash we're seeing in on the `IntersectionObserver` experiments.

Reviewed By: sammy-SC

Differential Revision: D57213994
  • Loading branch information
rubennorte authored and facebook-github-bot committed May 10, 2024
1 parent 143e310 commit 7f96234
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void IntersectionObserverManager::observe(
mountingCoordinator = shadowTree.getMountingCoordinator();
rootShadowNode = shadowTree.getCurrentRevision().rootShadowNode;
});

// If the surface doesn't exist for some reason, we skip initial notification.
if (!rootShadowNode) {
return;
}

auto hasPendingTransactions = mountingCoordinator != nullptr &&
mountingCoordinator->hasPendingTransactions();

Expand Down

0 comments on commit 7f96234

Please sign in to comment.