Skip to content

DevTools

Debug builds of every PAM Native app include an on-device performance overlay. Use it while you interact with a screen to see what a tap, a scroll or a reload costs: how long PHP’s frame took to decode and mount, how many native nodes changed, and whether the commit was a small patch or a full tree. It is the quickest way to find an expensive path before you measure it properly.

The overlay and its receiver are not registered in release builds.

Start the app with pam dev, then toggle the overlay from another terminal:

Terminal window
pam devtools

Run the same command again to hide it. The app must be running; otherwise the command tells you to start it first.

Metric What to look for
Frame rate (smoothed) Drops while scrolling or animating point to work on the UI thread.
Decode and mount time The cost of applying PHP’s frame natively. Large values mean large patches.
Nodes and batches How many native nodes the last commit touched. A small state change should touch few nodes.
Patch vs. full commits Full commits after every change mean component identity is unstable (check keys in lists).
Native heap Memory held by the renderer. It should return to its baseline after you leave a screen.
Capability timeline The last eight events: module latency and failures, lifecycle changes, runtime errors and HTTP method, status and byte counts.

On iOS the overlay reports the same metrics, with retained renderer memory in place of the Android native heap.

  1. Find it. Toggle the overlay and repeat the slow interaction. Note the frame rate and which metric jumps.

  2. Capture it. Take a diagnostics snapshot while the app is in that state and turn it into a trace:

    Terminal window
    pam diagnostics > artifacts/snapshot.json
    pam timeline artifacts/snapshot.json --output artifacts/timeline.json
  3. Measure it. Run the repeatable Android suites on a real device:

    Terminal window
    pam benchmark # macrobenchmark of a separate, release-optimized build
    pam profile # generates a baseline profile for faster startup

    pam benchmark installs a minified benchmark build and its instrumentation, so it never measures the .debug app that pam dev installed.

  4. Fix and compare. Apply the change and run the same suite again on the same device.

Common fixes: give list rows stable keys, virtualize long lists, size images to their display size, and move work that does not need to run per render out of render(). See Performance.

Integrations can toggle the overlay without the CLI:

Terminal window
adb shell am broadcast \
-a dev.pam.nativeapp.action.TOGGLE_DEVTOOLS \
-p com.example.acme.debug

The debug package normally ends in .debug. When Firebase is enabled with a google-services.json that has no debug client, debug builds keep the base application id; pam devtools resolves the right package for you.

If you embed PAM Native in your own UIKit app, install the reusable PamDevToolsOverlay over the PAM host view and forward the runtime callbacks. The generated host already does this.

let devTools = PamDevToolsOverlay()
let runtime = PamRuntime(
hostView: hostView,
reportError: reportError,
onFrameCommitted: { [weak devTools] metrics in
devTools?.update(metrics)
},
onDiagnostic: { [weak devTools] diagnostic in
devTools?.record(diagnostic)
},
)
devTools.toggle()

Keep it out of the release view hierarchy.