Add support for capturing screenshot of multiple windows with hardware bitmap enabled #98
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 screenshot of multiple windows with hardware bitmap enabled
Issue:
error: "Software rendering doesn't support hardware bitmaps".
window surfaces (dialogs, bottom sheets, Compose overlays).
Cause:
Android uses hardware bitmaps for performance, hence failing to capture
screenshot of some screens.
but could capture the screenshot of only the root window provided and
not any additional windows layered on top (dialogs, bottom sheets, etc.).
Fix:
ScreenshotCapture.javautility class to handlehardware-accelerated bitmap capture using
PixelCopyAPI.PixelCopyAPI for Android O+ to capture hardware-acceleratedbitmaps correctly.
getRootViews()to detect all active windows using reflection.captureAsync()method with dual capture strategy:per-window isolation.
ViewRootDataclass to encapsulate window hierarchy information:ScreenshotCaptureUtils.javafor bitmap manipulation and merging.Testing done
Tested locally and verified that the changes work as expected for traditional as well as compose bottom-sheets (that have hardware bitmaps enabled).
Note for reviewers
While the changes work as expected for bottom-sheets, we are observing some issue when capturing screenshots of dialogs. The dialog appears squeezed in the bitmap. We are still trying to debuga nd fix the issue hence keeping PR as draft.