cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.25k stars 213 forks source link

`WindowInsets.isImeVisible` is temporary true during snapshot test. #1293

Closed nvkleban closed 3 months ago

nvkleban commented 6 months ago

Description I have a compose UI function which hides some of it's content in case if ime is visible. Inside it I have AnimatedVisibility.

AnimatedVisibility(visible = !WindowInsets.isImeVisible) {
        content()
}

Paparazzi.snapshot for screen with this component produces screenshot without content()

For testing purposes:

What I see from logs inside my composable function:

isImeVisible = true
isImeVisible = true
isImeVisible = false
isImeVisible = false

Maybe first values affects AnimatedVisibility somehow, idk.

Steps to reproduce PaparazziImeReproducer.zip

Expected behavior snapshot produces picture not affected by initial keyboard state

Additional information:

jrodbx commented 6 months ago

@nvkleban mind providing a repro project?

nvkleban commented 6 months ago

@jrodbx updated description with repro project

jrodbx commented 3 months ago

@geoff-powell shared that testing preview appears to behave the same way.

I took a look as well with a debugger and saw two logs (not sure why you were seeing four?) confirming what you saw:

isImeVisible = true
isImeVisible = false

Going on a hunch, I searched on Google's issue tracker which seems to confirm that this is a problem with Compose's handling of the IME. This comment in particular stands out.

Closing as an issue with Compose libraries, and not Paparazzi.