Skip to content

appkit and Home: no restart after System, and a round-screen layout - #51

Merged
bdbarnett merged 2 commits into
mainfrom
round-home-heap
Nov 10, 2026
Merged

bdbarnett merged 2 commits into
mainfrom
round-home-heap

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

Going back from System to Home restarted a Waveshare RP2040-Touch-LCD-1.28 (228 KB heap), and on its round screen the shell's Home button and Home's header fell outside the circle. This fixes both.

The restart came from fragmentation the switch itself caused. The launcher checks the largest free block after closing an app, but it ran that check inside the calls that delivered the switch. On this board call frames live on the heap, and those calls, the request's timer and its closure had all been allocated while the old app ran, among its objects, so they split the space the close had just freed. A request now uses two timers made with the launcher, closes the old app from the timer, and checks the heap and starts the next app on the main loop's next turn, or from a scheduled call where nothing runs the loop. System's close no longer imports wifi_manager just to cancel it. The threshold is unchanged.

On a round panel (appkit.shell.is_round(): the board's driver says so, or it's a GC9A01) the Home button is now a small round button on the diagonal, and Home puts its pages and tabs in the square inside the circle, two apps by two, with the gear centred above. Square and rectangular screens are unchanged.

How it was checked, on the board: twenty Home-System round trips by tapping, with no restart; the largest free block after each close stayed at 49-62 KB (38 KB after the first), against a 28 KB threshold. Before, it fell to 13 KB and the board restarted within ten trips. Images rebuilt from the frames sent to the panel show every object of Home and System inside the circle. Headless renders of Home at 720x720 and 800x480 match main pixel for pixel. The launcher contract passes on CPython and unix MicroPython (384k and 8M heaps) with two new checks, each failing with its fix taken out, and the appkit and touchkit shell tests pass.

Not checked: other round boards, and CircuitPython on a board.

Fixes #49. Fixes #50.

After closing an app the launcher checks the largest free block and
restarts the program when it is too small. On a board that keeps call
frames on the heap, the check ran inside the calls that delivered the
switch, and those calls, the request's timer and its closure were all
allocated while the old app ran, among its objects. They split the space
the close had just freed, so a board with a 228 KB heap restarted on a
plain System-to-Home switch.

A request now uses two timers made with the launcher, closes the old app
from the timer, and checks the heap and starts the next app on the main
loop's next turn (a scheduled call where nothing runs the loop). System's
close no longer imports wifi_manager just to cancel it.

On a Waveshare RP2040-Touch-LCD-1.28, twenty Home-System round trips ran
without a restart, the largest free block after each close staying at
49-62 KB (38 KB at the first, threshold 28 KB); before, it fell to 13 KB
and the board restarted within ten trips. The launcher contract passes
on CPython and unix MicroPython, with a new check for each path.
On a round display the shell's Home button sat in the top-right corner,
outside the circle, and Home's title, gear and tab bar were clipped.
appkit.shell.is_round() now tells a round panel (the board's driver says
so, or it is a GC9A01). There the Home button is a small round button on
the diagonal, and Home puts its pages and tabs in the square inside the
circle, two apps by two, with the gear centred above them.

Checked on a Waveshare RP2040-Touch-LCD-1.28 from the frames sent to the
panel: every object of Home and System lies inside the circle. Home on
720x720 and 800x480 renders pixel for pixel as before.
@bdbarnett
bdbarnett merged commit 4df8bdb into main Nov 10, 2026
6 checks passed
@bdbarnett
bdbarnett deleted the round-home-heap branch November 10, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant