Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit e104b6f

Browse files
Michel Weststratefacebook-github-bot
Michel Weststrate
authored andcommitted
Fix NPE in ui-debugger when child isn't found
Summary: Fixes exception that happens occasionally on iOS {F1484099525} triggered here: https://www.internalfb.com/code/fbsource/[033ecc866dfb]/xplat/sonar/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx?lines=558 Working theory: activeChildIndex is out of bounds. Added error attribution to make sure it ends up in logview Reviewed By: antonk52 Differential Revision: D56011805 fbshipit-source-id: f511ff7dd22588d301427913d250fdd6cdd558ad
1 parent 0819b34 commit e104b6f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,14 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] {
562562
let children = node.children;
563563

564564
if (node.activeChildIdx != null) {
565-
children = [node.children[node.activeChildIdx]];
565+
const activeChild = node.children[node.activeChildIdx];
566+
if (activeChild == null) {
567+
console.error(
568+
`[ui-debugger] activeChildIdx not found for ${node.name}: ${node.activeChildIdx} not within ${node.children.length}`,
569+
);
570+
} else {
571+
children = [activeChild];
572+
}
566573
}
567574
const offsetMouseCoord = offsetCoordinate(mouseCoordinate, nodeBounds);
568575
let anyChildHitRecursive = false;

0 commit comments

Comments
 (0)