Skip to content

fix(channels): emit FL_ERROR when queued data has no enabled driver (Closes #2517) - #2795

Merged
zackees merged 1 commit into
masterfrom
fix/channels-no-driver-flush-error
Jun 5, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/channels-no-driver-flush-error

Conversation

@zackees

@zackees zackees commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Closes #2517

Silent-failure scenario

Before this change, a channel whose bound driver got disabled at runtime
(typically by FastLED.setExclusiveDriver<OtherBus>() or
setDriverEnabled(name, false)) would still call driver->enqueue() every
frame — but ChannelManager::onEndFrame() only iterates enabled drivers
when invoking show(), so the queued bytes were dropped on the floor with
no diagnostic. This is the silent-failure mode the ESP32-P4 PARLIO
no-output bug (#2515) surfaced.

What changed

  • src/fl/channels/manager.{h,cpp.hpp} — added two diagnostic accessors:
    • ChannelManager::driverStatus(name) returns a tri-state
      NOT_REGISTERED / DISABLED / ENABLED with no logging on miss
      (companion to the existing findDriverByName() silent lookup).
    • ChannelManager::exclusiveDriverName() returns the current
      setExclusiveDriver(...) selection (or empty if none).
  • src/fl/channels/channel.{h,cpp.hpp} — Channel::showPixels() now
    consults driverStatus() immediately before driver->enqueue():
    • DISABLED → emit one-shot FL_ERROR naming the channel, the bound
      driver, the active exclusive-driver setting, and the
      FastLED.enableDrivers<>() / FastLED.enableAllDrivers()
      remediation, then skip the enqueue (data would not transmit anyway).
    • ENABLED → clear the one-shot latch (so a later disable re-emits the
      diagnostic), then enqueue as before.
    • NOT_REGISTERED → enqueue as before (preserves behaviour for custom
      drivers that bypass the manager).
  • New Channel::mDisabledDriverWarned latch prevents per-frame log spam —
    the FL_ERROR fires once per channel times disable event.

Tests added

Three regression tests in tests/fl/channels/channel.cpp:

  • [#2517] Disabled driver: enqueue is suppressed (would-be silent drop) —
    reproduces the issue scenario verbatim: enqueue → setExclusiveDriverByName("DOES_NOT_EXIST") → enqueue is suppressed.
  • [#2517] Normal flush path does NOT trigger the silent-drop FL_ERROR —
    three consecutive happy-path frames, all enqueue (regression guard for
    the "must not trigger on success" acceptance criterion).
  • [#2517] Re-enabling the driver resumes enqueue and re-arms the latch —
    covers the disable → enable → disable cycle so the one-shot latch is
    proven to be re-armable.

Verification is behavioural — the project log macros don't have a capture
sink today, so each test asserts the fake driver's enqueue counter stops
growing on disable and resumes on enable.

Test plan

  • bash lint — passes (cpp + js + python)
  • bash test channel --cpp — passes (includes the 3 new cases)
  • bash test channel_manager --cpp — passes (regression guard)
  • bash test --cpp — 309/309 tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Prevented silent frame drops by implementing error diagnostics when drivers are disabled—users now receive actionable error messages instead of experiencing unexplained frame loss.

…er (Closes #2517)

Before this change, a channel with a bound driver that had been disabled
(e.g. by FastLED.setExclusiveDriver<OtherBus>()) would enqueue data to
that driver every frame, but ChannelManager::onEndFrame() iterates only
ENABLED drivers when calling show(), so the frame was silently dropped
on the floor with no diagnostic. This was the silent-failure mode that
the ESP32-P4 PARLIO no-output bug (#2515) surfaced.

Adds ChannelManager::driverStatus(name) — a silent tri-state lookup
(NOT_REGISTERED / DISABLED / ENABLED) — and ChannelManager::
exclusiveDriverName() accessor. Channel::showPixels() consults these
immediately before driver->enqueue() and:
  - On DISABLED: emits a one-shot FL_ERROR naming the channel, the
    bound driver, the active exclusive-driver setting, and the
    FastLED.enableDrivers<>() / FastLED.enableAllDrivers() remediation,
    then skips the enqueue (the data wouldn't be transmitted anyway).
  - On ENABLED (happy path): clears the one-shot latch so a later
    disable re-emits the diagnostic, then enqueues as before.
  - On NOT_REGISTERED: enqueues as before (preserves the historic
    behaviour for custom drivers that bypass the manager).

The mDisabledDriverWarned latch keeps the diagnostic from spamming once
per frame — it fires once per disable event per channel.

Three regression tests added to tests/fl/channels/channel.cpp:
  - "[#2517] Disabled driver: enqueue is suppressed" — reproduces the
    setExclusiveDriverByName("DOES_NOT_EXIST") silent-drop scenario and
    asserts the driver's enqueue count stops growing.
  - "[#2517] Normal flush path does NOT trigger the silent-drop
    FL_ERROR" — three happy-path frames, all enqueue.
  - "[#2517] Re-enabling the driver resumes enqueue and re-arms the
    latch" — covers the disable -> enable -> disable cycle.

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

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

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: 8d5e21a8-3823-4ac8-8e30-652c8d06f048

📥 Commits

Reviewing files that changed from the base of the PR and between 787de45 and 7fb27b1.

📒 Files selected for processing (5)
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/channel.h
  • src/fl/channels/manager.cpp.hpp
  • src/fl/channels/manager.h
  • tests/fl/channels/channel.cpp

📝 Walkthrough

Walkthrough

This PR addresses issue #2517 by adding pre-enqueue status validation to prevent silent LED frame drops when a channel's bound driver is disabled. A new ChannelManager::driverStatus() query and one-shot guard in Channel::showPixels() emit an actionable diagnostic and suppress enqueue when the bound driver is disabled or unavailable, while allowing re-emission when the driver is re-enabled.

Changes

Disabled Driver Diagnostic

Layer / File(s) Summary
ChannelManager driver status API
src/fl/channels/manager.h, src/fl/channels/manager.cpp.hpp
New DriverStatus enum (NOT_REGISTERED, DISABLED, ENABLED) and silent-lookup driverStatus(name) method enable Channel to query whether a named driver is enabled. Accessor exclusiveDriverName() exposes the active exclusive-driver selection for diagnostic context.
Channel disabled-driver guard and one-shot diagnostic
src/fl/channels/channel.h, src/fl/channels/channel.cpp.hpp
Channel::showPixels() pre-checks driver status before enqueue; if DISABLED, emits a one-shot FL_ERROR (with exclusive-driver context) and returns early. Private flag mDisabledDriverWarned suppresses repeat diagnostics until the driver returns to ENABLED, then resets to re-arm the error on future disable.
Test infrastructure and validation
tests/fl/channels/channel.cpp
CountingFakeDriver tracks enqueue/show counts; three tests verify disabled-driver suppression persists across frames, normal paths unaffected, and one-shot guard resets on re-enable/disable cycles.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • FastLED/FastLED#2455: Related one-shot diagnostic guard in Channel::showPixels(), though for a different condition (missing/unenrolled drivers vs disabled driver status).

Possibly related PRs

  • FastLED/FastLED#2465: Modifies Channel::showPixels() diagnostics text for missing driver instantiation in the same code path.
  • FastLED/FastLED#2441: Changes showPixels() control flow around driver selection and bypass logic that interacts with this disabled-driver gate.
  • FastLED/FastLED#2456: Adds a separate one-shot boolean guard in channel.h for affinity-miss diagnostics, using the same pattern as this PR's mDisabledDriverWarned.

Poem

🐰 A driver once silent, now speaks its truth,
When disabled and bound to a channel's use,
No more frames drop without a sound,
FL_ERROR guards the data round,
One-shot warnings keep logs so bright! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% 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 title clearly identifies the main fix: preventing silent frame drops by emitting FL_ERROR when queued data has no enabled driver, matching the changeset's core purpose.
Linked Issues check ✅ Passed All core objectives from #2517 are met: detects disabled drivers via driverStatus(), emits actionable FL_ERROR with channel/driver/exclusive-driver context, suppresses enqueue on disable, includes one-shot latch, and adds tests covering disable/re-enable scenarios.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #2517: ChannelManager status APIs, Channel pre-enqueue checks with one-shot guard, and test coverage for disabled-driver behavior. No unrelated modifications detected.

✏️ 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/channels-no-driver-flush-error

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
tests/fl/channels/channel.cpp

tests/fl/channels/channel.cpp:5:10: fatal error: 'FastLED.h' file not found
5 | #include "FastLED.h"
| ^~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/7fb27b1ca387544ef22daf874878c4ceefa02ef1-d95f1ae37209823e/tmp/clang_command_.tmp.0a3481.txt
++Contents of '/tmp/coderabbit-infer/7fb27b1ca387544ef22daf874878c4ceefa02ef1-d95f1ae37209823e/tmp/clang_command_.tmp.0a3481.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-c

... [truncated 1058 characters] ...

stall/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/d95f1ae37209823e/file.o" "-x" "c++"
"tests/fl/channels/channel.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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.

@zackees
zackees merged commit 58308c0 into master Jun 5, 2026
7 of 8 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 5, 2026
pull Bot pushed a commit to manmuqingshan/FastLED that referenced this pull request Jun 5, 2026
…astLED#2773)

The esp32dev_binary_size workflow had been pinned to --backend platformio
(PR FastLED#2605) and the budget bumped 330000 -> 700000 (PR FastLED#2790) to dodge two
fbuild deficiencies — fbuild#297 (no build_info.json emitter) and
fbuild#304 (framework objects not archived). Both upstream issues are
fixed in fbuild 2.2.10+ (we pin 2.2.17), so restore both:

- build_template_binary_size.yml: drop the three --backend platformio
  flags so ci.ci-compile defaults to fbuild and we get .eh_frame stripping
  back on every size workflow (~169KB on esp32dev).
- check_esp32_size.yml: revert max_size/max_size_apa102 to the historical
  330000 high-water mark. The test will fail at this ceiling — that is
  the regression signal the user asked for ("minimal memory size... goal
  is complete when the esp size test is failing again with its historical
  high water mark").

Also fix a master-blocking compile error introduced by FastLED#2795: the new
enum class DriverStatus { DISABLED, ENABLED } in fl/channels/manager.h
is textually rewritten by Arduino-ESP32's `#define DISABLED 0x00`
(esp32-hal-gpio.h:59) at every site that includes Arduino.h before
manager.h — which is every esp32 sketch. The platformio-backend CI is
failing for the same reason (`esp32dev_binary_size` red on every push).
Rename to STATUS_DISABLED/STATUS_ENABLED and update the four callers in
channel.cpp.hpp, manager.cpp.hpp, and tests/fl/channels/channel.cpp.

Local verification: fbuild build of examples/Blink on esp32dev succeeds,
emits build_info_Blink.json (with tool aliases the symbol_analysis
pipeline needs), and ci-check-compiled-size.py reports
"esp32dev size 640228 is greater than max size 330000" — the expected
regression signal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix/channels-no-driver-flush-error branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(channels): emit FL_ERROR when queued LED data has no enabled driver to flush

1 participant