Skip to content

fix(rmt5): report DRAINING once every strip is on the wire so show() returns async (#2994) - #5350

Merged
zackees merged 2 commits into
masterfrom
fix/2994-rmt5-draining
Nov 21, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/2994-rmt5-draining

Conversation

@zackees

@zackees zackees commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #2994

Root cause

ChannelEngineRMT::poll() returned BUSY for the entire RMT transmission. ChannelManager::onEndFrame() ends every FastLED.show() with waitForReadyOrDraining(), so show() blocked for the full wire time plus the reset latch on every frame. In 3.10.3, led_strip_refresh_async returned immediately. This affects the legacy addLeds<WS2812B, PIN> path on every RMT5 target, including the reporter's ESP32-S3. The PARLIO, I2S-SPI, LCD, UART and RMT4 drivers already report DRAINING.

Fix

poll() now returns:

  • BUSY while strips are still waiting for a hardware channel (mPendingChannels non-empty)
  • DRAINING once every strip has been submitted and the hardware is still sending
  • READY when idle

The state mapping lives in a small transmissionState() helper.

This is safe because strip bytes are copied into the driver's pool buffer (writeWithPadding) before transmit, and ChannelData in-use flags still clear only at READY. Every path that reuses a buffer or the hardware still waits for READY: ChannelManager::onBeginFrame, SlimBridgeController::showPixels, Channel::waitForInUseBuffer, the driver's own show(), and the destructor.

Behaviour note: FastLED.show() on RMT5 now returns while the frame is still on the wire, as in 3.10.3 and with the other drivers. Code that cuts LED power or sleeps the chip immediately after show() must wait for the frame to finish.

Evidence

Host (RED → GREEN): tests/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp now expects DRAINING after a single-strip show(), and in the channel-limit case after the queued strip starts; it still expects BUSY while a strip is pending. Master fails 3 cases; the fix passes 15/15 under --debug (ASAN/UBSAN).

Hardware: ESP32-C6 with AutoResearch timingDriftTest replaying the reporter's sketch (35 LEDs, 5 ms show cadence). The build used --legacy --rmt, because the C6's legacy default is PARLIO and the S3 uses RMT5.

show() mean sequence time (theory 2495 ms)
master 1687 µs (1386 µs inside waitForReadyOrDraining) 2500–2507 ms
this PR 369 µs 2495 ms on every sequence

The legacy-RMT RX loopback test (bash autoresearch esp32c6 --legacy --rmt, 100 LEDs, MSB_LSB_A) passes 4/4 with the fix, so the pixel data stays correct.

Not verified on an ESP32-S3: none is attached to the bench. The C6 run exercises the same RMT5 driver and SlimBridgeController path the S3 uses.

Out of scope: the C6's default PARLIO legacy path has its own ~2.3 ms per-frame cost, with time spent in both onBeginFrame and the driver's show(). That is tracked separately.

Summary by CodeRabbit

  • Bug Fixes
    • RMT5 polling now distinguishes between queued work (BUSY), transmissions still finishing (DRAINING), and completed activity (READY). This provides clearer status while LED strips are submitted to hardware channels and their transmissions complete.
    • Updated usage guidance to continue polling until the driver reports READY, including when polling reports DRAINING.

…returns async (#2994)

ChannelEngineRMT::poll() reported BUSY for the whole transmission, so
ChannelManager::onEndFrame()'s waitForReadyOrDraining() blocked every
FastLED.show() for the full wire time plus the reset latch. On the legacy
addLeds<WS2812B> path (ESP32-S3 and other RMT5 targets) that made a 35-LED
show() take ~1.7 ms instead of returning asynchronously as 3.10.3 did, and
the reporter's 5 ms-cadence sketch drifted every sequence.

Strip bytes are copied into the driver's pool buffer before transmit, and
ChannelData in-use flags still clear only at READY, so callers that reuse
buffers or hardware keep waiting for READY. BUSY now means a strip is still
waiting for a hardware channel; DRAINING means all strips are submitted.

Measured on ESP32-C6 forced onto the RMT5 legacy path (AutoResearch
timingDriftTest, 35 LEDs):
  master: show() 1687 us mean, sequences 2500-2507 ms (+5..+12)
  fix:    show()  369 us mean, sequences 2495 ms (+0, matches 3.10.3)
@zackees zackees added ci-platform:esp32dev Select FastLED board CI cells ci-platform:esp32s3 Select FastLED board CI cells labels Nov 21, 2026
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review.

Walkthrough

RMT5 polling now distinguishes pending strips from active transmissions. It reports BUSY while strips remain pending, DRAINING when transmissions remain active but no strips are pending, and READY when no transmission is active. The example and tests reflect this state progression.

Changes: RMT5 poll states

Layer / File(s) Summary
Track pending work and select poll state
src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
poll() tracks pending work separately from active transmissions. It reports BUSY when work is pending, DRAINING when transmissions remain active with no pending work, and READY when nothing is active.
Update polling example and state tests
src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.h, tests/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp, tests/data/esp32s3_bloat_baseline.txt
The example polls until READY. Tests expect DRAINING after strips are submitted and no work remains pending. The ESP32-S3 bloat baseline increases by 4 B; its budget ceilings remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • FastLED/FastLED#5014: Shares the READY/DRAINING wait behavior and changes PARLIO sorting at call sites that use these waits.
Merge Risk: Minimal · up to 0eed8

RMT5 polling now reports a DRAINING state so show() can return while the frame is still on the wire. Callers that cut LED power right after show() must now poll until READY. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: RMT5 now reports DRAINING once every strip is on the wire, so FastLED.show() returns asynchronously. The raw summary confirms poll() now returns DRAINING when transmis…
Linked Issues check Passed Issue #2994 reports that FastLED master blocks in show() for the full wire time and reset latch on ESP32-S3. This makes the sequence time 2563-2752 ms, against 2495 ms on 3.10.3. The whole-PR diff aga…
Out of Scope Changes check Passed The whole-PR diff touches the RMT5 driver source (poll() and the new transmissionState() helper, with the associated comment), the RMT5 driver header usage comment (poll until READY), the RMT5 host te…
Full details: Title check

Explanation

The title names the main change: RMT5 now reports DRAINING once every strip is on the wire, so FastLED.show() returns asynchronously. The raw summary confirms poll() now returns DRAINING when transmissions remain active but none are pending, and the PR objectives state the same goal. The title's issue reference (#2994) matches the linked issue, and the title's wording is specific and not vague.

Full details: Linked Issues check

Explanation

Issue #2994 reports that FastLED master blocks in show() for the full wire time and reset latch on ESP32-S3. This makes the sequence time 2563-2752 ms, against 2495 ms on 3.10.3. The whole-PR diff against the merge base changes ChannelEngineRMTImpl::poll() in channel_driver_rmt.cpp.hpp. The new transmissionState() helper returns BUSY only when mPendingChannels is non-empty, DRAINING when all strips are submitted but still transmitting, and READY when idle. ChannelManager::onEndFrame() returns on DRAINING, so show() no longer waits for the wire time. The tests in tests/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp expect DRAINING after a single-strip show() and after a queued strip starts, and BUSY while a strip is pending. The author reports a mean show() time of 369 us (previously 1687 us) and a 2495 ms sequence time on ESP32-C6 with forced RMT5. The C6 run uses the same RMT5 driver path as the S3, but the S3 was not tested. The changes since the previous review are the poll() diff as shown and the bloat baseline update; the poll() diff is consistent with the PR description. I did not directly re-inspect the READY-waiting callers in this review. The prior review also did not inspect them, so the claim that they still wait for READY rests on the PR description. This verdict is PASS, with the S3 verification gap noted.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff touches the RMT5 driver source (poll() and the new transmissionState() helper, with the associated comment), the RMT5 driver header usage comment (poll until READY), the RMT5 host test file, and the ESP32-S3 bloat baseline. The baseline change records the 4 B increase from the new state mapping, so it supports the code change. The PR description places the C6 default PARLIO per-frame cost outside this change, and the inspected diff contains no PARLIO changes. No unrelated changes were found.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3c04f6b and 0eed8cc.

Files selected for processing: 1

  • tests/data/esp32s3_bloat_baseline.txt

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 21, 2026
@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (Same) 136 (Same)
esp32dev 287,783 ($\color{red}\uparrow$ 4) 18,747 (Same)
esp32s3 320,391 ($\color{red}\uparrow$ 4) 22,499 (Same)

@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 21, 2026
@github-actions github-actions Bot added security: unscreened-content and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 21, 2026
@zackees
zackees added this pull request to the merge queue Nov 21, 2026
Merged via the queue into master with commit aac1367 Nov 21, 2026
134 checks passed
@zackees
zackees deleted the fix/2994-rmt5-draining branch November 21, 2026 09:54
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-platform:esp32dev Select FastLED board CI cells ci-platform:esp32s3 Select FastLED board CI cells security: unscreened-content

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug] Compounded timing inaccuracy on master compared to 3.10.3 (Follow-up to #2420)

1 participant