pazone / ashot

WebDriver Screenshot utility. Take screenshots, crop, prettify, compare
Other
642 stars 158 forks source link

Out of Memory Error From Large Screenshots #146

Open Sintrias opened 5 years ago

Sintrias commented 5 years ago

I really like this tool so far. The only issue I see now from it is that when a page is large and in turn the image is large, it causes an Out of Memory Error even with 1GB of reserved memory. I don't suppose there is any way to store the image in a file a little at a time to avoid this issue.

osyanin commented 4 years ago
    ru.yandex.qatools.ashot.shooting.ImageReadException: Can not parse screenshot data
        at org.project.tests.gui.screenashooter.VaultUpload.vaultUploadMobileBrowserEmulated(VaultUpload.java:26)
    Caused by: javax.imageio.IIOException: Caught exception during read:
        at org.project.tests.gui.screenashooter.VaultUpload.vaultUploadMobileBrowserEmulated(VaultUpload.java:26)
    Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.project.tests.gui.screenashooter.VaultUpload.vaultUploadMobileBrowserEmulated(VaultUpload.java:26)

org.project.tests.gui.screenashooter.VaultUpload > vaultUploadMobileBrowserEmulated(String, String)[6] FAILED
    ru.yandex.qatools.ashot.shooting.ImageReadException: Can not parse screenshot data
        at ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy.getScreenshot(SimpleShootingStrategy.java:34)
        at ru.yandex.qatools.ashot.shooting.ScalingDecorator.getScreenshot(ScalingDecorator.java:27)
        at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:53)
        at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
        at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145)
        at org.project.tests.util.screenashooter.ScreenShooter.capturePage(ScreenShooter.java:134)
        at org.project.tests.util.screenashooter.ScreenShooter.capturePageToVault(ScreenShooter.java:157)
        at org.project.tests.gui.screenashooter.VaultUpload.vaultUploadMobileBrowserEmulated(VaultUpload.java:26)
valfirst commented 4 years ago

@osyanin which memory options do you use for your Java process running tests?

osyanin commented 4 years ago
org.gradle.jvmargs=-Xmx16g -Xms4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
systemProp.junit.jupiter.execution.parallel.enabled=true
systemProp.junit.jupiter.execution.parallel.mode.default=concurrent
systemProp.junit.jupiter.execution.parallel.mode.classes.default=concurrent
systemProp.junit.jupiter.execution.parallel.config.strategy=dynamic
systemProp.junit.jupiter.execution.parallel.config.dynamic.factor=2

Environment: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz with 4 core and hyperthreading, and 32 gb of RAM + ssd hard drive

valfirst commented 4 years ago

@osyanin org.gradle.jvmargs specifies the JVM arguments used for the Gradle Daemon, not for tests, see https://docs.gradle.org/current/userguide/build_environment.html for more details.

For tests configuration options check https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

osyanin commented 4 years ago

It helped, thanks! @valfirst