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

Commit

Permalink
Fix NPE in ui-debugger when child isn't found
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Michel Weststrate authored and facebook-github-bot committed Apr 11, 2024
1 parent 0819b34 commit e104b6f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,14 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] {
let children = node.children;

if (node.activeChildIdx != null) {
children = [node.children[node.activeChildIdx]];
const activeChild = node.children[node.activeChildIdx];
if (activeChild == null) {
console.error(
`[ui-debugger] activeChildIdx not found for ${node.name}: ${node.activeChildIdx} not within ${node.children.length}`,
);
} else {
children = [activeChild];
}
}
const offsetMouseCoord = offsetCoordinate(mouseCoordinate, nodeBounds);
let anyChildHitRecursive = false;
Expand Down

0 comments on commit e104b6f

Please sign in to comment.