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

OutOfMemory when doing a lot of screenshoting in a single test run #1094

Open
hrach opened this issue Sep 15, 2023 · 2 comments
Open

OutOfMemory when doing a lot of screenshoting in a single test run #1094

hrach opened this issue Sep 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hrach
Copy link

hrach commented Sep 15, 2023

Description
We get OOM when there is a lot of screenshoting in a single test run. We have our "helper"
aka

@Test
fun testSomething() {
  snapshot { TestedUi() }
}

That internally iterates over many configurations and screenshots the composable lamba with multiple device confnigurations.

Something like

for (device in ComplexScreenshotDevices) {
  for (locale in ComplexScreenshotLocales) {
    makeSnapshot(content)
  }
}

There are two devices and about 15 languages. Adding a third device easily triggers the OOM for us.

makeSnapshot is basically

Locale.setDefault(locale)
paparazzi.unsafeUpdateConfig(
  config.copy(
    locale = locale.language,
    softButtons = false,
  ),
)
paparazzi.snapshot(name, content)

When we do too much, it OOMs - both locally or in CI.

   java.lang.OutOfMemoryError: Java heap space
        at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75)
        at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:539)
        at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
        at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:333)
        at app.cash.paparazzi.internal.ImageUtils.scale(ImageUtils.kt:286)
        at app.cash.paparazzi.Paparazzi.scaleImage(Paparazzi.kt:413)
        at app.cash.paparazzi.Paparazzi.access$scaleImage(Paparazzi.kt:83)
        at app.cash.paparazzi.Paparazzi$takeSnapshots$1$2.invoke(Paparazzi.kt:326)
        at app.cash.paparazzi.Paparazzi$takeSnapshots$1$2.invoke(Paparazzi.kt:313)
        at app.cash.paparazzi.Paparazzi.withTime(Paparazzi.kt:361)
        at app.cash.paparazzi.Paparazzi.takeSnapshots(Paparazzi.kt:313)
        at app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:207)
        at app.cash.paparazzi.Paparazzi.snapshot$default(Paparazzi.kt:206)
        at app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:202)
        at xxx.BaseScreenshotTest.makeSnapshot(BaseScreenshotTest.kt:112)
@hrach hrach added the bug Something isn't working label Sep 15, 2023
@TWiStErRob
Copy link
Contributor

I think it's a duplicate of #915

@hrach hrach changed the title OutOfMemery when doing a lot of screenshoting in a single test run OutOfMemory when doing a lot of screenshoting in a single test run Sep 15, 2023
@KennyGoers
Copy link

Any sort of status on this? We are still running out of memory and the ticket that was supposed to be a duplicate of this is closed, but that seems to be because it's fixed by Google, but there still doesn't seem to be a distribution with that version Google fixed it in included.

I tried to implement the work around mentioned, but it is missing some details.

Thanks.
Kenny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants