Skip to content

Integrate Vulkan Screenshot Layer with Perfetto#11

Merged
m--koma merged 23 commits intoandroid-graphics:mainfrom
m--koma:perfetto_screenshot_clean
Apr 17, 2026
Merged

Integrate Vulkan Screenshot Layer with Perfetto#11
m--koma merged 23 commits intoandroid-graphics:mainfrom
m--koma:perfetto_screenshot_clean

Conversation

@m--koma
Copy link
Copy Markdown

@m--koma m--koma commented Apr 16, 2026

This PR integrates the Vulkan screenshot layer with the Perfetto SDK, allowing screenshots to be emitted directly into Perfetto traces.

Key changes:

  • Perfetto SDK Update: Updated perfetto.cc and perfetto.h to include changes from PR #5348, which adds .pam and .ppm data formats. This was from a local fetch of Perfetto as this change has not been released yet.
  • Code Formatting: Ran clang-format on screenshot.cpp to align with project style guidelines.
  • Perfetto Integration: Refactored image writing logic to support streaming to both files and Perfetto traces. Added ScreenshotDataSource to handle emission.
  • Documentation: Added a section in screenshot_layer.md with instructions on how to build and verify this feature on Android.

Perfetto SDK update and clang are in separate commits for easier review.

Verification:

  • Verified on an Android device that both Perfetto traces and file-based screenshots work correctly.
  • Experimented with different buffer sizes and image scales: if we use 100% scale on Pixel 8, we'd need approx. 150MB buffer for screenshots. Since Sherlock uses 10% scale, a single screenshot was about 73 KB and - aligned with Emre's calculations - it doesn't look like we need a separate buffer.

@m--koma m--koma requested review from emrekultursay and olehkuznetsov and removed request for olehkuznetsov April 16, 2026 11:54
@m--koma
Copy link
Copy Markdown
Author

m--koma commented Apr 16, 2026

Looks like Perfetto upgrade breaks some of the CI checks; I'll look into it.

@m--koma m--koma force-pushed the perfetto_screenshot_clean branch 3 times, most recently from 6c08a49 to 084d9dd Compare April 16, 2026 12:56
@m--koma m--koma force-pushed the perfetto_screenshot_clean branch from 084d9dd to 269aa4c Compare April 16, 2026 13:04
@m--koma
Copy link
Copy Markdown
Author

m--koma commented Apr 16, 2026

The CI is now green on this PR. Changes to fix it are in commits 4 and 5.

Comment thread layersvt/perfetto/perfetto_helpers.cpp Outdated
Comment thread layersvt/perfetto/perfetto_helpers.h Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.h Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.h Outdated
Comment thread layersvt/CMakeLists.txt
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Copy link
Copy Markdown
Author

@m--koma m--koma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used to large reviews on Github, just saw that apparently I have 41 comment pending.

Comment thread layersvt/CMakeLists.txt
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
@m--koma m--koma requested a review from olehkuznetsov April 17, 2026 16:36
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/screenshot.cpp
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.cpp
@m--koma m--koma force-pushed the perfetto_screenshot_clean branch from 77066c7 to 8163eb0 Compare April 17, 2026 16:51
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.cpp Outdated
Comment thread layersvt/screenshot.cpp Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.cpp Outdated
Comment thread layersvt/screenshot_writer.h Outdated
Comment thread layersvt/screenshot_writer.h Outdated
@m--koma m--koma requested a review from olehkuznetsov April 17, 2026 17:07
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.h Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.h Outdated
Comment thread layersvt/screenshot.cpp Outdated
Copy link
Copy Markdown

@olehkuznetsov olehkuznetsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is mostly good from functional point of view.

Some code clean up still can be made.

Before submitting we need to verify those cases:

  1. App with layer started before perfetto
    we record two perfetto sessions while app is running
    in both perfetto files we can see screenshots.
  2. Perfetto started before app and app finishes first.
  3. Perfetto started before app and perfetto stops first.

Comment thread layersvt/perfetto/screenshots_perfetto_helpers.cpp Outdated
Comment thread layersvt/perfetto/screenshots_perfetto_helpers.cpp Outdated
@m--koma m--koma force-pushed the perfetto_screenshot_clean branch from b865a14 to 726cecc Compare April 17, 2026 17:32
@m--koma
Copy link
Copy Markdown
Author

m--koma commented Apr 17, 2026

Tested all three cases (4 traces), appear to work ok.

@m--koma m--koma merged commit 7771b8c into android-graphics:main Apr 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants