Add support for capturing screenshots of multiple windows with hardware bitmap support#99
Merged
li-advait merged 2 commits intolinkedin:mainfrom Jan 12, 2026
Conversation
…re bitmap support
Issue:
- Falcon library fails when processing hardware-accelerated bitmaps
with error: Software rendering doesn't support hardware bitmaps.
- The fallback method Utils.capture() is not capable of capturing screenshots
of multiple window surfaces (dialogs, bottom sheets, Compose overlays).
Cause:
- Falcon library uses Canvas-based rendering which requires software
bitmaps, but modern Android apps use hardware-accelerated bitmaps
for performance improvement, causing screenshot capture to fail.
- The fallback approach used Utils.capture() which internally uses
PixelCopy API that supports hardware bitmaps but could only capture
the screenshot of the main activity window and not any additional
windows layered on top.
- Each window (activity, dialog, bottom sheet) has its own Surface in
Android's rendering system, requiring separate capture operations.
Fix:
- Created new MultiWindowScreenshotCapture.java utility class to handle
hardware-accelerated bitmap capture of multiple windows using PixelCopy API.
- Implemented 3-tier fallback strategy in Shaky.java:
1. Attempt Falcon library for fast Canvas-based capture (works for
traditional Views without hardware bitmaps).
2. Use PixelCopy multi-window capture when Falcon fails (handles
hardware bitmaps).
3. Fallback to Utils.capture() for main activity window only (last resort).
- Implemented getRootViews() to detect all active windows using reflection
into WindowManager internals.
- Added captureMultipleAsync() method with dual capture strategy:
- Primary: Capture from Surface (via reflection on ViewRoot's mSurface)
for per-window isolation.
- Fallback: Capture from Window object when Surface unavailable.
- Created ViewRootData class to encapsulate window hierarchy information
including view reference, window frame bounds, layout parameters,
ViewRoot object, window type detection, and window association via tokens.
- Updated CollectDataTask.java to handle multiple bitmaps where first
bitmap becomes the main screenshot for UI preview and subsequent
bitmaps are added as attachments.
advait8
approved these changes
Jan 7, 2026
li-advait
approved these changes
Jan 7, 2026
Contributor
|
@li-manssing lets add a flag and control this behavior with a flag so that other users who are relying on the existing behavior are not impacted by the additional attachments. |
Author
Sure, added a flag |
li-advait
approved these changes
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for capturing screenshots of multiple windows with hardware bitmap support
Issue:
with error:
Software rendering doesn't support hardware bitmaps.Utils.capture()is not capable of capturingscreenshots of multiple window surfaces (dialogs, bottom sheets,
Compose overlays).
Cause:
bitmaps, but modern Android apps use hardware-accelerated bitmaps
for performance improvement, causing screenshot capture to fail.
Utils.capture()which internally usesPixelCopy API that supports hardware bitmaps but could only capture
the screenshot of the main activity window and not any additional
windows layered on top (dialogs, bottom sheets, etc.).
Android's rendering system, requiring separate capture operations.
Fix:
MultiWindowScreenshotCapture.javautility class tohandle hardware-accelerated bitmap capture of multiple windows using PixelCopy API.
Shaky.java:traditional Views without hardware bitmaps).
hardware bitmaps).
Utils.capture()for main activity window only (last resort).getRootViews()to detect all active windows usingreflection into WindowManager internals.
captureMultipleAsync()method with dual capture strategy:mSurface)for per-window isolation.
ViewRootDataclass to encapsulate window hierarchy information:CollectDataTask.javato handle multiple bitmaps:Testing done
Tested locally in integrating app and verified that the changes work as expected: