Skip to content

Run JS interpreter on headless (USE_DUMMY_TFT) builds - #3106

Open
jdankney wants to merge 1 commit into
BruceDevices:devfrom
jdankney:fix/headless-interpreter
Open

jdankney wants to merge 1 commit into
BruceDevices:devfrom
jdankney:fix/headless-interpreter

Conversation

@jdankney

@jdankney jdankney commented Nov 17, 2026 •

Copy link
Copy Markdown

On USE_DUMMY_TFT builds the loop() that sets interpreter_state=2 is compiled out, so interpreterHandler blocks forever at 'while (interpreter_state != 2)' and no script ever runs. Promote the task to the running state directly on headless, where there is no foreground/background display loop to do it.

Fixes #3105

Proposed Changes

On headless (USE_DUMMY_TFT) builds, the JS interpreter never executes a script. interpreterHandler() (src/modules/bjs_interpreter/interpreter.cpp) waits on while (interpreter_state != 2), but the only code that sets interpreter_state = 2 lives in the non-headless loop() in src/main.cpp, which is compiled out under USE_DUMMY_TFT. The headless loop() never services it, so the task prints init interpreter and then blocks forever — scripts never run, whether launched via the serial js command or the WebUI.

This affects every headless env (seeedstudio-xiao-esp32s3, esp32-s3-devkitc-1, esp32-s3-devkitc-1-psram), where JS is one of the few ways to drive the device.

The fix marks the task as running directly on headless builds, since there is no foreground/background display loop to promote it. The task already allocates the engine, evals the script, and cleans up (stopInterpreterTask()) independently of loop(), so no other change is needed. Non-headless builds are untouched.

Types of Changes

Bugfix. No API or behavior change on screen-based builds (guarded by #if defined(USE_DUMMY_TFT)).

Verification

On an ESP32-S3 (N16R8) headless build (esp32-s3-devkitc-1-psram, USE_DUMMY_TFT=1):

Before: js /test.js prints init interpreter then hangs; the script body never runs and no files are written.

After: a script runs to completion — serial shows init interpreter → context created → deinit interpreter, storage.write(...) creates files on LittleFS, and a sub-GHz capture script sweeps frequencies and saves a .sub.

Minimal repro script:

storage.write("/test_ran.txt", "ok\n");
Run js /test.js, then confirm /test_ran.txt exists (cat /test_ran.txt).

#### Testing ####

Verified manually on hardware (see Verification). Not covered by automated tests; the interpreter task is hardware/RTOS-dependent and the repo has no interpreter test harness for headless builds.

#### Linked Issues ####

Fixes #3105

#### User-Facing Change ####

```release-note
Fix JavaScript interpreter hanging on headless (USE_DUMMY_TFT) builds; scripts now run from the WebUI and serial as expected.

Further Comments

Root cause is a single missing state transition on headless. interpreter_state = 2 is assigned in exactly one place (the #if !defined(USE_DUMMY_TFT) loop()); the WebInterface does not touch it. Happy to adjust the approach if you'd prefer the headless loop() service interpreter_state instead of the task self-promoting.

On USE_DUMMY_TFT builds the loop() that sets interpreter_state=2 is
compiled out, so interpreterHandler blocks forever at 'while
(interpreter_state != 2)' and no script ever runs. Promote the task to
the running state directly on headless, where there is no foreground/
background display loop to do it.

Fixes BruceDevices#3105

This branch has not been deployed

No deployments
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