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.
[Android] Fix screenshot from WebView content not working #35384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
[Android] Fix screenshot from WebView content not working #35384
Changes from all commits
febd7d40bc938ea0c7b579d80ad5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[critical] Regression Prevention and Test Coverage — The known gate result showed this test passes without the product fix, so this assertion does not prove the WebView screenshot regression. Strengthen the repro/assertion so it fails on base, e.g. validate actual WebView-specific captured pixels/content rather than only waiting for the host page status label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Async and Threading Safety - If
CaptureAsync(View)is called from a background thread andPixelCopyreturnsnull, this fallback path runsView.Draw/ drawing-cache work on that background thread. Android view rendering APIs must run on the UI thread; dispatch the fallback render to the main looper or fail before falling back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] Android Platform Specifics — This allocates a new Android
Handler/Java peer for every screenshot capture. MAUI's existing PixelCopy usage posts through the view's native handler; preferview.Handler ?? new Handler(Looper.MainLooper!)so the callback is tied to the view looper and avoids unnecessary per-capture allocation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Async and Threading Safety — This waits indefinitely for the PixelCopy callback. If the window/surface is detached after
PixelCopy.Requestand no completion arrives,Screenshot.CaptureAsyncnever completes. Add a bounded wait/cancellation fallback and keep the continuation consistent with the rest of this file (ConfigureAwait(false)) while carefully handling bitmap ownership on timeout vs late success.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[major] Logic and Correctness - Returning
nullfor anyPixelCopyfailure silently falls through to the old canvas/drawing-cache screenshot path, which is the path that cannot capture hardware-accelerated WebView content. On an API 26+ device wherePixelCopyreturnsERROR_SOURCE_NO_DATA/timeout, callers can still receive a successful but blank-prone screenshot instead of a retry or clear failure signal.Uh oh!
There was an error while loading. Please reload this page.