# UI debugging tips

For general debugging info see the
[Fuchsia Debugging Workflow](https://fuchsia.dev/docs/development/debugging/debugging).

## Capture the Screen

### Take a Screenshot

A screenshot takes a screenshot of what is currently displayed on the Fuchsia
device's screen. It returns a 2D buffer.

From the Fuchsia device console, run:

    screencap /tmp/filename.ppm

From your host workstation, run:

    fx scp [$(fx get-device-addr)]:/tmp/filename.ppm /tmp/filename.ppm

### Take a Scenic Snapshot

A Scenic snapshot takes a 3D representation of what is currently displayed on
the screen. It usually takes longer to capture than a screenshot, and can be
used to visualize issues with layout of 3D content.

From your host workstation, run:

    fx shell gltf_export > filename.gltf

You can upload `filename.gltf` to any gltf viewer, such as this
[online viewer](https://gltf-viewer.donmccurdy.com/).

### Dump the SceneGraph as Text

The [SceneGraph](https://fuchsia.dev/docs/concepts/ui/scenic#scenic-resource-graph)
as text is useful when you want to see all the resources, including non-visible
elements such as transform matrices.

#### Dump the SceneGraph in Fuchsia snapshot

A Fuchsia snapshot contains the SceneGraph that is rendered to the screen.
Capture it from your host workstation using the following commands:

    fx snapshot

    unzip <snapshot output file>

Then, look for Scenic's info in the inspect file:

    less inspect.json

#### Dump the SceneGraph and all Scenic resources

To capture all the resources created, including those that are not currently
attached to the main SceneGraph, you can use `dump-scenes`. From your host
workstation, run the following command:

    ffx component explore /core/ui/scenic -c "cat out/debug/dump-scenes"

[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/development/debugging/ui_tips.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/development/debugging/ui_tips.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/development/debugging/ui_tips.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/development/debugging/ui_tips.md "Edit the source code of this page")