Skip to content

fix(core): make no-argument FastLED.wait() honor its completion contract #3933

Closed

Description

@zackees

Problem

The public no-argument FastLED.wait() API says it waits for channel transmissions to complete, but it can return after one second while a driver is still busy and gives the caller no indication that completion did not occur.

This was found while reviewing the completion guidance for #1049. I searched open FastLED issues and PRs for FastLED.wait timeout; no existing tracker covers this contract mismatch.

Current source evidence

  • CFastLED::wait() calls ChannelManager::waitForReady() and discards its boolean result (src/FastLED.cpp.hpp, around lines 635-640).
  • ChannelManager::waitForReady(u32 timeoutMs = 1000) defaults to a one-second timeout (src/fl/channels/manager.h).
  • waitForCondition() treats timeoutMs == 0 as an unbounded wait: timeout checks are guarded by timeoutMs > 0 while it continues polling and cooperatively running system tasks (src/fl/channels/manager.cpp.hpp).
  • The explicit bool FastLED.wait(timeout_ms) overload already exposes bounded failure to callers.

Impact

Code that uses the no-argument overload before reusing externally owned buffers, changing hardware state, or tearing resources down can proceed while transmission remains active. The function's void return makes that timeout indistinguishable from successful completion. Slow or stuck custom drivers are the clearest reproducer, but the API contract should not depend on every backend finishing inside an undocumented one-second ceiling.

Proposed fix

Make the no-argument overload use the manager's existing unbounded semantics:

void CFastLED::wait() {
    fl::channelManager().waitForReady(0);
}

Keep bool FastLED.wait(timeout_ms) as the bounded/cancellable choice. Update API documentation to distinguish the unbounded completion overload from the checked timeout overload.

Acceptance criteria

  • No-argument FastLED.wait() cannot return while any registered driver remains non-READY.
  • It continues to cooperatively run the existing system/task work rather than becoming a hard busy-spin.
  • FastLED.wait(timeout_ms) retains its boolean timeout behavior.
  • A focused regression test proves the no-argument wrapper requests the manager's unbounded (0) behavior, without making the suite wait for a real second.
  • API documentation clearly describes both overloads.

Decisions made while filing

  • Preserve both public signatures; this is a behavior/contract correction, not an API redesign.
  • Use the manager's already-supported zero timeout convention instead of adding a new sentinel or duplicate wait loop.

Activity

  1. added
    status: in-progress
    type: bug
    priority: high
    area: core
    on Aug 20, 2026
  2. moved this from Triage to Done in FastLED Trackeron Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: highstatus: in-progresstype: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions