Surface.java: decrease native allocation size
The original change caused a new camera test flake. The camera app has a
bug where it doesn't release surfaces, and this caused the GC to churn
and captures to time out. This led to a rollback of this flag.
Lowering the value to hopefully cause less churn but still put enough
pressure on the GC to actually GC these objects.
Tested with:
- atest "CtsCameraTestCases:android.hardware.camera2.cts.CameraExtensionSessionTest#testRepeatingAndCaptureCombined[1]" --iteration 3
- atest "android.view.cts.SurfaceOOMTest#testSurfaceGarbageCollection" --iterations 3
Bug: 306193257
Bug: 324071855
Test: atest, see above
Change-Id: I405b388286939df015e8934b76f8cd1781228f5a
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 6c6e8b2..12dd608 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -103,9 +103,9 @@
long nativeObject, float frameRate, int compatibility, int changeFrameRateStrategy);
private static native void nativeDestroy(long nativeObject);
- // 5MB is a wild guess for what the average surface should be. On most new phones, a full-screen
- // surface is about 9MB... but not all surfaces are screen size. This should be a nice balance.
- private static final long SURFACE_NATIVE_ALLOCATION_SIZE_BYTES = 5_000_000;
+ // 5KB is a balanced guess, since these are still pretty heavyweight objects, but if we make
+ // this too big, it can overwhelm the GC.
+ private static final long SURFACE_NATIVE_ALLOCATION_SIZE_BYTES = 5_000;
public static final @android.annotation.NonNull Parcelable.Creator<Surface> CREATOR =
new Parcelable.Creator<Surface>() {