Skip to content

fix(channels): drop incomplete runtime WS2812 frames - #5475

Merged
zackees merged 1 commit into
masterfrom
fix/runtime-clockless-short-frame
Nov 25, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/runtime-clockless-short-frame

Conversation

@zackees

@zackees zackees commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #5356.

Runtime WS2812 channels can leave a prefix in the encoded buffer when a bulk writer cannot grow it. Check the emitted byte count against the input pixel count and the active RGB, RGBW, or RGBWW format before notifying listeners or submitting. Drop the incomplete buffer so a later show can retry without consuming a dither phase.

The host regression injects a buffer-local allocation limit on a 33-pixel channel, then lifts it and confirms that all 99 bytes are submitted. Before the fix, the failed frame reached the capturing driver. After the fix, the sanitizer run and lint on all three changed files passed. Full C++ validation is running.

Summary by CodeRabbit

  • Bug Fixes
    • WS2812 frames are submitted only when encoding completes successfully, preventing incomplete frames from being sent or reported as encoded. Successful frames continue to be processed normally.

@zackees zackees added the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Nov 25, 2026
@github-actions github-actions Bot removed the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 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

The channel now validates WS2812 frame encoding before it fires the encoded-data event or submits a frame. A regression test covers allocation failure and successful encoding.

Changes: WS2812 Frame Validation

Layer / File(s) Summary
Validate and submit frames
src/fl/channels/channel.h, src/fl/channels/channel.cpp.hpp, tests/unit/fl/channels/channel.cpp
encodeFrame returns a success flag and checks that WS2812 output matches the expected size. showPixels submits only successful frames. The test checks that allocation failure produces no captured frame or encoded event and does not advance the dither phase; it also checks successful encoding.

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

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to ae7ac

This change stops incomplete WS2812 frames from being sent or announced when a buffer allocation fails, so a later show can retry cleanly. No merge-blocking risk was found.

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 "fix(channels): drop incomplete runtime WS2812 frames" matches the main change. The changeset makes showPixels submit a frame only when encodeFrame succeeds, and encodeFrame now returns bool…
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.
Full details: Title check

Explanation

The title "fix(channels): drop incomplete runtime WS2812 frames" matches the main change. The changeset makes showPixels submit a frame only when encodeFrame succeeds, and encodeFrame now returns bool and rejects a WS2812 buffer whose size does not equal pixel count times bytes per pixel. The title names the channel area, the WS2812 encoder, and the dropped incomplete frame behavior. The title is specific and concise, and it does not depend on file names or vague terms.

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 c9cfcae and ae7acb2.

Files selected for processing: 3

  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/channel.h
  • tests/unit/fl/channels/channel.cpp

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

@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)
esp32c3 322,844 (Same) 13,814 (Same)
esp32c6 351,430 (Same) 17,905 (Same)
esp32dev 285,587 (Same) 18,767 (Same)
esp32s3 318,715 (Same) 22,519 (Same)
esp8266 264,603 (Same) 6,808 (Same)
nrf52840_dk 66,976 (Same) 19,468 (Same)
rp2040 102,004 (Same) 8,624 (Same)
stm32f103c8 21,676 (Same) 1,789 (Same)
teensy41 46,080 (Same) 21,738 (Same)
uno 3,644 (Same) 134 (Same)

@zackees
zackees added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit 89287f3 Nov 25, 2026
346 of 486 checks passed
@zackees
zackees deleted the fix/runtime-clockless-short-frame branch November 25, 2026 13:38
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 25, 2026
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.

1 participant