Skip to content

fix(channels): preserve buffers still owned by an earlier frame - #5473

Merged
zackees merged 1 commit into
masterfrom
fix/slim-bridge-owned-frame
Nov 25, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/slim-bridge-owned-frame

Conversation

@zackees

@zackees zackees commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The clockless and SPI legacy bridges can route a frame to a different driver while the previous driver still owns the shared ChannelData. The new driver's READY state does not release the previous frame's buffer. Check ChannelData ownership again after the bounded wait and skip encoding while the buffer remains in use.

Follow-up to #5356.

Validation

  • Both focused sanitizer tests reproduced the unsafe enqueue before the fix.
  • Changed-file lint passed.
  • Final sanitizer, full host C++, and ESP32-C6 RMT loopback validation are running.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of frames while a previous transfer is still in progress. New frames are now held until the data is available, or dropped if the transfer does not become ready, helping prevent outdated or overlapping frame data from being sent.
    • Updated behavior across both standard and SPI bridge channels so busy buffers are not reused prematurely.

@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
Walkthrough

Both slim bridge controllers now drop a frame if the driver is not ready or the channel data remains in use after the readiness wait. Tests cover busy-buffer handling, fallback behavior, and retrying after the data becomes available.

Changes: In-flight channel data guard

Layer / File(s) Summary
Guard channel data before reuse
src/fl/channels/slim_bridge_controller.h, src/fl/channels/slim_spi_bridge_controller.h, tests/unit/fl/channels/slim_bridge_controller.cpp, tests/unit/fl/channels/spi_channel.cpp
Both controllers drop a frame if readiness fails or channel data remains in use. Tests check that busy data is not reused or enqueued, and that a retry can enqueue after the data becomes available.

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

Change: Bug fix

Merge Risk: Minimal · up to b3653

This change stops a frame from overwriting a buffer that an earlier driver still owns when the bridge routes to a different driver. No concrete defect remains in the production change. The only open comments are optional test-style suggestions.

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 fix type and scope and states the main change: buffers still owned by an earlier frame are preserved. The changeset rechecks ChannelData ownership after the bounded wait in SlimBri…
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 names the fix type and scope and states the main change: buffers still owned by an earlier frame are preserved. The changeset rechecks ChannelData ownership after the bounded wait in SlimBridgeController::showPixels and SlimSpiBridgeController::showPixels, and drops the frame when the buffer remains in use. The title is specific and matches the primary change. Its 63-character length is acceptable.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 2

tests/unit/fl/channels/spi_channel.cpp: 1

613-613: Trivial · Maintainability & Code Quality · Heavy lift

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Exercise SPI ownership through a real driver.

SpiCaptureMock::poll() always returns READY and never releases ownership. These direct flag writes test the guard but cannot test actual driver completion. Use a real driver implementation to acquire ownership, complete the frame, and release ownership before the successful retry.

As per coding guidelines, “No mocks — test real implementations.”

Source: Coding guidelines

tests/unit/fl/channels/slim_bridge_controller.cpp: 1

398-399: Trivial · Maintainability & Code Quality · Heavy lift

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Use a real driver for the ownership regression.

The added case uses SlimBridgeMockDriver and sets ownership directly. The later manual release bypasses the completion path that must make fallback recovery possible. Add a regression with a real driver implementation that acquires and releases ownership. Verify buffer preservation during ownership and successful fallback after completion.

As per coding guidelines, “No mocks — test real implementations.”

Source: Coding guidelines

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ec53bae and b36530c.

Files selected for processing: 4

  • src/fl/channels/slim_bridge_controller.h
  • src/fl/channels/slim_spi_bridge_controller.h
  • tests/unit/fl/channels/slim_bridge_controller.cpp
  • tests/unit/fl/channels/spi_channel.cpp

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

@zackees
zackees added this pull request to the merge queue Nov 25, 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)
esp32c3 322,844 ($\color{red}\uparrow$ 14) 13,814 (Same)
esp32c6 351,430 ($\color{red}\uparrow$ 14) 17,905 (Same)
esp32dev 285,587 ($\color{red}\uparrow$ 16) 18,767 (Same)
esp32s3 318,723 ($\color{red}\uparrow$ 16) 22,519 (Same)
esp8266 264,603 (Same) 6,808 (Same)
nrf52840_dk 66,976 ($\color{red}\uparrow$ 16) 19,468 (Same)
rp2040 102,004 ($\color{red}\uparrow$ 8) 8,624 (Same)
stm32f103c8 21,676 ($\color{red}\uparrow$ 8) 1,789 (Same)
teensy41 46,080 (Same) 21,738 (Same)
uno 3,644 (Same) 134 (Same)

Merged via the queue into master with commit ab11af7 Nov 25, 2026
349 of 487 checks passed
@zackees
zackees deleted the fix/slim-bridge-owned-frame branch November 25, 2026 12:45
@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