JPEG Screenshots

Configure periodic Android JPEG session capture and on-demand VisualTree screenshots.

Android exposes screenshots through two paths:

  • periodic session JPEG capture while a paired live session is open
  • on-demand ui.get_screenshot from the VisualTree tools

Important: Screen capture will result in an FPS drop while the SDK captures, encodes, and transports frames. Use conservative interval, quality, and max-width settings, and disable session JPEG capture for performance-focused runs unless visual evidence is required.

Session Capture

The developer preset enables JPEG capture every 2000 ms, quality 60, max width 480.

For core setup:

val options = AnsightOptions.createBuilder()
    .withSessionJpegCapture(
        intervalMilliseconds = 2000,
        quality = 60,
        maxWidth = 480,
        captureGpuBackedSurfaces = true,
    )
    .build()

Disable periodic capture:

val options = AnsightOptions.createBuilder()
    .withoutSessionJpegCapture()
    .build()

Manual Frame Capture

val result = AnsightRuntime.captureScreenFrame(
    AnsightSessionJpegCaptureOptions(
        quality = 60,
        maxWidth = 480,
        captureGpuBackedSurfaces = true,
    ),
)

A connected live session is required.

captureGpuBackedSurfaces is accepted for cross-platform configuration parity and defaults to true. The capture-mode tradeoff is currently meaningful on iOS, where setting it to false selects a lower-overhead path that may miss GPU-backed surfaces.

On-Demand Screenshot Tool

The all-in-one package registers AndroidVisualTreeTools.create(), including ui.get_screenshot.

Arguments supported by the tool include format, quality, maxWidth, and chunkBytes. Screenshot bytes are transferred over the Ansight binary transfer protocol when a live tool request is active.