« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 2182 ms

feat(core): highlight and inspect views from DevTools by edusperoni · Pull Request #11689 · NativeScript/NativeScript

Source: https://github.com/NativeScript/NativeScript/pull/11689

Repository navigation

feat(core): highlight and inspect views from DevTools - #11689


Draft
edusperoni wants to merge 4 commits into main from feat/debugger-layout-inspection
Draft

feat(core): highlight and inspect views from DevTools #11689 edusperoni wants to merge 4 commits into main from feat/debugger-layout-inspection

Conversation

edusperoni commented Nov 30, 2026 · edited Loading



Copy link Copy Markdown
Contributor

PR Checklist

What is the current behavior?

The Elements panel shows the view tree, but there is no link between it and the screen. Chrome DevTools highlights and inspects through the Overlay domain, which core doesn't implement: Overlay.enable fails, hovering a node highlights nothing, and inspect mode does nothing. DOM.getBoxModel, DOM.getNodeForLocation and DOM.pushNodesByBackendIdsToFrontend fail too, and every node reports backendNodeId: 0, so the frontend can't map a backend node to the tree.

There is also no way to get from a node in Elements to the view itself: DOM.resolveNode is a stub and $0 is always undefined.

What is the new behavior?

Highlight. Hovering a node in Elements highlights its view on the device, with margin, border, padding and content bands in the colors DevTools asks for. It clears when the pointer leaves or the view unloads.

Inspect. In inspect mode, touching the device highlights the view under the finger, and lifting it selects that view in Elements. The touch doesn't reach the app, and inspect mode ends after one pick.

Geometry for the frontend.

  • DOM.getBoxModel returns margin, border, padding and content quads in window DIPs.
  • DOM.getNodeForLocation returns the deepest visible view at a point.
  • DOM.pushNodesByBackendIdsToFrontend is implemented, and nodes now report a backendNodeId equal to their nodeId.

References to views. The runtimes serialize domain handler results to JSON, so a handler can't return a remote object. DevTools clients get the view through Runtime.evaluate instead:

  • $0 is the node selected in Elements (DOM.setInspectedNode).
  • __inspector.getViewById(nodeId) is the view behind a node id. A DevTools proxy can answer DOM.resolveNode with it.
  • __inspector.getRootView() is the app's root view, so tools such as Angular DevTools need no code in the app.

Geometry and hit testing are shared code in debugger/devtools-layout.ts. Drawing and touch interception are per platform in debugger/devtools-screen.{ios,android}.ts. Everything is loaded through inspector_modules.

Testing

  • Unit tests: core:test passes (789 passed, 1 skipped), including 11 new tests for the box decomposition, highlight bands, hit testing and view references. core:build passes.
  • iOS (iPhone 16 Pro simulator, iOS 26.3) and Android (Galaxy S20 FE, Android 13), with a Chromium 156 DevTools frontend:
    • Hovering a node draws the highlight on the device, and the bands match the view's margin, border, padding and content.
    • Tapping a view in inspect mode selects it in Elements.
    • $0 and __inspector.getViewById give the view.
  • Android only: taps 3 dp inside opposite corners of three views select the right one, a tap in inspect mode doesn't reach the app, and touches work again after a pick or a cancel.

Known limitations

  • Views inside modals don't resolve to a node, because modals aren't part of the inspected document.
  • If DevTools disconnects while inspect mode is on, the device keeps intercepting touches until the next pick or the next Overlay.enable. The debugger modules get no disconnect notification.
  • Percentage margins aren't shown on Android, because the native layout params hold their resolved value only while measuring.
  • DOM.resolveNode itself is still a stub. Answering it natively needs a runtime change (V8InspectorSession::wrapObject).
edusperoni added 2 commits November 30, 2026 10:08 feat(core): DOM box model, node-at-location and backend node ids for ... c917a78
...the inspector

Adds DOM.getBoxModel, DOM.getNodeForLocation and
DOM.pushNodesByBackendIdsToFrontend. Box quads are in window DIPs, built
from the view's location, size and effective margins, borders and
paddings. Nodes now report backendNodeId equal to nodeId so the frontend
can resolve backend ids from Overlay events and screencast inspect.
feat(core): Overlay domain with native highlight and tap-to-inspect c56ed02
Implements Overlay.enable/disable, highlightNode, highlightRect,
hideHighlight and setInspectMode, plus successful no-ops for the
setShow* family and setPausedInDebuggerMessage that the frontend sends on
attach.

Highlights draw as colored content/padding/border/margin bands above the
app: a non-interactive view on the window on iOS, the decor view's
overlay on Android. They go away on hideHighlight or when the view
unloads.

In searchForNode mode a full-window view swallows touches: dragging
highlights the view under the finger and emits
Overlay.nodeHighlightRequested; lifting emits Overlay.inspectNodeRequested
and leaves inspect mode on the device, since the frontend exits it
locally without sending mode none. Overlay.enable resets the state so a
reconnecting frontend never inherits a touch-blocking interceptor.

nx-cloud
Bot
commented Nov 30, 2026 · edited Loading



Copy link Copy Markdown

View your CI Pipeline Execution ↗ for commit 25bd9cd

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 16s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-12-01 17:22:58 UTC

pkg-pr-new
Bot
commented Nov 30, 2026 · edited Loading



Copy link Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11689
npm i https://pkg.pr.new/@nativescript/vite@11689
npm i https://pkg.pr.new/@nativescript/webpack@11689

commit: 25bd9cd

edusperoni added 2 commits December 1, 2026 14:16 feat(core): references to inspected views for DevTools clients b1438cb fix(core): include margins in the inspector's box model on Android 25bd9cd

This branch has not been deployed


No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

1 participant