Skip to content

fix(lvgl): a new app starts on a fresh screen (release 0.10.1) - #58

Merged
genmon merged 1 commit into
mainfrom
lvgl-fresh-screen-per-app
Oct 5, 2026
Merged

genmon merged 1 commit into
mainfrom
lvgl-fresh-screen-per-app

Conversation

@genmon

@genmon genmon commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

App reset emptied the active LVGL screen but kept the screen object, so a style an app set on the screen itself (lvgl.bind(name).screen():set{ bg_color = ... }) outlived it and outranked every later app's theme. On a clock, an app that whitened its screen left every later app with a white ring around whatever it drew, until a reboot. The display's Lua-set theme leaked the same way.

LvglModule::onAppReset now:

  • uninstalls the theme Lua set on each display, through luavgl's own set_theme(nil) so its bookkeeping agrees;
  • replaces the active screen with a new one, which LVGL deletes with everything on it.

Releases 0.10.1 (library.json, idf_component.yml, changelog).

Tested

  • Reproduced the bug on the clock's hardware: a white-screen app, then an unchanged smiley, gives a white ring.
  • In hawthorn-firmware's clock sim, with this patch over 0.9.1:
    • that sequence now shows the smiley's dark ground;
    • six rounds of the swap end clean;
    • the agent-status overlay still repaints;
    • a plain app is byte-identical whether or not a red-theme app ran first.
  • Unit tests (269), static analysis and m5stick-lvgl pass.

🤖 Generated with Claude Code

App reset emptied the active screen (lv_obj_clean) but kept the screen
object, so anything an app set on the screen itself outlived it —
`lvgl.bind(name).screen():set{ bg_color = ... }`, the one-property tweak
luavgl documents, lands as a local style, and a local style outranks every
later app's theme. On a clock, one app whitened its screen and every app
after it showed a white ring around whatever it drew, until a reboot. The
display's theme leaked the same way: one Lua state lives as long as the
device, and luavgl keeps a set_theme installed in it until replaced.

LvglModule::onAppReset now uninstalls the theme Lua set on each display
(luavgl's own set_theme(nil), so its per-display record agrees) and
replaces the active screen with a new one, which LVGL deletes along with
everything on it. Stale Lua handles are safe as before: luavgl invalidates
them on C-side deletion, and its bound constructors resolve the active
screen at call time.

Checked in hawthorn-firmware's clock sim (the same patch over 0.9.1): an
app that whitens the screen, then a smiley, now shows the smiley's dark
ground; six rounds of that swap end clean; the agent-status overlay still
repaints; and a plain app is byte-identical whether or not an app that
installed a red theme ran first. The bug itself reproduced on the clock's
hardware. Unit tests, static analysis and the m5stick-lvgl example pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@genmon
genmon merged commit 8e4a130 into main Oct 5, 2026
4 checks passed
@genmon
genmon deleted the lvgl-fresh-screen-per-app branch October 5, 2026 15:05
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