From 62e59809548034611fdce387e5b72d6bc6b9e6ea Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 25 Jan 2024 16:56:49 -0800 Subject: [PATCH] Fix UIManagerBinding's findNodeAtPoint (#42439) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42439 UIManagerBinding's findNodeAtPoint assumes that UIManager::findNodeAtPoint returns non-null pointers. But, this is false! See [LayoutableShadowNode::findNodeAtPoint](https://github.com/facebook/react-native/blob/fd0ca4dd6209d79ac8c93dbffac2e3dca1caeadc/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp#L333-L354): https://www.internalfb.com/code/fbsource/[7169da7945c813b35cd0a4fa15e66969c90c2481]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp?lines=333%2C354 Changelog: [General][Fixed] Fix UIManagerBinding's findNodeAtPoint Reviewed By: cortinico, sammy-SC Differential Revision: D52909512 fbshipit-source-id: e1da112d4f8dcf4cdc037c978d84751eb8cf6695 --- .../react/renderer/uimanager/UIManagerBinding.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 77fac8ee516afa..90c01c772ada05 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -326,6 +326,12 @@ jsi::Value UIManagerBinding::get( arguments[3].getObject(runtime).getFunction(runtime); auto targetNode = uiManager->findNodeAtPoint(node, Point{locationX, locationY}); + + if (!targetNode) { + onSuccessFunction.call(runtime, jsi::Value::null()); + return jsi::Value::undefined(); + } + auto& eventTarget = targetNode->getEventEmitter()->eventTarget_; EventEmitter::DispatchMutex().lock();