Repository navigation
Description
Follow-up to #4201. The two crashes it reported are fixed in #4239
(PixelIteratorAny's self-referential copy, and XYMap::fromXMap memcpying
from nullptr). With those fixed, tests/fl/channels/channel.cpp runs — 10
cases, 6 pass and 4 fail — so it stays dormant in KNOWN_DORMANT until
these are settled.
To reproduce: on top of #4239, change that file's include from
fl/test/fltest.h to test.h, wrap the body in FL_TEST_FILE(FL_FILEPATH),
and run bash test channel --cpp.
1 & 2: APA102 byte order, two addressing paths
Serpentine 2x2 with APA102 encodes pixels in expected byte order and
XMap reverse addressing with APA102 encodes pixels in reverse order.
Every pixel comes out R/B swapped against what the tests expect. Both
channels are created with RGB order and SpiEncoder::apa102(). The tests
expect the APA102 wire order [brightness][B][G][R]; the encoder emits
[brightness][R][G][B].
The swap is consistent and it is visible only on colours that are not
symmetric under it — LED1 (pure green) passes in the serpentine case while
LED0 (red → blue), LED2 (yellow → cyan) and LED3 (blue → red) all fail, which
is what makes the diagnosis unambiguous:
channel.cpp:141: 255 == 0 # LED0 blue byte, expected 0
channel.cpp:143: 0 == 255 # LED0 red byte, expected 255
I have not determined whether the tests encode the right convention or the
encoder does. That needs someone with context on APA102 colour-order handling
in the SPI encoder path — in particular whether Channel's EOrder is
supposed to be pre-applied before writeAPA102 or consumed by it.
3 & 4: #2517 driver-latch counts
[#2517] Normal flush path does NOT trigger the silent-drop FL_ERROR fails
with 0 == 3 on the enqueue count, and [#2517] Re-enabling the driver resumes enqueue and re-arms the latch fails four assertions with counts
consistently one lower than expected (0 == 1, 1 == 2).
These read like the tests were written against a different enqueue cadence
than the current one — but since they have never run, it is equally possible
the latch logic regressed at some point with nothing to catch it. Unassessed.
Why this is filed rather than fixed
Each of the four is a behaviour question, not a crash, and each needs its own
judgement about whether the test or the code is right. Bundling them into the
crash fix would have made that PR unreviewable, and waking the file before
they are settled would turn CI red.
Related: #4201, #4232 (which woke the other two dormant files), #4239.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 9, 2026
The APA102 pair is settled: the tests are wrong, not the encoder
encodeAPA102writes the three bytes its input iterator yields, in order, andnames them in its own comments:
It performs no reordering. The bytes come from
loadAndScaleRGB, whichyields them in the channel's
EOrder. So for APA102 the channel's colour orderis the wire order — which is what FastLED's own examples tell users:
// FastLED.addLeds<APA102, PIN_DATA, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typicalBoth dormant tests construct the channel with
RGBand then assert[br][B][G][R]wire bytes — a reordering nothing performs. Hence every pixel appearing red/blue
swapped; green passed only because it is symmetric under the swap.
Fix: construct with
BGR. I verified it — both cases pass, taking the filefrom 6/10 to 8/10. That keeps the assertions testing something real (that the
reordering path produces the documented APA102 wire order) rather than rewriting
expectations to match observed output.
The #2517 pair is not what it looks like, and I have not solved it
fakeDriver->enqueueCountis 0, not off-by-one — the channel never enqueuesat all. Ruled out by experiment:
showLeds(0)short-circuits on zero brightnessshowLeds(255)also gives 0showLedsvsFastLED.show)FastLED.add+FastLED.show()also gives 0CountingFakeDriver::getCapabilities()returnsCapabilities(true, true), same as the mocks in passing testsmStateFlags = kEnabledby default, and only strict-mode profile rejection clears itSo
ChannelManager::selectDriverForChannel(mChannelData, busKey)is returningnothing for a channel whose only registered driver answers
canHandle() == true.The next thing to check is
mChannelDataat that point, and whatfreshBusTestManager()leaves behind versus theChannelManager::instance()thepassing tests use.
I stopped rather than guess. Whoever picks this up starts from "the driver is
never selected", not "the counts are off by one", which is what the original
report suggested.
zackees commentedon Sep 10, 2026
Solved:
clearAllDrivers()leaves the exclusive-driver filter behindPicking up from "the driver is never selected" — that was the right thread to pull.
ChannelManager::clearAllDrivers()emptiesmDriversbut never touchesmExclusiveDriver. AndaddDriver()consults it:So after a clear, the filter still names a driver that no longer exists, and every driver registered afterwards arrives disabled — silently, with nothing short of another
setExclusiveDriver*()call able to clear it.The leak path across the three #2517 cases is exact:
Disabled driver: enqueue is suppressedends withsetExclusiveDriverByName("DOES_NOT_EXIST").scope_exitcallsclearAllDrivers()— which drops the registry but keeps"DOES_NOT_EXIST".Normal flush pathregistersHAPPY_DRIVER→ disabled →enqueueCount == 0vs 3.Re-enablingregistersRECOVERY_DRIVER→ disabled →0 == 1,1 == 2.That also explains why the first case passed while the other two failed: it is the one that sets the filter, so it runs before the poison exists.
This is not a test-isolation problem, which is why the fix is in the library rather than in
freshBusTestManager().FastLED.clear(CHANNEL_ENGINES)is the production caller ofclearAllDrivers()(FastLED.cpp.hpp:229), and it has the same defect: clear your drivers after ever setting an exclusive driver, and re-registration silently no-ops.Fix is one line — the clear drops the filter along with the registry it refers to.
And confirming your APA102 call
Your diagnosis was right and I kept it as written: constructing with
BGRrather than rewriting the expected bytes. Both cases pass.Result
All four settled, so
channel.cppis woken andKNOWN_DORMANTis now empty — which also closes #4201.Mutation-tested both fixes: reverting
mExclusiveDriver.clear()fails exactly the two #2517 cases; revertingBGR→RGBfails exactly the two APA102 cases. Neither pair is passing by accident.PR: #4249
study(color): characterise the 8-bit shaping paths, ruling two out (#…
fix(channels): clear the exclusive-driver filter in clearAllDrivers, …