Repository navigation
Description
Summary
Hoisted from #2167 (comment) by @ewowi to track remaining driver issues separately from the Channels API discussion.
Testing on ESP32-S3 with latest master reveals three distinct issues across the LED drivers when used via the Channels API:
Issue 1: I2S driver starves websockets (~1 FPS)
Status: Regression — this was previously fixed (delayMicroseconds busy-wait fix, Mar 9) but has resurfaced.
- When using I2S as the channel driver, websocket throughput drops to ~1 FPS
- LEDs show the correct output — the rendering itself is fine
- The I2S driver appears to be monopolizing the RTOS task, starving the network task layer
- This affects boards smaller than ESP32-P4 (tested on ESP32-S3, previously also on ESP32-D0)
- RMT does not exhibit this problem
Root cause hypothesis (from @zackees): The network stack has two layers — ISR layer and task layer. The task layer is what's getting starved. A vTaskDelay(1) or delay(1) between frames in the main loop may alleviate it, suggesting the I2S driver needs cooperative yield points.
Issue 2: SPI driver — incorrect LED output
Status: Partially fixed in #2251 (buffer growth on channel reuse), but still not rendering correctly.
- SPI driver does not slow down websockets (good)
- However, LEDs are not showing the right output on ESP32-S3
- Video evidence: https://github.com/user-attachments/assets/afe42d51-a635-42a4-a838-bca5b56bfdf9
This is a separate rendering bug from the buffer issue fixed in #2251.
Issue 3: FastLED Audio driver reduces FPS (100 → 60)
Status: Ongoing side-effect.
- With the FastLED Audio driver active, FPS drops from ~100 to ~60
- @ewowi asks: is the audio driver running on the same RTOS task as the LED driver code? If so, the slowdown is expected, and running audio on a separate task would resolve it.
Driver behavior matrix (ESP32-S3, latest master)
| Driver | Websocket speed | LED output | Notes |
|---|---|---|---|
| RMT | Normal | Correct | Works as expected |
| SPI | Normal | Incorrect | Rendering bug persists after #2251 |
| I2S | ~1 FPS | Correct | Task starvation regression |
Environment
- Board: ESP32-S3
- Project: MoonLight using FastLED Channels API
- FastLED: latest master as of 2026-04-11
Related
- Parent discussion: FastLED Channels API #2167
- SPI buffer fix: fix(esp32): resolve SPI/LCD_SPI buffer growth failure on channel reuse #2251
- Previous websocket starvation fix (delayMicroseconds): commit from Mar 9
- Cooperative waiting refactor: commit from Mar 10
@ewowi — continuing the conversation from #2167 here to keep things organized. Thanks for the detailed testing breakdown!
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(esp32): guarantee deep yield in driver wait loops (Refs #2254)
zackees commentedon Apr 18, 2026
Progress update — picking this up (step 0: plan)
Kicking off work focused on Issue 2: SPI driver — incorrect LED output on ESP32-S3.
Filed sibling issue #2288 with a concrete plan: the current autoresearch pipeline only captures a single
FastLED.show()per test case, so the reported "black frame between displays" symptom (frame #1 correct, frame #2 zeroed/corrupted, cycle repeats) is invisible to the test matrix today. See #2288 for the full problem write-up and implementation sketch.Plan being executed now (will comment again at each step):
AutoResearchTest.cpp::capture()+AutoResearchRemote.cppRPC handlers) — in progress.capture()to acceptframeCountand arm RX once, then do N back-to-backFastLED.show()calls, decoding N frames from the edge stream.frameCount/frameComparisononrunSingleTestJSON-RPC; return per-frame pass/fail with a namedfailureClass.bash autoresearch --spion esp32s3 default toframeCount=2so the regression is caught automatically.bash autoresearch --spion the attached ESP32-S3 and confirm the second-frame bug now shows up as a hard FAIL.Board attached right now: ESP32-S3.
zackees commentedon Apr 18, 2026
Progress update — step 1/2: firmware + CLI wired for multi-frame capture
What's done (not yet running on hardware):
Firmware (
examples/AutoResearch/):AutoResearchTest.h/.cpp—autoResearchChipsetTiming()andautoResearchChipsetTimingLegacy()gain anint num_runs_per_pattern = 1parameter. Threaded intoMultiRunConfig::num_runs, which was previously hardcoded to 1. When > 1,print_all_runsalso flips on so per-frame pass/fail shows up in the serial log.AutoResearchRemote.cpp—runSingleTestRPC handler accepts an optionalframeCount(int, validated to [1, 16]). Passed through to the chipset-timing functions. Response now also carriesframeCountand per-pattern entries includerunNumberso frame-1 vs frame-2 failures are distinguishable in JSON.Python (
ci/autoresearch/):args.py— new--frames NCLI flag.phases.py— when buildingrunSingleTestcommands, defaultsframeCount = 2for--spi,1for everything else;--frames Noverrides.context.py::display_pattern_details— showsframes=Nin the header and[frame N]suffix per pattern failure.Detection strategy (minimal, targeted): Each pattern applies the same LED buffer then issues
frameCountconsecutiveFastLED.show()/ capture cycles (RX is re-armed per cycle; TX driver state is untouched). That's exactly the user loop that reproduces the "black frame between displays" in #2254 — if the SPI driver corrupts its DMA buffer after the first show, frame 2 fails and the whole test fails.Acceptance criterion I'm about to verify on the attached ESP32-S3:
bash autoresearch --spimust produce a hard FAIL with frame 2 showing all-zero (or garbage) LED values on at least one pattern. Running now — will post results in the next comment.feat(autoresearch): add --frames N multi-frame capture
feat(autoresearch): add --frames N multi-frame capture (#2293)
zackees commentedon Apr 18, 2026
Progress update — step 2/2: ran on ESP32-S3, multi-frame works, bug did NOT reproduce
Feature shipped:
--frames Nlanded in #2293 (merged to master), defaultframeCount=2for--spi.bash autoresearch --spi --skip-lint --skip-schema --no-fbuildcompiles, flashes, and exercises the new path on the attached ESP32-S3.Confirmed plumbing works. The serial trace shows the RPC going out with the right payload and the firmware obeying:
All 4 bit patterns × 2 frames = 8 captures, 8 PASS on the attached S3 with 100-LED APA102-style strip in loopback.
AUTORESEARCH SUCCEEDED.What this means
The tool change did its job — we now have a regression gate for two-frame degradation. But the specific second-frame bug described in this issue ("black frame between displays") did not reproduce in the minimal autoresearch harness on my board. That is interesting and narrows the hypothesis space:
show()back-to-back with the RX re-arm in between; a tighter or looser cadence could matter.--spihere binds to the channel-API SPI driver. ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 mentions the Channels API SPI path specifically — want to double-check this is the sameSPIdriver name the device enumerates.Next investigation steps I'd suggest (not yet done)
--spi --strip-sizes 300,1000,3000 --frames 2to see if size triggers it.--spi --lanes 2 --frames 2and--spi --lanes 4 --frames 2.show()happens under contention (could be worth a follow-up issue).Action for #2254: Issue 2 (SPI incorrect output) remains open — the tool is now capable of detecting it, but on this board + configuration it is passing. Happy to run any specific sweep you'd like me to try next.
zackees commentedon Apr 18, 2026
Progress update — 550-LED run surfaced a harness false-positive
Tried
bash autoresearch --spi --strip-sizes 550on the ESP32-S3. Device reports PASS, but the pass is not trustworthy:Two distinct harness bugs, independent of #2254
SPIdriver path (esp32s3 withRX_BUFFER_SIZE = 96,100, so the host buffer is not the limit — this is almost certainly an RMT RX symbol-buffer limit inrx_channel->wait()/decode()for long clockless waveforms).examples/AutoResearch/AutoResearchTest.cpp:840-844breaks the per-LED loop whenbyte_offset + 2 >= bytes_captured, and the remaining LEDs are quietly ignored rather than counted as mismatches. So for 550 LEDs the harness checks only the first ~170 and reports "Errors: 0/550".This is a silent false-positive — any second-frame degradation happening past byte ~512 is invisible to the sweep today. That directly affects this issue: if the SPI black-frame bug kicks in past the first chunk (plausible for a DMA corruption after the initial descriptors drain), the current harness would not flag it.
Proposed fix (happy to PR if you greenlight)
bytes_captured < num_leds * 3, count(num_leds - verified_leds)as mismatches and emit[TRUNCATED CAPTURE] verified X of Y LEDsin the log. Do NOT silentlybreakto PASS.Will file this as its own issue and link it back here. 100-LED path still works correctly end-to-end (genuine PASS for both frames).
zackees commentedon Apr 18, 2026
Plan — segmented capture to verify full 550-LED strip via
RxConfig::skip_signalsInvestigation confirms the 512-byte cap is
RMT_RX_DMA_SYMBOL_COUNT = 4096atsrc/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp:1134, not a software decoder limit. For SPI wave8, 4096 symbols ÷ 8 symbols/byte = 512 bytes = ~170 LEDs per pass.The relevant hardware-ish skip feature exists —
RxConfig::skip_signals(src/fl/rx_device.h:218). Implementation atrmt_rx_channel.cpp.hpp:1016-1116(handleSkipPhase) drains the first N symbols through a throwaway buffer via ISR before accumulation starts, so the DMA buffer never sees them. That lets us segment a long strip across multiple captures.Steps (executing now)
Firmware —
examples/AutoResearch/:AutoResearchRemote.cpp— accept optionalskipLeds: intonrunSingleTest(validate [0, 10000]); thread to the chipset-timing functions.AutoResearchTest.cpp/.h— threadskip_ledsdown torunMultiTest()andcapture(). Incapture(), setrx_config.skip_signals = skip_leds * 24(WS2812B = 8 bits/byte × 3 bytes/LED). In the comparator, index TX LEDs asleds[i + skip_leds]so the right segment is compared.skipLedsback in the JSON response.Python —
ci/autoresearch/:4.
args.py— new--skip-leds NCLI flag.5.
phases.py— injectskipLedsintorunSingleTestparams when set.Verify on device — ESP32-S3, 550-LED strip:
6. Rebuild + reflash.
7. Four runs:
--skip-leds 0,170,340,510. Each pass checks one ~170-LED window.8. Report: all four PASS ⇒ full-strip verification is green; any FAIL ⇒ real bug localized to that window.
Out of scope for this pass (flag here, fix separately): the silent-truncation false-positive in the comparator (
AutoResearchTest.cpp:840-844breaks instead of failing whenbytes_captured < expected) — tracked so it doesn't hide bugs going forward.Starting work on a feature branch now. Next update will be the results of step 7.
zackees commentedon Apr 18, 2026
Progress update —
skipLedswired in, but it does NOT work for this capture flowImplementation landed on branch
feat/autoresearch-spi-skip-leds:skipLedsRPC param +--skip-leds NCLI, threaded throughcapture()toRxConfig::skip_signalsand to the comparator's TX index. The code is additive and safe (skipLeds=0is default and equivalent to old behavior).Device run results (ESP32-S3, 550-LED strip, 4-pass sweep)
--skip-leds 0breaks on buffer exhaustion--skip-leds 170RX begin() failed for pin 2— handleSkipPhase timeout--skip-leds 340--skip-leds 510*— not a trustworthy PASS; the 550 LEDs in the count were not actually all checked.Why the skip path fails (root cause)
Looked at
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp:1016-1116—handleSkipPhase()is synchronous and runs insidebegin(). It issuesrmt_receive()on a 64-symbol throwaway buffer and blocks waiting for the ISR to fire, then loops untilmSkipCounter == 0.Our harness flow is:
→ The first skip chunk times out after 5 s × (
SKIP_TIMEOUT_MS),begin()returns false,capture()returns 0. That's the40 sduration (8 captures × ~5 s each).skip_signalsis designed for a continuous-receiver scenario where the TX is already running (or running on a separate task) — not the "arm RX, then fire one-shot TX" pattern the autoresearch harness uses.The deeper issue this exposed
Even with
skipLeds=0, the 550-LED test lies: captures 512 bytes, silentlybreaks the comparator, reports "0/550 errors" as PASS. Before any driver verification is trustworthy on long strips, the harness needs either:bytes_captured < num_leds * 3as FAIL rather than PASS with silent break. (Trivial fix; ~5 lines inAutoResearchTest.cpp:840.)rmt_rx_channel.cpp.hpp:1135;en_partial_rxis enabled for ESP-IDF 5.3+ but only 1 callback's worth seems to make it to the accumulation buffer. Need to investigate why the ISR re-arm isn't firing for subsequent DMA fills during a 5.5 ms SPI transmission. This is the actual fix for verifying long strips.Recommendation
Not going to push the
skipLedsbranch for PR — it's correct code but the underlying mechanism won't let us use it for one-shot validation. Want me to instead:(B) is the real unlock for verifying 550-LED strips correctly.
zackees commentedon Apr 18, 2026
Final status — fix (A) landed, fix (B) blocked on RMT memory-manager refactor
What works now
[TRUNCATED CAPTURE] Only verified 170/550 LEDs (512 bytes captured, needed 1650). Marking 380 unchecked LEDs as mismatches.— no more "0/550 errors" pass that was hiding real bugs. 100-LED regression-free (PASS, 2 frames each × 4 patterns).--strip-sizes 100passes legitimately on ESP32-S3 with the Channel API SPI driver in loopback, with frameCount=2 covering the ESP32-S3 SPI driver: second-frame degradation (black frame between displays) — autoresearch needs two-frame capture #2288 second-frame degradation check.Honest ceiling
The DMA investigation (7 attempts, all committed for posterity)
Branch
feat/autoresearch-spi-skip-ledscontains the full exploration:skipLeds+ multi-passhandleSkipPhasetimes out — expects signal beforebegin()returnswith_dma=falsemeans 4096 is not the DMA bufferRxConfig::use_dmaopt-inwith_dmais baked atrmt_new_rx_channel()timeuse_dmachanges\"user buffer not in the internal RAM\"(fl::vector landed in PSRAM)\"buffer size exceeds DMA capacity\"—mem_block_symbols=64too smallmem_block_symbols=1024RmtMemoryManager:\"RMT RX memory allocation failed for channel 130\"— ESP32-S3 only has 384 total RMT symbols across all channelsEach fix unblocked the previous step and surfaced the next layer of constraint. The last one is structural: ESP32-S3 RMT hardware simply doesn't have enough symbol memory for a 1024-symbol DMA RX buffer while other RMT users (TX for the RMT driver test, discovery, etc.) are also registered. The
RmtMemoryManager's budget enforces this correctly.What stays committed (branch NOT pushed for merge yet)
The following is groundwork, reasonable on its own, no behavior change unless opted-in:
RxConfig::use_dma— opt-in API field (defaultfalse).use_dmatoggles, with heap_caps-DMA raw buffer allocation.[RMT RX] symbols=N callbacks=Cvisible telemetry afterwait()— future regressions on long streams will be diagnosable withoutFL_LOG_RX.What I'd recommend pushing for merge (opening a targeted PR)
Just the truncation-fix commit (
fix(autoresearch,rmt_rx): fail on truncation + 4× DMA buffer for long strips— drop the DMA-buffer bump, keep only the comparator fix). That alone stops the harness from lying on long strips, which is critical for CI trustworthiness regardless of whether #2254 ever gets fully solved.Next investigation if anyone wants to pick it up
The path to actually verifying 550+ LEDs on ESP32-S3 requires refactoring
RmtMemoryManagerto accept larger dynamic RX allocations when DMA is in use. That's a bigger PR of its own and not something I'll do in this thread. Tracker worthy.What this answers for #2254 itself
24 remaining items
feat(audio/fft): add fft_backend.h dispatcher for future ESP-DSP path
refactor(audio/fft): dispatcher for ESP-DSP FFT backend (#2310)
feat(audio/fft): ESP-DSP backend implementation + AudioFftParity test
feat(audio/fft): ESP-DSP backend implementation + AudioFftParity test (…
fix(esp32-s3,i2s): restore websocket throughput when I2S driver is ac…
zackees commentedon May 9, 2026
Cross-link to #2428. The I2S/audio FPS-impact half of this is partially addressed by #2428's default-path removal of
ChannelManagerfrom theshow()call chain — the begin-framewaitForReady()(which currently callstask::run(250, SYSTEM)→pumpCoroutines(1000)→vTaskDelay(1), see #2421 root cause analysis) disappears when channels bind directly to a singleBusTraits<B>::instance()at compile time. Won't fix the I2S driver itself, but removes one of the two tick-aligned waits per frame in the default (non-registry) configuration.zackees commentedon May 21, 2026
Cross-reference: the deep-yield fix for this issue is the root cause of #2420 and #2493
The
pumpCoroutines(1000)→vTaskDelay(max(1, us/tick_period))deep-yield that fixed Issue 1 here (src/platforms/esp/32/coroutine_esp32.impl.hpp:83-86, comment explicitly references this issue) is now the per-frame cost driving two regressions:FastLED.show()callsChannelManager::waitForReady()→ busy-loop →vTaskDelay(1).show()blocks ~16.7 ms for 256 LEDs × 12 strips): same loop, ~8 × 1 ms ticks + 7.6 ms DMA drain wait.The deep-yield is still correct for I2S audio busy-wait paths (the actual cause of websocket starvation here). The regression is that the same yield was applied generically to
ChannelManager::waitForCondition, where it sleeps for prior-frame DMA drain on drivers (PARLIO, RMT, SPI) that don't have a WiFi-starvation risk — their DMA runs entirely in hardware/ISR after the first buffer submit.#2428 (compile-time
Busbinding) is the structural fix — decouples the defaultshow()path fromChannelManagerpolling. Until that lands, a targetedtask::run(0, SYSTEM)(=taskYIELD()) inChannelManager::waitForCondition/IChannelDriver::waitForConditionretains the I2S fix while removing the per-frame tick cost from PARLIO/RMT/SPI.perf(channels): runtime NetworkDetector-gated yield in waitForConditi…
fix(core): adaptive yield in show()'s refresh throttle (FastLED#3762, f…
fix(task): clamp the SYSTEM yield to the caller's budget; drop dead n…
zackees commentedon Aug 20, 2026
Closing after verifying all three reported sub-issues against current
master:The original umbrella has no remaining actionable sub-issue.
fix(autoresearch): recognise the whole SPI family, and triage discove…
fix(autoresearch): three RP SPI harness bugs that reported host failu…