ndtp / android-testify

Add screenshots to your Android tests
Other
101 stars 5 forks source link

Improve handling of memory allocations and OOM errors #226

Closed DanielJette closed 3 months ago

DanielJette commented 3 months ago

What does this change accomplish?

Parallel pixel processing requires the allocation of two byte buffers. For a typical device resolution of 1080 x 1920, two buffers of approximately 2 MB each (4 MB total) are allocated.

Most AVDs are configured with a heap size of 25% their available RAM. For example, 512 MB for a device with 2 GB of RAM. See: https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/android-emu/android/main-common.c#1292

This is normally more than sufficient for parallel pixel processing. However, in some instances it has been observed where the heap size for androidTest instrumentation runners is set to only 16 MB, which is not sufficient for Testify. If you encounter this exception, please verify that your emulator is correctly configured with at least 2 GB of RAM.

Testify will now throw a LowMemoryException when attempts to allocate an IntBuffer fail. This can help users diagnose AVD configuration problems and reports on the state of the device.

AndroidTestifyBot commented 3 months ago

:white_check_mark: Success! - Legacy Sample screenshot test results

View build for commit 4809725bd5095ba31866d88122ac1cd16fd9c820
AndroidTestifyBot commented 3 months ago

:white_check_mark: Success! - Flix Sample screenshot test results

View build for commit 4809725bd5095ba31866d88122ac1cd16fd9c820
AndroidTestifyBot commented 3 months ago

:white_check_mark: Success! - Flix Library screenshot test results

View build for commit 4809725bd5095ba31866d88122ac1cd16fd9c820