Repository navigation
Description
Summary
A sketch that never calls .setScreenMap() in setup() — for example the stock Blink example — shows an empty canvas in the viewer. The LEDs update in WASM, but the renderer never receives a layout for them.
FastLED does create a default layout for such strips, but only on the first frame, after the worker has already taken its one and only look at the layouts.
Where it happens
- The worker calls
extern_setup(), then reads layouts exactly once withgetScreenMapData():
src/fastled/frontend/modules/core/fastled_background_worker.ts:627-668. Ifsetup()registered none, the result is{}. - FastLED creates the missing default layout lazily, when a frame is exported:
getFrameData()/jsOnFrame()→jsFillInMissingScreenMaps()in FastLEDsrc/platforms/wasm/js_bindings.cpp.hpp("Creating linear screenmap for N"). - That function calls
_jsSetCanvasSize(), which only logsScreenmap update available (worker will poll via getScreenMapData). - Nothing polls again. Nothing in the frontend posts the
screenmap_updatemessage thathandleScreenMapUpdate()(fastled_background_worker.ts:932) handles. The graphics manager keeps an empty layout for the rest of the session.
Reproduction
Observed 2026-09-14 on Linux (WebKitGTK 2.52, feat/kernal-api-migration build), with fastled <sketch> --test --test-screenshot ...:
- Blink (no
setScreenMap,delay()-based): the canvas stays empty. - The same 60-LED strip with a layout set in
setup()renders and animates:Red/blue flips every 500 ms: X11 in-page capturesfl::ScreenMap screenMap = fl::ScreenMap::DefaultStrip(NUM_LEDS, 1.5f, 0.5f); FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS).setScreenMap(screenMap);
RRBBRRRRBBRR; Wayland capturesRBRRBB.
This is independent of the renderer path: it reproduces on both X11 and Wayland.
Suggested fix
Have the worker pick up layouts that appear after setup(), for example:
- Re-read
getScreenMapData()after a frame whenever the frame data lists a strip with no cached layout (cheap: only runs until every strip has one), or - Make FastLED's
_jsSetCanvasSize()actually notify the worker (the comment saysEM_JShad partial-link issues; a flag the worker checks per frame would avoid that).
The frontend also lives in FastLED at src/platforms/wasm/compiler/modules/core/fastled_background_worker.ts, so the fix should land in both places, or wherever the frontend is now owned.
Acceptance
- The unmodified Blink example shows its LEDs in the viewer.
- A
--testrender check covers a sketch with nosetScreenMap()call.
Activity
zackees commentedon Sep 17, 2026
This also hits sketches that DO call
setScreenMap()insetup(), and it blocks #247's verification.Reproduced on
main(4ebcabd), NVIDIA Wayland, with a 60-LED strip whosesetup()is exactly the workaround this issue suggests:fastled <sketch> --test --test-screenshot ... --test-exit-on-errorexits 125,fastled: viewer did not render a canvas before --test-ready-timeout-secs, and no screenshot is written. Viewer log:The layout is fully present in that update, and the renderer still has none: the worker's single
getScreenMapData()read happened before it arrived. So the trigger is ordering, not whethersetup()registers a map, and the "set a screen map insetup()" workaround does not reliably avoid it.Two consequences:
--testrender, and that render fails here for this reason, not for a WebGL2 reason. The WebGL2 part of migration: real WASM viewer fails OffscreenCanvas WebGL2 compatibility in Linux smoke #247 now behaves as intended:webgl2:falseon OffscreenCanvas falls back tocontextType: "main_thread"without error.Suggested RED -> GREEN for the fix: the command above exits 125 with no screenshot before, and exits 0 with a screenshot showing lit LEDs after.
fix(viewer): recover screen maps created after setup() (#screenmap-25…
ci: render a sketch on Linux in a focused lane instead of the wheel s…
release: 2.0.21