Skip to content

fix(channels): register pre-bound legacy driver with ChannelManager (closes #2493) - #2498

Merged
zackees merged 2 commits into
masterfrom
fix-legacy-clockless-driver-registration-2493
May 23, 2026
Merged

zackees merged 2 commits into
masterfrom
fix-legacy-clockless-driver-registration-2493

Conversation

@zackees

@zackees zackees commented May 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Bug: After PR feat(channels): remove FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY (default-as-opt-in, closes binary-bloat half of #2421) #2469 made driver TUs opt-in, the legacy addLeds<> path on ESP32-S3 / RMT (and other platforms) silently stopped pushing data: FastLED.show() returns in ~1.4ms, serial reports ~170+ FPS, but no LED data appears on the pin. The ClocklessIdf5 constructor pre-binds the driver via setDriver() (so showPixels() skips per-frame selectDriverForChannel()), but the pre-bind never registers the driver with ChannelManager::mDrivers — so onEndFrame() iterates an empty list and driver->show() is never called. Encoded pixels sit enqueued and never transmit.
  • Fix: ClocklessIdf5 constructor now calls BusTraits<Bus::RMT>::registerWithManager() before the existing setDriver() pre-bind. This wires the driver into mDrivers so onEndFrame() triggers show(). The pre-bind itself is retained so per-frame priority dispatch is still skipped — preserves the memory/perf intent of feat(channels): remove FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY (default-as-opt-in, closes binary-bloat half of #2421) #2469.
  • Idempotent registration: ChannelManager::addDriver() now silently no-ops when the same shared_ptr is added at the same priority, so the registration call from every addLeds<> template instantiation doesn't spam "Replacing existing driver" warnings or trigger waitForReady() on each instantiation.
  • CI: Re-enable --no-fbuild on bash autoresearch to select the dormant PlatformIO backend. This was the escape hatch needed when fbuild's zccache daemon was wedged on my host; the flag was previously documented as deprecated and ignored.

Closes #2493.

Test plan

Notes

  • This only touches the RMT5 path. Grep across src/ for setDriver\(BusTraits< returns one hit, so no other legacy clockless controllers use this pre-bind pattern.
  • The same root cause likely explains the P4/PARLIO failure mode reported in the issue. PARLIO uses its own bus_traits.h specialization but the addLeds<> template path does not pre-bind via PARLIO's BusTraits. Follow-up may need a similar fix in any other legacy clockless controller wired through the channels API.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced build system resilience with optional PlatformIO fallback when the default build driver encounters issues
    • Improved driver registration to prevent unnecessary re-registration of identical drivers at the same priority level
    • Fixed RMT5 bus driver registration to ensure proper hardware transmission of pixel data

Review Change Stack

zackees and others added 2 commits May 22, 2026 22:50
…loses #2493)

PR #2469 made driver TUs opt-in: only the platform-default driver was
expected to link, via the Phase 5b `setDriver()` pre-bind in the legacy
clockless controller. The pre-bind correctly short-circuits per-frame
`selectDriverForChannel()` lookups, but it never registers the driver
with `ChannelManager`. `ChannelManager::onEndFrame()` iterates
`mDrivers` to call `driver->show()` -- with `mDrivers` empty, the
encoded pixel data sits enqueued and never reaches the hardware.

Symptoms (matching #2493 user reports on ESP32-S3 / RMT and ESP32-P4 /
PARLIO with the stock `addLeds<>` API after the channels refactor):
- `FastLED.show()` returns in ~1.4ms with no errors
- Serial reports ~170+ FPS
- No data burst on the LED data pin

Fix:
- `ClocklessIdf5` constructor calls
  `BusTraits<Bus::RMT>::registerWithManager()` before the existing
  `setDriver()` pre-bind. This adds the driver to `mDrivers` so
  `onEndFrame()` finds it and triggers transmission. The pre-bind is
  retained so per-frame `selectDriverForChannel()` is still skipped --
  preserves the memory/perf intent of #2469.

- `ChannelManager::addDriver()` is now idempotent for true duplicates
  (same `shared_ptr` at same priority). Each `addLeds<>` template
  instantiation calls `registerWithManager()` from its constructor, so
  multiple controllers on the same Bus would otherwise spam "Replacing
  existing driver" warnings and `waitForReady()` flushes on every
  instantiation.

Verified on ESP32-S3 (COM13) via `bash autoresearch --rmt`: 4/4
multi-run RMT test patterns pass with correct captured data on the
internal RX loopback.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The flag was previously documented as deprecated and ignored, leaving
no escape hatch when fbuild's zccache daemon is wedged (e.g., recv
timeout on the cache daemon after a stale process or a corrupted cache
state). Restore its original purpose: passing `--no-fbuild` now
selects the existing-but-dormant `PlatformIODriver` for the build +
upload path, while the default remains `FbuildDriver`.

This was needed to verify the fix for #2493 when fbuild was broken on
the host.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 23, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3101a4cd-327a-49f9-80a6-3b21d4337cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 909df70 and 5e43aff.

📒 Files selected for processing (3)
  • ci/autoresearch/build_driver.py
  • src/fl/channels/manager.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/idf5_clockless.h

📝 Walkthrough

Walkthrough

The PR introduces three coordinated changes: select_build_driver() now uses no_fbuild_flag to conditionally return PlatformIO or Fbuild drivers; ChannelManager::addDriver() adds an idempotent path for re-registration of the same driver instance; and RMT5 explicitly registers its driver with ChannelManager instead of relying on static initialization.

Changes

Driver registration and selection refactor

Layer / File(s) Summary
Build driver selection conditional on no_fbuild_flag
ci/autoresearch/build_driver.py
select_build_driver() accepts no_fbuild_flag as a functional driver-selection parameter. When true, it returns PlatformIODriver() as a legacy fallback when fbuild's zccache is broken; otherwise returns FbuildDriver() (the default). Documentation reflects the actual behavior.
ChannelManager idempotent re-registration fast path
src/fl/channels/manager.cpp.hpp
ChannelManager::addDriver() detects identical registrations (same driver name, same shared_ptr instance, same priority) and treats them as idempotent no-ops, logging a debug message and returning early instead of replacing the driver and waiting for readiness.
RMT5 explicit driver registration and documentation
src/platforms/esp/32/drivers/rmt/rmt_5/idf5_clockless.h
ClocklessIdf5 constructor now calls BusTraits<Bus::RMT>::registerWithManager() to explicitly register the RMT5 driver with ChannelManager. Documentation clarifies that setDriver() only affects per-frame selection in showPixels() and that explicit registration is required because drivers no longer auto-register at static-init time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • FastLED/FastLED#2460: The explicit BusTraits registration and clarified setDriver()/pre-bind behavior directly support the trailing fl::Bus template pattern that relies on BusTraits::instancePtr() and setDriver() behavior.
  • FastLED/FastLED#2428: Both changes shift toward explicit/opt-in driver registration via BusTraits::registerWithManager() rather than relying on static initialization, aligning with the channel driver registry refactor discussed in that issue.

Possibly related PRs

  • FastLED/FastLED#2395: Modifies the same select_build_driver() function; #2395 makes it always return FbuildDriver, while this PR reintroduces conditional PlatformIODriver() return when no_fbuild_flag is set.
  • FastLED/FastLED#2438: Both PRs coordinate driver registration by ensuring the same BusTraits<...>::instancePtr() singleton is registered and avoiding duplicate replacement behavior through the updated ChannelManager::addDriver() idempotency.
  • FastLED/FastLED#2441: The RMT5 explicit registration via BusTraits<Bus::RMT>::registerWithManager() and the ChannelManager::addDriver() idempotency are in the same driver registration/binding area as the retrieved PR's opt-in BusTraits-based pre-binding.

Poem

🐰 Drivers now register with care,
No duplicates floating in air!
FbuildDriver leads by day,
While PlatformIO waits as the fallback way—
Idempotent, safe, and perfectly fair! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly summarizes the main change: registering a pre-bound legacy driver with ChannelManager to fix a bug where drivers weren't being registered. It's specific, clear, and concise.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-legacy-clockless-driver-registration-2493

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

ESP32-P4 PARLIO: FastLED.show() appears to block for ~16.7 ms before WS2812 data burst begins

1 participant