Skip to content

Bit World: frames and sprites outside the heap where the firmware has offheap - #198

Merged
bdbarnett merged 3 commits into
mainfrom
bit-world-offheap
Nov 20, 2026
Merged

bdbarnett merged 3 commits into
mainfrom
bit-world-offheap

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Bit World's three full-screen backgrounds (2.3 MB at 800x480) and its sprite atlas now come from pixel_bytes(), which makes an offheap.Buffer where the firmware has the offheap module (PyDevices/omnipython-builds#602) and a bytearray everywhere else (CPython, CircuitPython, older firmware). The garbage collector no longer reads every word of them. On MicroPython without offheap, Bit World prints one line saying collections will pause the picture.

Measured on an ESP32-S31 4.3 inch 800x480 board, 70 s each, with the same firmware for both (#602's image):

apps main this branch
frame a collection lands in 239-260 ms 47-71 ms
gc.collect() with the app alive 193-195 ms 24-25 ms
bytes allocated per frame 1,087 916
frames per second 11.6 24.6

tests/repaint_check.py passes on unix MicroPython built with offheap (800x480, every redraw matches a full draw, with the frames in Buffers), and the Bit World tests pass on CPython, where the frames stay bytearrays. The app's other bytearrays are small and stay as they are.

Refs #189.

… offheap

The three full-screen backgrounds (2.3 MB at 800x480) and the sprite
atlas were bytearrays, and MicroPython's collector reads every word of
them, so each collection stopped the picture for 200-360 ms on an
ESP32-S31. pixel_bytes() makes an offheap.Buffer where the firmware has
offheap, and a bytearray everywhere else (CPython, CircuitPython, older
firmware), where MicroPython also says why collections will pause.
@bdbarnett
bdbarnett marked this pull request as ready for review November 20, 2026 19:19
@bdbarnett
bdbarnett merged commit 6053469 into main Nov 20, 2026
14 checks passed
@bdbarnett
bdbarnett deleted the bit-world-offheap branch November 20, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant