Skip to content

Use PixelCopy to create Screenshots #2916

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

Closed
kahest opened this issue Sep 5, 2023 · 2 comments · Fixed by #3008
Closed

Use PixelCopy to create Screenshots #2916

kahest opened this issue Sep 5, 2023 · 2 comments · Fixed by #3008
Assignees

Comments

@kahest
Copy link
Member

kahest commented Sep 5, 2023

Description

Using PixelCopy to create screenshots is likely to provide better performance than the current approach.
See https://developer.android.com/reference/android/view/PixelCopy

@markushi
Copy link
Member

markushi commented Sep 8, 2023

So I've compared the old API against the new one and it's slower.

Turns out the async API is a lie, only the callback gets executed async - but capturing is happening on the calling thread.
See the source for more details.

Surprisingly PixelCopy is also around 20% slower, maybe because it e.g. also draws shadows?
Pixel 6a, Demo App, Release build

n=20, PixelCopy.request avg 145.6ms, ScreenshotUtils.takeScreenshot avg 116.85ms

@markushi
Copy link
Member

Closing this as it doesn't seem to give us any real advantage over ScreenshotUtils.takeScreenshot. Let's see if we can call this API on a background thread, which would be the only advantage then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants