Optimize cinematic rendering for integrated Android TVs

This commit is contained in:
Elijah Kuntz 2026-10-19 09:49:08 -07:00
parent dc5908cb3b
commit 1f69422354
15 changed files with 366 additions and 153 deletions

View file

@ -37,7 +37,14 @@ public final class WakeRegressionInstrumentation extends Instrumentation {
Bitmap image = (Bitmap) field(field(tile, "art"), "bitmap");
if (image == null || image.isRecycled()) return false;
}
Bitmap wallpaper = (Bitmap) field(field(activity, "scene"), "wallpaper");
Object scene = field(activity, "scene");
Bitmap wallpaper = (Bitmap) field(scene, "wallpaper");
Bitmap frame = (Bitmap) field(scene, "frame");
if (frame == null || frame.isRecycled() || frame.getWidth() > 960 || frame.getHeight() > 540)
return false;
// A decoded source alone must not conceal a missing or blank composed background.
if (frame.getPixel(frame.getWidth() * 3 / 4, frame.getHeight() / 4)
== frame.getPixel(frame.getWidth() / 4, frame.getHeight() * 3 / 4)) return false;
return wallpaper != null && !wallpaper.isRecycled();
}
@ -177,6 +184,45 @@ public final class WakeRegressionInstrumentation extends Instrumentation {
throw new RuntimeException(e);
}
});
runOnMainSync(
() -> {
callActivityOnPause(activity);
callActivityOnStop(activity);
try {
Object scene = field(activity, "scene");
for (String name : new String[] {"wallpaper", "mediaArt", "frame", "previousFrame"})
if (field(scene, name) != null)
throw new AssertionError("background retained " + name);
if (!((ThreadPoolExecutor) field(scene, "renderer")).getQueue().isEmpty())
throw new AssertionError("background work retained after stop");
} catch (Exception e) {
throw new RuntimeException(e);
}
callActivityOnRestart(activity);
callActivityOnStart(activity);
callActivityOnResume(activity);
});
awaitImages("composed background restores after all cached textures are released");
runOnMainSync(
() -> {
try {
java.lang.reflect.Method start = activity.getClass().getDeclaredMethod("startSaver");
start.setAccessible(true);
start.invoke(activity);
Object scene = field(activity, "scene");
if ((boolean) field(scene, "active"))
throw new AssertionError("scene active under saver");
java.lang.reflect.Method stop =
activity.getClass().getDeclaredMethod("stopSaver", boolean.class);
stop.setAccessible(true);
stop.invoke(activity, true);
if (!(boolean) field(scene, "active"))
throw new AssertionError("scene paused after saver");
} catch (Exception e) {
throw new RuntimeException(e);
}
});
awaitImages("screensaver dismissal resumes background rendering");
for (int i = 0; i < 5; i++) {
runOnMainSync(
() -> {