Skip to content
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

Errors thrown when attempting to generate diff image files for Compose views #157

Open
1 of 5 tasks
philipsawyer opened this issue Jul 18, 2023 · 0 comments
Open
1 of 5 tasks
Labels
Bug Any behaviour the deviates from the documentation, expected outcome or API contract.

Comments

@philipsawyer
Copy link

philipsawyer commented Jul 18, 2023

Describe the bug
Attempting to record a diff image on a failed Compose screenshot test leads to a java.lang.RuntimeException: Buffer not large enough for pixels error

This issue relates to:

  • The Kotlin library
  • The Gradle plugin
  • The IntelliJ Platform plugin
  • The sample code
  • The documentation

To Reproduce
Steps to reproduce the behavior:
Create a screenshot test using the ComposableScreenshotRule and enable the TestifyFeatures.GenerateDiffs option. Create a screenshot reference and then update the UI such that it is different. Then run the test (expected to fail). An updated screenshot is written out (as expected) but the diff image is not created. In the logs it appears there is an error that is thrown when creating the diff image (java.lang.RuntimeException: Buffer not large enough for pixels)

Here is the call stack I'm seeing in the logs:

java.lang.RuntimeException: Buffer not large enough for pixels
	at android.graphics.Bitmap.copyPixelsToBuffer(Bitmap.java:636)
	at dev.testify.internal.processor.ParallelPixelProcessor.prepareBuffers(ParallelPixelProcessor.kt:39)
	at dev.testify.internal.processor.ParallelPixelProcessor.transform(ParallelPixelProcessor.kt:97)
	at dev.testify.internal.processor.diff.HighContrastDiff.generate(HighContrastDiff.kt:24)
	at dev.testify.ScreenshotRule.generateHighContrastDiff(ScreenshotRule.kt:423)
	at dev.testify.ScreenshotRule.assertSame(ScreenshotRule.kt:534)
	at com.xxxx.android.example.ExampleComposeSnapshotTests$test_instrumentation_snapshot_tests_integration_for_compose$3.invoke(ExampleComposeSnapshotTests.kt:20)
	at com.xxxx.android.example.ExampleComposeSnapshotTests$test_instrumentation_snapshot_tests_integration_for_compose$3.invoke(ExampleComposeSnapshotTests.kt:15)
	at com.kaspersky.kaspresso.testcases.core.TestRunner.runMainTestSection(TestRunner.kt:146)
	at com.kaspersky.kaspresso.testcases.core.TestRunner.run(TestRunner.kt:59)
	at com.kaspersky.kaspresso.testcases.core.sections.MainTestSection.run(MainTestSection.kt:29)
	at com.xxxx.android.example.ExampleComposeSnapshotTests.test_instrumentation_snapshot_tests_integration_for_compose(ExampleComposeSnapshotTests.kt:15)

Here is our setup for the rule:

@get:Rule
 val composeScreenshotRule = ComposableScreenshotRule()
    .configure {
        exactness = 0.95f
    }
    .withExperimentalFeatureEnabled(TestifyFeatures.GenerateDiffs)
    as ComposableScreenshotRule

Is there any insight you can provide here about what might be causing this issue or how we might fix this? / Does our setup look correct for this approach?

Thanks for any help you can provide!

Expected behavior
I would expect the diff image file is created and written to disk. Note: The ScreenshotRule with similar setup works fine and outputs a diff image.

Screenshots
If applicable, add screenshots to help explain your problem.

Target Android Device (please complete the following information):

  • Device: Android Emulator and actual device on AWS DeviceFarm (Samsung Galaxy S21)
@philipsawyer philipsawyer added the Bug Any behaviour the deviates from the documentation, expected outcome or API contract. label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any behaviour the deviates from the documentation, expected outcome or API contract.
Projects
None yet
Development

No branches or pull requests

1 participant