diff --git a/.gitignore b/.gitignore index 276ee72..99d8884 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ output/*.txt output/*.log output/wake-before/ output/Luma-wake-tests.apk* +output/performance/ diff --git a/README.md b/README.md index 79e75c9..5de8d45 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ To return to the previous routing, turn off Luma's Home override, then open Proj **App labels** offers Always, Focused only (default), and Never. Accessibility app names remain available in all modes. Other settings include 5/6/7 columns, background dimming, automatic or fixed accent colors, reduced motion, clock visibility, and 90-second scene rotation. Alpine uses the bundled original wallpaper; Aurora and Midnight are inexpensive procedural gradients. -Focus uses a 6.5% scale increase, a 160 ms transition, and an app-colored native shadow. Wallpaper/artwork crossfades last 320 ms. The launcher has no continuously rendered blur or background video. Optional screensaver video runs only while the screensaver is visible. +Focus uses a 6.5% scale increase, a 160 ms transition, and an app-colored native shadow. Background crossfades last 280 ms. The launcher has no continuously rendered blur or background video. Optional screensaver video runs only while the screensaver is visible. The app grid uses one 260 ms scroll animation for remote focus movement. **App section text** can hide the heading, installed count, and customization hint; it is hidden by default without changing the original spacing. @@ -97,10 +97,10 @@ Android scheduling and installation behavior follow the [JobInfo API](https://de ## Performance design - Platform Java/Android views and Canvas; no WebView, Compose runtime, playback engine, or third-party runtime dependencies. -- Single sampled RGB565 wallpaper (960 × 540 for the bundled 1920 × 1080 image). +- Single sampled RGB565 wallpaper (960 × 540 for the bundled 1920 × 1080 image). Cinematic gradients, dimming, and artwork are composed off the UI thread into an opaque texture capped at 960 × 540; navigation crossfades the finished textures instead of re-running several full-screen shaders every frame. - App artwork is rasterized to 288 × 162. Icon cache is capped at 3 MiB; visible tiles also hold their displayed images. - Plex image cache is capped at 3 MiB. Hero images are sampled to at most roughly 1280 × 720; rows and network response sizes are bounded. -- At most the current and previous artwork are retained during a short crossfade. A focus debounce avoids loading artwork for every passing selection. +- At most the current and previous composed backgrounds are displayed during a short crossfade. The compositor has one worker and one pending request; obsolete results are discarded. Its worker times out after two idle seconds. A focus debounce avoids loading Plex artwork for every passing selection. Only the focused tile casts an app-colored shadow, with no duplicate parent shadow. - No boot receiver, alarms, or PowerManager wake locks. Update checks use one brief JobScheduler job, normally daily. The optional Home override is an event-driven accessibility service in a separate process; turning it off removes that bound service. The optional DreamService runs only when Android explicitly binds it as a system screensaver. - Clock updates once per minute; optional scene rotation runs only while Luma is visible. - On pause, networking and scene animations are canceled. On stop, queued work, image references, and caches are cleared. Worker threads time out after ten idle seconds. @@ -115,7 +115,7 @@ The signed APK is [output/Luma.apk](output/Luma.apk). Source is in `app/src/main The current workspace already contains a local JDK 17 and Android SDK under `.tools`. Rebuild without Gradle: ```sh -scripts/build.sh +bash scripts/build.sh .tools/platform-tools/adb -s 192.168.50.195:35635 install -r output/Luma.apk ``` @@ -140,7 +140,7 @@ python3 scripts/device_smoke.py --part screensaver-timeout The scripts operate the TV through ADB. Run one at a time with the TV awake. The customization checks expect the documented defaults. The Plex fixture requires `python3 scripts/plex_fixture.py` running on the host, followed by `python3 scripts/device_smoke.py --part plex`. It uses temporary ADB reverse forwarding to a loopback server and disconnects the fixture when finished. -The wake regression uses a separate test APK signed with the same development key, without adding any test interface to Luma. It replays interrupted background loading, a pause/resume without another start callback, memory trimming, and five stop/start cycles. The old 1.0.0 build fails the interrupted-wake case; 1.0.1 passes. +The wake regression uses a separate test APK signed with the same development key, without adding any test interface to Luma. It replays interrupted background loading, a pause/resume without another start callback, memory trimming, and five stop/start cycles. The old 1.0.0 build fails the interrupted-wake case; 1.0.1 passes. The current test also verifies nonblank composed backgrounds, their resolution limit, and cache release on stop. ```sh bash scripts/build-wake-tests.sh @@ -152,4 +152,6 @@ bash scripts/build-wake-tests.sh Successful output ends with `INSTRUMENTATION_CODE: -1` and PASS lines for all cases. The runner controls activity lifecycle callbacks and should be run with no other device tests in progress. Android force-stops the target package during instrumentation and can mark its accessibility helper as stopped/crashed. After testing, check **Settings → Default launcher** and toggle **Luma Home button** off/on in Android Accessibility if needed, then reopen Luma. This is test-runner cleanup, not an action needed during normal TV wake. +The same test APK also includes `tv.luma.launcher.tests/.PerformanceInstrumentation` for the background/shadow A/B benchmark. It changes only runtime view state and writes a temporary `performance.txt` in Luma's external-files directory. Reopen Luma afterward and remove the diagnostic APK. + See [docs/ASSETS.md](docs/ASSETS.md) for the wallpaper generation prompt and asset provenance. Android TV intent handling follows [Android's TV app guidance](https://developer.android.com/training/tv/get-started/create); Plex integration follows the [official Plex Media Server API documentation](https://developer.plex.tv/pms/). diff --git a/app/build.gradle b/app/build.gradle index 7bbbadf..51fe5e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId 'tv.luma.launcher' minSdk 26 targetSdk 34 - versionCode 8 - versionName '1.1.5' + versionCode 9 + versionName '1.1.6' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d488ff6..06fd734 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + diff --git a/app/src/main/java/tv/luma/launcher/AppTile.java b/app/src/main/java/tv/luma/launcher/AppTile.java index 6ccbc3b..b2e001c 100644 --- a/app/src/main/java/tv/luma/launcher/AppTile.java +++ b/app/src/main/java/tv/luma/launcher/AppTile.java @@ -42,14 +42,14 @@ final class AppTile extends LinearLayout { animate() .scaleX(f ? 1.065f : 1f) .scaleY(f ? 1.065f : 1f) - .translationZ(f ? Ui.dp(c, 8) : 0) .setDuration(motion ? 160 : 0) .setInterpolator(new DecelerateInterpolator()) .start(); label.setTextColor(f ? Ui.WHITE : Ui.MUTED); updateLabel(); art.focus = f; - art.animate().translationZ(Ui.dp(c, f ? 8 : 1)).setDuration(motion ? 160 : 0).start(); + // Only the focused tile needs a shadow; avoid overlapping parent/child shadows. + art.animate().translationZ(Ui.dp(c, f ? 6 : 0)).setDuration(motion ? 160 : 0).start(); art.invalidate(); if (focus != null) focus.changed(f); }); @@ -116,7 +116,7 @@ final class AppTile extends LinearLayout { super(c); fallback = s; setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); - setElevation(Ui.dp(c, 2)); + setElevation(0); setOutlineProvider( new ViewOutlineProvider() { @Override diff --git a/app/src/main/java/tv/luma/launcher/MainActivity.java b/app/src/main/java/tv/luma/launcher/MainActivity.java index 3b38f5c..053c09e 100644 --- a/app/src/main/java/tv/luma/launcher/MainActivity.java +++ b/app/src/main/java/tv/luma/launcher/MainActivity.java @@ -308,6 +308,7 @@ public final class MainActivity extends Activity { protected void onResume() { super.onResume(); foreground = true; + scene.resume(); plex.resume(); restoreImages(); handler.removeCallbacks(minuteTick); @@ -358,7 +359,7 @@ public final class MainActivity extends Activity { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); handler.removeCallbacks(idleSaver); stopSaver(false); - scene.stopAnimations(); + scene.pause(); scroll.stopAnimation(); } @@ -401,6 +402,7 @@ public final class MainActivity extends Activity { plex.cancel(); updater.cancel(); if (updateTask != null) updateTask.cancel(true); + scene.shutdown(); work.shutdownNow(); network.shutdownNow(); super.onDestroy(); @@ -1857,7 +1859,7 @@ public final class MainActivity extends Activity { handler.removeCallbacks(idleSaver); handler.removeCallbacks(minuteTick); handler.removeCallbacks(rotateScene); - scene.stopAnimations(); + scene.pause(); scroll.stopAnimation(); saver = new SaverView(this); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -1872,6 +1874,7 @@ public final class MainActivity extends Activity { saver = null; getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); if (resume && foreground) { + scene.resume(); AppTile tile = tiles.get(selected); if (tile != null) tile.requestFocus(); handler.removeCallbacks(minuteTick); diff --git a/app/src/main/java/tv/luma/launcher/SceneView.java b/app/src/main/java/tv/luma/launcher/SceneView.java index b9cd80b..ec0ca6a 100644 --- a/app/src/main/java/tv/luma/launcher/SceneView.java +++ b/app/src/main/java/tv/luma/launcher/SceneView.java @@ -7,24 +7,33 @@ import android.content.Context; import android.graphics.*; import android.view.View; import java.io.InputStream; +import java.util.concurrent.*; -/** Single sampled bitmap, cached shaders; nothing redraws when the screen is idle. */ +/** Flatten cinematic effects once off the UI thread, then crossfade bounded opaque textures. */ final class SceneView extends View { - private final Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); - private Bitmap wallpaper, mediaArt, previousArt; - private float artMix = 1; - private boolean motion = true; - private ValueAnimator imageAnimator; + private final Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG); private final RectF destination = new RectF(); - private int accent = 0xFF5B4125, from = accent, to = accent; - private ValueAnimator animator; - private Shader left, bottom, glow, base; + private final ThreadPoolExecutor renderer = + new ThreadPoolExecutor( + 1, + 1, + 2, + TimeUnit.SECONDS, + new ArrayBlockingQueue<>(1), + new ThreadPoolExecutor.DiscardOldestPolicy()); + private Bitmap wallpaper, mediaArt, frame, previousFrame; + private float mix = 1; + private boolean motion = true, active = true, dirty = true; + private volatile int generation; + private int accent = 0xFF5B4125; private String scene = "alpine"; private float dim = .24f; + private ValueAnimator animator; SceneView(Context c) { super(c); setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); + renderer.allowCoreThreadTimeOut(true); } static Bitmap decodeWallpaper(Context c) { @@ -46,9 +55,9 @@ final class SceneView extends View { } void setWallpaper(Bitmap b) { - Bitmap previous = currentArt(); + if (wallpaper == b) return; wallpaper = b; - transitionArt(previous); + requestRender(); } boolean hasWallpaper() { @@ -61,106 +70,125 @@ final class SceneView extends View { void setMediaArt(Bitmap b) { if (mediaArt == b) return; - Bitmap previous = currentArt(); mediaArt = b; - transitionArt(previous); - } - - private Bitmap currentArt() { - return mediaArt != null ? mediaArt : scene.equals("alpine") ? wallpaper : null; + requestRender(); } void setMotion(boolean enabled) { motion = enabled; - if (!motion) stopAnimations(); - } - - private void transitionArt(Bitmap previous) { - if (imageAnimator != null) imageAnimator.cancel(); - if (!motion || previous == currentArt()) { - previousArt = null; - artMix = 1; - invalidate(); - return; - } - previousArt = previous; - artMix = 0; - imageAnimator = ValueAnimator.ofFloat(0, 1); - imageAnimator.setDuration(320); - imageAnimator.addUpdateListener( - a -> { - artMix = (float) a.getAnimatedValue(); - invalidate(); - }); - imageAnimator.addListener( - new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - previousArt = null; - artMix = 1; - invalidate(); - } - }); - imageAnimator.start(); + if (!enabled) stopAnimations(); } void configure(String s, float darkness) { - Bitmap previous = currentArt(); + if (scene.equals(s) && dim == darkness && frame != null) return; scene = s; dim = darkness; - shaders(); - transitionArt(previous); + requestRender(); } void accent(int color, boolean animate) { - if (animator != null) animator.cancel(); - from = accent; - to = color; - if (!animate) { - accent = color; - shaders(); - invalidate(); - return; - } - animator = ValueAnimator.ofFloat(0, 1); - animator.setDuration(280); - animator.addUpdateListener( - a -> { - float f = (float) a.getAnimatedValue(); - accent = blend(from, to, f); - glowShader(); - invalidate(); - }); - animator.start(); - } - - private int blend(int a, int b, float f) { - return Color.rgb( - (int) (Color.red(a) * (1 - f) + Color.red(b) * f), - (int) (Color.green(a) * (1 - f) + Color.green(b) * f), - (int) (Color.blue(a) * (1 - f) + Color.blue(b) * f)); + if (accent == color) return; + accent = color; + requestRender(); } + @Override protected void onSizeChanged(int w, int h, int ow, int oh) { - shaders(); + requestRender(); } - private void glowShader() { - if (getWidth() > 0) - glow = - new RadialGradient( - getWidth() * .76f, - getHeight() * .25f, - getWidth() * .8f, - new int[] {(accent & 0x00FFFFFF) | 0xA0000000, 0x00000000}, + private void requestRender() { + dirty = true; + final int ticket = ++generation; + renderer.getQueue().clear(); + if (!active || getWidth() == 0 || getHeight() == 0) return; + float scale = Math.min(1f, Math.min(960f / getWidth(), 540f / getHeight())); + final int w = Math.max(1, Math.round(getWidth() * scale)); + final int h = Math.max(1, Math.round(getHeight() * scale)); + final Bitmap art = mediaArt != null ? mediaArt : scene.equals("alpine") ? wallpaper : null; + final String theme = scene; + final int color = accent; + final float darkness = dim; + renderer.execute( + () -> { + if (ticket != generation) return; + Bitmap composed; + try { + composed = compose(w, h, art, theme, darkness, color); + } catch (OutOfMemoryError e) { + return; + } + if (ticket != generation) return; + post( + () -> { + if (ticket != generation || !active) return; + dirty = false; + stopAnimations(); + previousFrame = frame; + frame = composed; + if (!motion || previousFrame == null) { + previousFrame = null; + mix = 1; + invalidate(); + return; + } + mix = 0; + animator = ValueAnimator.ofFloat(0, 1); + animator.setDuration(280); + animator.addUpdateListener( + a -> { + mix = (float) a.getAnimatedValue(); + invalidate(); + }); + animator.addListener( + new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + previousFrame = null; + mix = 1; + invalidate(); + } + }); + animator.start(); + }); + }); + } + + private static Bitmap compose(int w, int h, Bitmap art, String scene, float dim, int accent) { + Bitmap result = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); + result.setHasAlpha(false); + Canvas c = new Canvas(result); + Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); + boolean hasArt = art != null && !art.isRecycled(); + if (hasArt) { + float scale = Math.max(w / (float) art.getWidth(), h / (float) art.getHeight()); + float aw = art.getWidth() * scale, ah = art.getHeight() * scale; + c.drawBitmap(art, null, new RectF((w - aw) / 2, (h - ah) / 2, (w + aw) / 2, (h + ah) / 2), p); + c.drawColor(((int) (dim * 255) << 24) | 0x00040810); + } else { + p.setShader( + new LinearGradient( + w, + 0, + 0, + h, + new int[] {scene.equals("aurora") ? 0xFF143B49 : 0xFF152037, 0xFF151A32, Ui.BG}, null, - Shader.TileMode.CLAMP); - } - - private void shaders() { - if (getWidth() == 0) return; - float w = getWidth(), h = getHeight(); - left = + Shader.TileMode.CLAMP)); + c.drawRect(0, 0, w, h, p); + } + p.setShader( + new RadialGradient( + w * .76f, + h * .25f, + w * .8f, + new int[] {(accent & 0x00FFFFFF) | 0xA0000000, 0x00000000}, + null, + Shader.TileMode.CLAMP)); + p.setAlpha(hasArt ? 65 : 150); + c.drawRect(0, 0, w, h, p); + p.setAlpha(255); + p.setShader( new LinearGradient( 0, 0, @@ -168,8 +196,9 @@ final class SceneView extends View { 0, new int[] {0xE0080D18, 0x9C080D18, 0x00080D18}, new float[] {0, .48f, 1}, - Shader.TileMode.CLAMP); - bottom = + Shader.TileMode.CLAMP)); + c.drawRect(0, 0, w, h, p); + p.setShader( new LinearGradient( 0, h * .24f, @@ -177,60 +206,58 @@ final class SceneView extends View { h, new int[] {0x00080D18, 0xA8080D18, 0xFC080D18, 0xFF080D18}, new float[] {0, .47f, .82f, 1}, - Shader.TileMode.CLAMP); - int top = scene.equals("aurora") ? 0xFF143B49 : 0xFF152037; - base = - new LinearGradient( - w, 0, 0, h, new int[] {top, 0xFF151A32, Ui.BG}, null, Shader.TileMode.CLAMP); - glowShader(); + Shader.TileMode.CLAMP)); + c.drawRect(0, 0, w, h, p); + return result; } + @Override protected void onDraw(Canvas c) { - if (base == null) shaders(); - p.setShader(base); - c.drawRect(0, 0, getWidth(), getHeight(), p); - p.setShader(null); - Bitmap art = currentArt(); - if (previousArt != null) - drawArt(c, previousArt, art == null ? (int) (255 * (1 - artMix)) : 255); - drawArt(c, art, (int) (255 * artMix)); - if (art != null || previousArt != null) { - c.drawColor(((int) (dim * 255) << 24) | 0x00040810); + destination.set(0, 0, getWidth(), getHeight()); + if (previousFrame != null) c.drawBitmap(previousFrame, null, destination, paint); + if (frame == null) { + c.drawColor(Ui.BG); + return; } - p.setShader(glow); - p.setAlpha(art == null ? 150 : 65); - c.drawRect(0, 0, getWidth(), getHeight(), p); - p.setAlpha(255); - p.setShader(left); - c.drawRect(0, 0, getWidth(), getHeight(), p); - p.setShader(bottom); - c.drawRect(0, 0, getWidth(), getHeight(), p); - p.setShader(null); + paint.setAlpha(previousFrame == null ? 255 : (int) (mix * 255)); + c.drawBitmap(frame, null, destination, paint); + paint.setAlpha(255); } - private void drawArt(Canvas canvas, Bitmap art, int alpha) { - if (art == null || art.isRecycled() || alpha == 0) return; - float scale = - Math.max(getWidth() / (float) art.getWidth(), getHeight() / (float) art.getHeight()); - float w = art.getWidth() * scale, h = art.getHeight() * scale; - destination.set( - (getWidth() - w) / 2, (getHeight() - h) / 2, (getWidth() + w) / 2, (getHeight() + h) / 2); - p.setAlpha(alpha); - canvas.drawBitmap(art, null, destination, p); - p.setAlpha(255); + @Override + public boolean isOpaque() { + return true; } void stopAnimations() { if (animator != null) animator.cancel(); - if (imageAnimator != null) imageAnimator.cancel(); - previousArt = null; - artMix = 1; + previousFrame = null; + mix = 1; + } + + void pause() { + active = false; + generation++; + renderer.getQueue().clear(); + stopAnimations(); + } + + void resume() { + active = true; + if (dirty || frame == null) requestRender(); } void release() { - stopAnimations(); + pause(); wallpaper = null; mediaArt = null; + frame = null; + dirty = true; invalidate(); } + + void shutdown() { + release(); + renderer.shutdownNow(); + } } diff --git a/docs/UPDATE_NOTES.md b/docs/UPDATE_NOTES.md index 5bd8bd6..1acdbe2 100644 --- a/docs/UPDATE_NOTES.md +++ b/docs/UPDATE_NOTES.md @@ -1 +1 @@ -Adds scheduled update checks, TV notifications, and downloading/installing Luma updates directly from Settings. Includes the fix for missing app images and wallpaper after TV wake. Your appearance, screensaver, app order, and Home routing settings are preserved. +Improves navigation performance on integrated Android TVs by precomposing cinematic backgrounds off the main thread. Reduces redundant tile shadows while keeping focus animations, dynamic colors, and the existing spacious layout. Image work and caches are released when leaving Home. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 7e568e6..54aee34 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -48,7 +48,7 @@ No launcher application was disabled or uninstalled. Screensaver selection at th Build validation uses aapt2, javac, D8, zipalign, and apksigner signature verification. There are no third-party runtime libraries. -Final APK (1.1.5): 2,753,622 bytes. SHA-256: `9556c053f5c1ebb7e7b9414596ee2b2185a37161044538617490713bb9dd8228`. +Final APK (1.1.6): 2,753,622 bytes. SHA-256: `59527fde9ca270d76864406dadbdad219905fbfdf75e853b536ca09e51811cdd`. ## Updater regression — October 18, 2026 @@ -65,3 +65,34 @@ Testing exposed a device-specific consequence of legacy APK/file installation: A The final real upgrade, **1.1.4 → 1.1.5**, was downloaded from production Git and approved with the TV remote. The complete enabled-accessibility-service list matched before and after, including Luma Home, Projectivy, and Button Mapper. Restricted-settings authorization remained allowed, and the TV returned directly to Luma. No ADB install or accessibility repair was used for that final upgrade. Prior temporary configuration changes from failed installation-method tests were restored. The source classification follows Android's [PackageInstaller source definitions](https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_OTHER); the platform's [file-source restriction implementation](https://android.googlesource.com/platform/frameworks/base/+/143db55921dd%5E%21/) explains the behavior encountered during the earlier file-install tests. + +## Integrated TV rendering — October 19, 2026 + +The authorized second device (`192.168.50.200:5555`) is a TCL Smart TV Pro / G08, Android 14 (API 34), ARM Cortex-A73 cores, Mali-G52 OpenGL renderer, approximately 2.34 GiB physical RAM. Its existing 1920 × 1080 render override and density 320 were retained. About 1 GiB was available at diagnosis; Android reported no thermal throttling. The original installed version was 1.1.5. + +A repeatable ADB D-pad sequence on 1.1.5 reported 627 rendered frames, 310 missed frame deadlines (49.44%), median 57 ms and 90th percentile 69 ms in `dumpsys gfxinfo`. Frame timing was recorded on the TV itself and is independent of ADB/Tailscale latency. + +A separate same-signature `PerformanceInstrumentation` diagnostic isolates the scene and tile shadows. It requests the same first-six-tile sequence 36 times with 350 ms between selections; this includes moving to/from the next row. Android `FrameMetrics.TOTAL_DURATION` includes renderer/queue waits and differs from the histogram summary in `gfxinfo`. These are comparable A/B samples from the same TV, rather than benchmarks across different devices: + +| Rendering variant | Frames | Median | 90th percentile | Frames over 16.7 ms | +| --- | ---: | ---: | ---: | ---: | +| 1.1.5 unchanged | 433 | 85.97 ms | 89.50 ms | 433 (100%) | +| 1.1.5 background hidden | 366 | 9.22 ms | 10.46 ms | 0 | +| 1.1.5 tile shadows removed, background restored | 433 | 84.90 ms | 87.39 ms | 433 (100%) | +| Precomposed background, original shadows | 638 | 14.40 ms | 25.79 ms | 185 (29.0%) | +| 1.1.6 background and focused shadow enabled | 639 | 12.99 ms | 17.00 ms | 64 (10.0%) | +| 1.1.6 shadows removed for diagnosis only | 640 | 12.67 ms | 13.59 ms | 0 | + +The full-screen shader/transparency passes were the dominant bottleneck on this renderer. Removing redundant shadows after fixing that bottleneck reduced the remaining tail latency. This supports an application rendering optimization issue exposed by this TV's graphics implementation; there is no evidence here that replacing the TV or adding RAM is necessary. This is a short controlled navigation sample, not a claim of universally perfect 60 fps. + +Version 1.1.6 composes the original artwork, accent glow, darkening, and gradient protection on one background worker into opaque textures no larger than 960 × 540. Each texture is about 1.98 MiB. The worker has one pending-request slot, discards stale results, and times out after two idle seconds. Navigation crossfades the finished textures rather than regenerating full-screen shaders each frame. Only the focused tile casts a shadow, and its parent no longer casts a duplicate shadow. Focus enlargement, smooth scrolling, app-colored accents, and user preferences remain enabled. This follows Android's guidance on [reducing overdraw](https://developer.android.com/topic/performance/rendering/overdraw). + +The enhanced wake regression passed cold launch, interrupted loading followed by pause/resume, memory trim recovery, existing-image reuse, partial-grid recovery, composed-texture resolution/nonblank checks, release of all composed/source textures on stop, screensaver dismissal resuming rendering, and five stop/start cycles. No preferences were rewritten by the diagnostic. Temporary test APKs are not part of the published launcher. + +Raw local captures are in `output/performance/` (ignored by Git), including the original screenshot, A/B timings, final navigation frames, memory/idle samples, and final screenshot. + +The original D-pad workload was then repeated against the final installed APK: **853 frames, 12 missed deadlines (1.41%)**, median 13 ms, 90th percentile 24 ms, and no slow bitmap uploads. The original missed-deadline rate was 49.44%. Screenshots retain the mountain artwork, focus enlargement, five-column layout, and partial second row. The difference from the isolated benchmark reflects using actual D-pad input and more repeated scrolling. + +Foreground PSS was 43,742 KiB (42.7 MiB), and background PSS was 35,803 KiB (35.0 MiB). The launcher consumed zero CPU ticks over five seconds while Android settings was foreground. Source/composite caches are cleared when stopped; actual heap reclamation remains Android's responsibility. These short samples do not establish overnight endurance. + +The TV's Home override was already off (no enabled accessibility services) and was retained. A physical Home-key injection returns to Google Home on this TV; opening Luma directly and repeated Back stays in Luma. No default-launcher, picture, power, resolution, or accessibility settings were changed. The optimized APK was installed only on the authorized TV at `.200`; the onn was not operated during this investigation. Version 1.1.6 is published in the existing Git update feed for the other devices. diff --git a/output/Luma.apk b/output/Luma.apk index feb5eb3..096b009 100644 Binary files a/output/Luma.apk and b/output/Luma.apk differ diff --git a/output/Luma.apk.idsig b/output/Luma.apk.idsig index 3e3d41b..52ec58e 100644 Binary files a/output/Luma.apk.idsig and b/output/Luma.apk.idsig differ diff --git a/output/update.json b/output/update.json index a706e5f..fef655a 100644 --- a/output/update.json +++ b/output/update.json @@ -1,11 +1,11 @@ { "schema": 1, "packageName": "tv.luma.launcher", - "versionCode": 8, - "versionName": "1.1.5", + "versionCode": 9, + "versionName": "1.1.6", "minSdk": 26, "apk": "Luma.apk", "size": 2753622, - "sha256": "9556c053f5c1ebb7e7b9414596ee2b2185a37161044538617490713bb9dd8228", - "notes": "Adds scheduled update checks, TV notifications, and downloading/installing Luma updates directly from Settings. Includes the fix for missing app images and wallpaper after TV wake. Your appearance, screensaver, app order, and Home routing settings are preserved." + "sha256": "59527fde9ca270d76864406dadbdad219905fbfdf75e853b536ca09e51811cdd", + "notes": "Improves navigation performance on integrated Android TVs by precomposing cinematic backgrounds off the main thread. Reduces redundant tile shadows while keeping focus animations, dynamic colors, and the existing spacious layout. Image work and caches are released when leaving Home." } diff --git a/tests/device/AndroidManifest.xml b/tests/device/AndroidManifest.xml index db38d59..52f018c 100644 --- a/tests/device/AndroidManifest.xml +++ b/tests/device/AndroidManifest.xml @@ -3,4 +3,5 @@ + diff --git a/tests/device/PerformanceInstrumentation.java b/tests/device/PerformanceInstrumentation.java new file mode 100644 index 0000000..b07ab95 --- /dev/null +++ b/tests/device/PerformanceInstrumentation.java @@ -0,0 +1,102 @@ +package tv.luma.launcher.tests; + +import android.app.Activity; +import android.app.Instrumentation; +import android.content.ComponentName; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import java.lang.reflect.Field; +import java.util.Map; + +/** Same-signature on-device A/B rendering benchmark; never shipped with Luma. */ +public final class PerformanceInstrumentation extends Instrumentation { + private Object field(Object o, String name) throws Exception { + Field f = o.getClass().getDeclaredField(name); + f.setAccessible(true); + return f.get(o); + } + + @Override + public void onCreate(Bundle args) { + super.onCreate(args); + start(); + } + + @Override + public void onStart() { + Bundle result = new Bundle(); + try { + Activity activity = + startActivitySync( + new Intent(Intent.ACTION_MAIN) + .setComponent( + new ComponentName("tv.luma.launcher", "tv.luma.launcher.MainActivity")) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + Thread.sleep(4000); + View scene = (View) field(activity, "scene"); + Map tiles = (Map) field(activity, "tiles"); + View[] items = tiles.values().toArray(new View[0]); + java.util.List times = + java.util.Collections.synchronizedList(new java.util.ArrayList<>()); + android.os.HandlerThread listener = new android.os.HandlerThread("frame-metrics"); + listener.start(); + activity + .getWindow() + .addOnFrameMetricsAvailableListener( + (w, f, d) -> times.add(f.getMetric(android.view.FrameMetrics.TOTAL_DURATION)), + new android.os.Handler(listener.getLooper())); + StringBuilder report = new StringBuilder(); + for (int mode = 0; mode < 3; mode++) { + final int variant = mode; + runOnMainSync( + () -> { + scene.setVisibility(variant == 1 ? View.INVISIBLE : View.VISIBLE); + if (variant == 2) + for (View item : items) { + try { + ((View) field(item, "art")).setOutlineProvider(null); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + Thread.sleep(700); + times.clear(); + for (int i = 0; i < 36; i++) { + View target = items[(i % 12 < 6 ? i % 6 : 11 - i % 12) % Math.min(items.length, 6)]; + runOnMainSync(target::requestFocus); + Thread.sleep(350); + } + java.util.List sample; + synchronized (times) { + sample = new java.util.ArrayList<>(times); + } + java.util.Collections.sort(sample); + report.append("Variant=").append(mode).append(" frames=").append(sample.size()); + if (!sample.isEmpty()) + report + .append(" medianMs=") + .append(sample.get(sample.size() / 2) / 1e6) + .append(" p90Ms=") + .append(sample.get((int) (sample.size() * .9)) / 1e6) + .append(" over16ms=") + .append(sample.stream().filter(t -> t > 16666667).count()); + report.append('\n'); + try (java.io.FileWriter out = + new java.io.FileWriter( + new java.io.File( + getTargetContext().getExternalFilesDir(null), "performance.txt"))) { + out.write(report.toString()); + } + } + listener.quitSafely(); + result.putString( + "stream", report.toString() + "PASS: background and shadow A/B benchmark completed\n"); + finish(Activity.RESULT_OK, result); + } catch (Exception e) { + result.putString("stream", e.toString()); + finish(Activity.RESULT_CANCELED, result); + } + } +} diff --git a/tests/device/WakeRegressionInstrumentation.java b/tests/device/WakeRegressionInstrumentation.java index f019d99..c8ed824 100644 --- a/tests/device/WakeRegressionInstrumentation.java +++ b/tests/device/WakeRegressionInstrumentation.java @@ -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( () -> {