JPEG Screenshots

Configure React Native session JPEG capture and manual native frame capture.

React Native uses the native iOS and Android screenshot capture implementations.

Important: Screen capture will result in an FPS drop while native frames are captured, encoded, and transported. Use conservative interval, quality, and max-width settings, and disable sessionJpegCapture for trend-focused runs unless visual evidence is required.

Session Capture

Native all-in-one defaults enable JPEG capture every 2000 ms, quality 60, max width 480.

await Ansight.initializeAndActivate({
  sessionJpegCapture: {
    intervalMilliseconds: 2000,
    quality: 60,
    maxWidth: 480,
    captureGpuBackedSurfaces: true,
    mode: "screenshotAndVisualTree",
    captureKeyboardPresence: true,
  },
});

Visual-Tree and Keyboard Metadata

mode accepts:

  • "screenshotOnly", the default, sends frames without an SDK visual-tree snapshot.
  • "screenshotAndVisualTree" captures registered native or framework visual-tree sources with each app-owned screenshot and correlates them through the screenshot timestamp.
  • "screenshotWithVisualTreeOnTouch" captures visual trees on touch down and touch up rather than for every frame. Move and cancel events do not trigger a tree.

Tree capture requires a registered visual-tree provider. Touch-triggered mode also requires touch capture. Visual trees use the compact v2 contract.

captureKeyboardPresence defaults to false and records only whether the native on-screen keyboard was present. It does not capture contents or dimensions and remains useful when the host owns simulator/emulator screenshots.

Disable periodic capture:

await Ansight.initializeAndActivate({
  sessionJpegCapture: false,
});

Simulator and Emulator Capture Ownership

React Native inherits screenshot-control version 1 from its native runtime. The resident host can select host capture for an iOS Simulator or Android emulator, optionally identifying simctl or adb as the source.

In host mode, the native SDK suspends its periodic in-app JPEG loop for that live session. A missing host response or app mode keeps the configured sessionJpegCapture behavior. The negotiation is automatic and does not affect manual capture or ui.get_screenshot.

Manual Frame Capture

const result = await Ansight.captureScreenFrame({
  quality: 60,
  maxWidth: 480,
  captureGpuBackedSurfaces: true,
});

A connected live session is required.

On iOS, captureGpuBackedSurfaces defaults to true so Metal, SceneKit, and similar GPU-backed views are included. Set it to false to use a lower-overhead capture path when those surfaces are not needed. Android accepts the same option for cross-platform configuration parity.

On-Demand Tool

Register native VisualTree tools with withVisualTreeTools() to expose ui.get_screenshot. Screenshot bytes are delivered over the Ansight binary transfer protocol during live tool calls.