Skip to content

Precompute artwork palettes and restore fast theme fades - #24

Merged
XDanfr merged 2 commits into
masterfrom
perf/dynamic-theme
Oct 15, 2026
Merged

XDanfr merged 2 commits into
masterfrom
perf/dynamic-theme

Conversation

@XDanfr

@XDanfr XDanfr commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Artwork Dynamic currently computes colours during focus changes, averages unrelated artwork hues, and animates the root theme while replacing its expressive tokens. This makes browsing do avoidable work and can produce muddy colours.

Successful Coil image loads now queue background palette extraction from the decoded bitmap. A 96×96 sample feeds AndroidX Palette; Aperture ranks populated, saturated swatches and ignores transparent pixels, near-black/white and near-grey candidates. Hardware bitmaps use a small software sample without recycling the displayed image. At most two extractions run concurrently, and requests for the same artwork coalesce.

Room stores the selected seed by artwork path and extraction version. Database migration 7→8 adds the palette table while retaining the existing library and playback tables. Focus changes only observe the table after a 140 ms settle delay: they do not download or decode artwork. A pending row updates the theme as soon as extraction saves it. Metadata/artwork changes select the current path automatically; renaming without changing artwork reuses its palette. Cinematic Ambient uses the same store and can prefetch a missing next backdrop using the renderer's URL.

Browsing and cinematic logos share Material tonal colour roles. Dynamic primary, secondary and tertiary roles are opaque, with paired foreground/container colours. The secondary source has reduced saturation and the tertiary source shifts hue by 60 degrees; these are Aperture palette choices. Theme colours fade with the existing fast Material Expressive effects spring. The token object and semantic colour scheme stay stable throughout the fade, so unchanged spacing, shape and motion consumers are not invalidated every frame. Named themes and the approved Material TV logo palette remain available.

Validation on 709ba94:

  • Standard debug APK assembly passed.
  • All 28 standard debug unit tests passed, including focus debounce, metadata replacement, pending table-row arrival, unchanged-artwork reuse and cancellation.
  • All 10 instrumentation tests passed on Television_1080p, Android 16. These cover represented-hue selection, transparency and monochrome fallback, hardware bitmap ownership, persistent reuse, extraction-version invalidation, library-preserving migration, one display fetch with no second palette request, and a real intermediate fade colour with stable tokens and no per-frame recomposition of unrelated content.
  • Instrumentation used a temporary application ID through an uncommitted Gradle init script to preserve the emulator's differently signed Aperture installation. Temporary test packages were removed.
  • git diff --check passed.

Physical-TV frame-time profiling and subjective review against a real media library remain outstanding. No measured FPS or speedup is claimed.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@XDanfr XDanfr changed the title Reduce dynamic theme work while browsing artwork Precompute artwork palettes and restore fast theme fades Oct 15, 2026
@XDanfr
XDanfr merged commit 01a0914 into master Oct 15, 2026
1 check passed
@XDanfr
XDanfr deleted the perf/dynamic-theme branch October 15, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants