cashapp / paparazzi

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

Text gets cut off when the AccessibilityRenderExtension is used and the font scale is set to 2f #1601

Open palpapp04 opened 1 month ago

palpapp04 commented 1 month ago

Description I have a snapshot test where I am using the AccessibilityRenderExtension and I have a font scale test parameter to create multiple snapshots with different font sizes. When the font scale is set to 2f and the AccessibilityRenderExtension is used texts on buttons get cut off. However when I do not use the AccessibilityRenderExtension the text on the buttons does not get cut off.

Steps to Reproduce Here is a sample project I created where the issue is reproducible by running the recordPaparazzi task. It contains 2 test classes one with AccessibilityRenderExtension and one without. When you run recordPaparazzi it will generate the snapshots (although the ones I generated are also contained in the zip file if I am correct) and you can see that the snapshots look the same except when the font scale is set to 2f. PaparazziTest.zip

Expected behavior My expectation would be that the generated snapshots are the same with and without the AccessibilityRenderExtension and that the text on the buttons does not get cut off when you use the AccessibilityRenderExtension

Additional information:

Screenshots com example paparazzitest_ExampleUnitTest_Example test where text is cut off MAX_FONT_CONFIG com example paparazzitest_ExampleWithoutA11yExtensionUnitTest_Example test where text is not cut off MAX_FONT_CONFIG

palpapp04 commented 1 month ago

Thanks in advance to anyone for helping to resolve this issue :)

geoff-powell commented 1 month ago

Yep, so the issue is animationContentSize modifier .animateContentSize(animationSpec = tween(durationMillis = 500)) is animating so the initial snapshot is the first frame of animation. Try using paparazzi.gif() to record the animation or allow a param to omit animation. We are working on creating an InstantAnimationRule that support compose animations soon hopefully 🙏🏽 https://github.com/cashapp/paparazzi/issues/1261 .

Removing that modifier results in the expected snapshot. com example paparazzitest_ExampleUnitTest_Example test where text is cut off MAX_FONT_CONFIG

palpapp04 commented 1 month ago

Thanks for your response. Then I guess I will just have to wait for compose animation support. But it is interesting that the issue only comes forward when the AccessiblityRenderExtension is added. Is there some reason for that? Because then I can just not use that extension while there is no support for compose animations but I am a little worried that this issue will come forward here and there without the extension as well.