Open alexjlockwood opened 7 months ago
Thank you for reporting this issue. I was unable to reproduce the issue using your sample project.
It may or may not be related, but I'm using an Apple M1 Max, version 13.5.1.
I suggest trying to set the robolectric.screenshot.hwrdr.native property to true as a possible solution to the issue:
init {
val USE_HARDWARE_RENDERER_NATIVE_ENV = "robolectric.screenshot.hwrdr.native"
System.setProperty(USE_HARDWARE_RENDERER_NATIVE_ENV, "true")
}
Sorry, I wasn't using the recordRoborazziDebug task, so I'm able to reproduce the issue. Additionally, I managed to fix the issue using the hardware rendering option. Deciding whether we can utilize it is also challenging for me though.
@alexjlockwood I was able to reproduce this issue without Roborazzi.
@RunWith(AndroidJUnit4::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class ExampleUnitTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<ComponentActivity>()
@Test
fun lazyColumnTest() {
composeTestRule.setContent {
LazyColumn {
item {
Text(
modifier = Modifier.animateItem(),
text = "Text",
)
}
}
}
val bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888)
PixelCopy.request(
composeTestRule.activity.window, bitmap, PixelCopy.OnPixelCopyFinishedListener {
}, Handler(Looper.getMainLooper())
)
}
}
The issue likely originates not from Roborazzi but from Robolectric, as Robolectric may need to incorporate the drawRenderNode()
method in its shadow. Using hardware rendering serves as a potential workaround; should this be the advised approach for resolving the issue, we might need to implement hardware rendering.
Therefore, if you could report this issue to Robolectric, it would be greatly appreciated.
I have a sample project (which you can download here in RoborazziSample.zip) that runs the following test:
When I run this test, I get an exception:
My sample project uses the following versions:
1.7.0-alpha06
1.11.0
4.12.1
The issue seems to be related to
Modifier.animateItem()
in Compose1.7.0-alpha06
, as this test works fine if I downgrade to Compose1.7.0-alpha05
and replace the modifier with the olderModifier.animateItemPlacement()
. (If you are unfamiliar with these APIs, basically they allow for automatic fade in/out/reordering animations in a compose list).I am uncertain of the details causing this exception, but I do notice that in the latest Compose changelog there is mention of changes to
GraphicsLayer
and I noticed that there's also mention ofGraphicsLayer
in the PR that introduced this newModifier.animateLayer()
API.Full stack trace: