Skip to content

Fix double apply, cache loss, and hidden failures on rotation start - #74

Merged
codenameakshay merged 1 commit into
mainfrom
fix/android-rotation-start
Sep 15, 2026
Merged

codenameakshay merged 1 commit into
mainfrom
fix/android-rotation-start

Conversation

@codenameakshay

Copy link
Copy Markdown
Owner

Three rotation-start bugs, all reproduced on an API 36 emulator:

Before After
Start Applied twice. Start applied the first image, and WorkManager then ran the new periodic request at once, which skipped ahead One apply. The first scheduled run waits one interval
Rejected start (every source fails) Deleted the running rotation's cache. Status still said "running", but every rotation failed Cache untouched, and Rotate now still works
One of two sources fails "index 0 of 1, 1 cached", so the failure was hidden "index 0 of 2, 1 cached"
 startRotation
-  delete the cache dir, then cache sources into it
+  cache into <cache>.staging; swap it in only if at least one source loaded
   save config (+ requestedSourceCount)
   apply the first wallpaper
 schedulePeriodic / scheduleCharging
+  setInitialDelay(interval)

Verification

API 36 emulator, checked with dumpsys wallpaper ids and logcat:

  • Start: the wallpaper id goes 27 → 28, and no worker runs in the next 20 s. Before, it went 22 → 24, with the worker running 0.4 s after start.
  • Rejected start: wallpaper_0.jpg and wallpaper_1.jpg survive, and Rotate now succeeds.
  • Partial failure: the status shows 2 requested and 1 cached.

Tests: JVM tests cover the staging swap (a reject keeps the cache, an accept replaces it) and the WorkManager initial delay. Plugin unit tests: 63 pass.

Local CI (format, analyze, tests, pigeon check, Gradle test/lint/assemble, iOS simulator build): pass.

🤖 Generated with Claude Code

- Start applied the first wallpaper, and WorkManager then ran the new
  periodic request at once, so a second wallpaper was applied and the
  playlist skipped ahead. The periodic and charging requests now wait one
  interval before their first run.
- prepareLocalFiles deleted the cache before it knew whether any new
  source would load. A rejected start therefore wiped the files of the
  rotation that was still running, and every later rotation failed. New
  sources now go into a staging directory that replaces the cache only
  when at least one source loaded.
- totalCount and cachedCount were both the number of cached files, so a
  source that failed to load was invisible. totalCount now reports the
  requested sources.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codenameakshay
codenameakshay merged commit 1fb33ba into main Sep 15, 2026
6 checks passed
@codenameakshay
codenameakshay deleted the fix/android-rotation-start branch September 16, 2026 09:44
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.

1 participant