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
Using PixelCopy in conjunction with ShadowPackageManager.addActivityIfNotPresent and robolectric.screenshot.hwrdr.native results in capturing an empty image. #8982
Comments
Thanks @takahirom for this issue. We will definitely look at this issue. Overall I would say that HW rendering in Robolectric is still experimental. There are currently a lot of issues with it and the APIs are subject to change. |
Hi @takahirom, @ralf-at-android and I looked at this issue just now. The root cause is that when Activities are created in the manner described in your test, the Window of the Activity does not contain If you use this code to set up the Activity, the test passes:
When adding the Activity to an AndroidManifest.xml, the FLAG_HARDWARE_ACCELERATED flag of ActivityInfo gets properly added I believe. @ralf-at-android and I are still considering how to resolve this issue. FLAG_HARDWARE_ACCELERATED is default to true since Android SDK 14 (ice cream sandwich), so this should also be the default for all Activities in Robolectric. However, that may be a breaking change if somehow tests depend on activities not supporting FLAG_HARDWARE_ACCELERATED. We will look into this issue more. |
Thanks. I edited a comment on an issue that appears in the logs when you forget to add an Activity to the Manifest in Robolectric. |
…Present Previously, only Activities that were present in an AndroidManifest.xml would contain the FLAG_HARDWARE_ACCELERATED window flag, which gets populated by PackageParser. This means that Activities not present in a manifest could not be rendered with a HardwareRenderer, as it would get ignored due to the missing flag. This meant that the HW rendering version of PixelCopy would not operate on that Activity. The FLAG_HARDWARE_ACCELERATED was true by default since Android ICS (SDK 14), so it should be true by default in Robolectric as well. Fixes #8982 PiperOrigin-RevId: 628494031
…Present Previously, only Activities that were present in an AndroidManifest.xml would contain the FLAG_HARDWARE_ACCELERATED window flag, which gets populated by PackageParser. This means that Activities not present in a manifest could not be rendered with a HardwareRenderer, as it would get ignored due to the missing flag. This meant that the HW rendering version of PixelCopy would not operate on that Activity. The FLAG_HARDWARE_ACCELERATED was true by default since Android ICS (SDK 14), so it should be true by default in Robolectric as well. Fixes #8982 PiperOrigin-RevId: 628494031
…Present Previously, only Activities that were present in an AndroidManifest.xml would contain the FLAG_HARDWARE_ACCELERATED window flag, which gets populated by PackageParser. This means that Activities not present in a manifest could not be rendered with a HardwareRenderer, as it would get ignored due to the missing flag. This meant that the HW rendering version of PixelCopy would not operate on that Activity. The FLAG_HARDWARE_ACCELERATED was true by default since Android ICS (SDK 14), so it should be true by default in Robolectric as well. Fixes #8982 PiperOrigin-RevId: 628494031
Description
While using a Manifest file to add an Activity allows for successful screenshot captures, employing ShadowPackageManager.addActivityIfNotPresent results in a transparent image instead of the expected bitmap.
Steps to Reproduce
Use following settings and code.
Please add this test into ActivityScenarioTest in Robolectric repo to reproduce the issue
Result
Robolectric & Android Version
Robolectric master branch 03bbc9c (current latest commit)
Link to a public git repo demonstrating the problem:
The text was updated successfully, but these errors were encountered: