Repository navigation
Description
Summary
Tracking issue for the timing-precision and binary-size regression on ESP32-S3 (and likely all ESP32 family + similar Channel-API platforms) reported in #2420 by @nomakewan.
This issue exists to coordinate investigation, organize fix proposals, and track shipping of the near-term mitigation.
Reported symptoms (from #2420)
- Timing drift: A loop that should take 2500 ms now averages ~2600 ms with random spikes >3000 ms on master vs 3.10.3. Sketch is minimal:
FastLED.show()every 5 ms viamillisDelay, 35 WS2812B LEDs, NEOPIXEL pin only,setMaxRefreshRate(0),setCpuFrequencyMhz(160). - Binary bloat: Same sketch grew from 344 KB → 783 KB (+439 KB / 2.27x) between 3.10.3 and
master#ea5d8ec. - Bare
delay()is not swapped tofl::delayon Arduino targets (gated toFASTLED_STUB_IMPLatsrc/FastLED.h:1648), so async pumping infl::delayis not the cause.
Root cause analysis (initial)
Timing jitter — vTaskDelay(1) floor in every show()
The new Channel API inserts two FreeRTOS-blocking waits per FastLED.show() call that did not exist in 3.10.3:
- Begin-frame wait:
CFastLED::show()->onBeginFrame()(FastLED.cpp.hpp:233) firesEngineEvents::onBeginFrame->ChannelManager::onBeginFrame()->waitForReady()(manager.cpp.hpp:401-403). - End-frame wait:
onEndFrame()(FastLED.cpp.hpp:280) ->ChannelManager::onEndFrame()->driver->show()thenwaitForReadyOrDraining()(manager.cpp.hpp:405-415).
Both go through ChannelManager::waitForCondition (manager.cpp.hpp:326-336), which busy-loops:
while (!condition()) {
if (timeoutMs && (millis() - startTime >= timeoutMs)) return false;
task::run(250, task::ExecFlags::SYSTEM); // <- blocks >=1 FreeRTOS tick
}task::run(250, SYSTEM) -> pumpCoroutines(1000) (executor.cpp.hpp:135-141) -> on ESP32 (coroutine_esp32.impl.hpp:62-87) -> vTaskDelay(1 tick) minimum.
Math matches the report:
- 35 WS2812B LEDs ~= 1.1 ms actual RMT transmission
- Each
show()adds ≥1×vTaskDelay(1)≈ 1 ms (Arduino ESP32 default tick=1000Hz; would be 10 ms on stock IDF tick=100Hz) - 500 shows in 2500 ms × ~1 ms added blocking ≈ +500 ms drift — matches "up to 500 ms additional delay"
- Random jitter:
vTaskDelayaligns to tick boundary AND yields to whatever lower-priority task FreeRTOS picks (idle, lwIP, esp_timer)
setMaxRefreshRate(0) correctly zeros mNMinMicros and skips the spin-wait at FastLED.cpp.hpp:234, but the new waits are inside EngineEvents callbacks, not the rate limiter.
In 3.10.3 the RMT4 path used a semaphore wait inside endShowLeds() only — no per-show pre-wait, no engine-event indirection, no vTaskDelay(1) floor.
Binary bloat — unconditional driver compilation + registration
src/platforms/esp/32/drivers/_build.cpp.hpp unconditionally compiles every ESP32 driver family regardless of what the sketch uses:
- ble, gpio_isr_rx, i2s, i2s_spi, lcd_cam, lcd_spi, parlio, rmt, rmt_rx, spi, uart
- Plus
channel_manager_esp32,cled,spi_hw_manager_esp32
Each driver self-registers as a shared_ptr<IChannelDriver> in ChannelManager::mDrivers, so the linker cannot dead-strip them. Largest contributors by source size:
parlio/parlio_engine.cpp.hpp~2066 linesrmt/rmt_5/channel_driver_rmt.cpp.hpp~1520 linesi2s/channel_driver_i2s.cpp.hpp~619 lineslcd_spi/channel_driver_lcd_spi.cpp.hpp~459 lines- ble, uart, gpio_isr_rx, etc.
In addition, FastLED.h unconditionally pulls in the Task/Executor/Promise/Coroutine system (#include "fl/task/executor.h" at line 142) and the full Channel manager + events + audio + rx machinery (lines 161-168) — even for a NEOPIXEL-only sketch.
Proposed near-term mitigation
Add a build-time define such as FASTLED_TIGHT_TIMING (name TBD — alternatives: FASTLED_NO_ASYNC_WAIT, FASTLED_FAST_SHOW) that:
- Skips the begin-frame
waitForReady()(driver should already be READY by next frame; if not, the encode-time safety check inChannel::showPixels()atchannel.cpp.hpp:300still protects us). - Inside
ChannelManager::waitForCondition, replacestask::run(250, SYSTEM)with a tight poll-then-yield: pollNtimes before falling back tovTaskDelay(1). For 35-LED WS2812B, ~1 ms transmission completes in well under one tick of polling. - Optionally disables EngineEvents firing entirely when
FASTLED_HAS_ENGINE_EVENTSis forced off via this define.
Users with cooperative WiFi/lwIP loads can leave the default behavior; users with tight-timing single-purpose sketches can opt into the fast path.
Long-term architectural fixes
- Driver linkage: Gate driver
_build.cpp.hppincludes behind feature flags (e.g.FASTLED_ENABLE_BLE,FASTLED_ENABLE_PARLIO,FASTLED_ENABLE_LCD_CAM), default-on only for the driver chosen by the user'saddLeds<>template. The current "compile everything, register everything" pattern defeats LTO and is the dominant binary-bloat driver. - Wait architecture: Remove the per-show
waitForReady()inonBeginFrame. The driver state should be checked lazily insideChannel::showPixels(already done at line 300) — pre-waiting inonBeginFrameis redundant and adds the tick-alignedvTaskDelayfloor. - Decouple
fl::taskfrom the FastLED critical path so a sketch that doesn't use HTTP/promises/coroutines doesn't pay any link/runtime cost.
Investigation TODO
- Get
.elf+.map+platformio.inifrom [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420 reporter — requested in [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420 (comment) -
bloaty/nm --size-sortanalysis: confirm the per-driver byte cost on an actual ESP32-S3 build - Bisect: identify the commit where the begin-frame
waitForReady()was introduced - Bisect: identify the commit where unconditional driver
_build.cpp.hppincludes landed - Microbenchmark: instrument
show()withesp_timer_get_time()to measure the actual blocking duration of eachwaitForConditioniteration on ESP32-S3 with the user's exact sketch - Validate proposed
FASTLED_TIGHT_TIMINGmitigation against the user's reproducer - Decide name + scope of the mitigation define and ship it
- File follow-up issue(s) for the per-driver feature-gate refactor
Related
- Reported in: [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420
- Related context: ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 (the websocket-starvation fix that added the
pumpCoroutines(1000)floor — see commit message incoroutine_esp32.impl.hpp:78-82)
Labels
Suggested: type: regression, area: esp32, area: performance, area: binary-size
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Apr 30, 2026
Symbol-level analysis from #2420 reporter's ELF
@nomakewan provided the firmware.elf (41 MB w/ DWARF) and firmware.map for an ESP32-S3 build of
master#ea5d8ecagainst the minimal NEOPIXEL sketch from #2420. Analysis usedxtensa-esp32s3-elf-nm --print-size --size-sort -Cand a Python parser of the linker map's per-section / per-object breakdown.Section sizes (from
xtensa-esp32s3-elf-size -A).flash.text.flash.rodata.iram0.text.dram0.dataReporter's firmware = 783 KB; baseline 3.10.3 = 344 KB; regression = +439 KB.
libFastLED.a contribution
Per-archive aggregation of
.flash.text+.flash.rodata+.iram0.text:platforms+.cpp.o(all ESP32 drivers)fl.channels+.cpp.o(Channel API + manager)fl.audio+.cpp.ofl.stl+.cpp.ofl.gfx+.cpp.ofl.remote+.cpp.othird_party+.cpp.ofl.net+.cpp.ofl.fx+.cpp.ofl.math+.cpp.ofl.task+.cpp.ofl.system+.cpp.oPlus
main.cpp.o(FastLED template instantiations leaking into the user sketch's TU):.flash.text: 1,361.flash.rodata: 78,825 (huge — variant<>, PixelIterator<>, Channel-derived ClocklessIdf5<>, etc.)ESP-IDF driver code dragged in by FastLED's self-registration
The Channel API instantiates one driver per family at static-init, which keeps the linker from dropping any of them. This pulls in entire ESP-IDF driver components the user never references:
uart.c+uart_vfs.c+esp32-hal-uart)spi_master,spi_common,esp32-hal-spi,spi_hal_iram)esp_lcd_panel_io_i80)rmt_rx.c)esp32-hal-rmt,esp32-hal-perimanThe user's NEOPIXEL sketch only needs RMT5 TX. UART, SPI master, LCD i80, RMT RX, and most hal-* code is dead weight here.
Bloat budget reconciliation
The match is within the noise of which symbols I attribute to "FastLED-pulled" vs "would have been linked anyway" — the diagnosis is confirmed: FastLED itself accounts for the bloat, not the toolchain or platform.
Worst offenders (priority list for fix)
Ranked by "code that the user provably does not use":
fl.audio+.cpp.o— 34 KB rodata in a NEOPIXEL sketch. NoaddLedsvariant in the sketch references audio. Likely a staticUIAudioregistration or table somewhere in the include graph (we have#include "fl/audio/input.h"and#include "fl/audio/audio_processor.h"unconditionally at FastLED.h:167-168).fl.remote+.cpp.o(13 KB) +fl.net+.cpp.o(10 KB) — networking code in a sketch that does no networking.fl/channels/rx.h(FastLED.h:144) likely drags in remote+net.fl.fx+.cpp.o— 10 KB — effects library, not used.fl.gfx+.cpp.o— 17.5 KB rodata — graphics support; need to check whether NEOPIXEL templates depend on it.platforms+.cpp.o— 140 KB — confirms the unconditional driver_build.cpp.hpphypothesis. Should be feature-gated per driver.fl.channels+.cpp.o— 68 KB — Channel API itself. The user's sketch uses one ClocklessIdf5 channel; most of this (manager, multi-driver dispatch, ChannelEvents) is overhead.main.cpp.orodata 79 KB — template instantiation explosion in user TU. Worth investigating whethervariant<ClocklessChipset, SpiChipsetConfig>andPixelIterator<...>instantiations can be moved out-of-line or merged.Action items added to investigation TODO
fl/channels/rx.h(FastLED.h:144) is the entry point for remote+net+rxFASTLED_ENABLE_AUDIO,FASTLED_ENABLE_REMOTE,FASTLED_ENABLE_NET) vs opt-out (FASTLED_NO_AUDIO, etc.) vs subset header (<FastLED_Lean.h>)_build.cpp.hpp: detect fromaddLeds<>chipset macro vs explicit per-driver enableFASTLED_TIGHT_TIMING/ lean-build define by rebuilding reporter's sketch and re-measuring binary + timingTooling note
For reproducible analysis, the script that produced the table above is in
/tmp/fastled-2420-analysis/on the maintainer's machine — usesxtensa-esp32s3-elf-nmfrom the pioarduinotoolchain-xtensa-esp-elfpackage and a small Python parser of the linker.mapper-section / per-object format. We should land anagents/script orci/helper that does this analysis on every PR-built ESP32-S3 example to catch regressions automatically.zackees commentedon Apr 30, 2026
Correction: deeper map analysis — the audio/remote/net "rodata" is actually
.eh_frame@zackees pushed back on the previous numbers — and rightly so. I re-parsed the linker map with proper sub-section attribution (filtering
--gc-sections-discarded entries at addr0x00000000, separating.eh_frameexception-unwind data from real rodata, and accounting for the linker's merged string-literal pool.str1.1). The picture is materially different.What the prior analysis got wrong
.textcontributions are zero. What I called "audio rodata" is.eh_frameexception-unwinding metadata for code that the linker dead-stripped but whose unwind data it kept.main.cpp.owas actually the merged.str1.1string-literal pool — a linker-merged region containing string literals from many TUs (mostly FastLEDFL_LOG/FL_WARN/FL_ERROR/format strings), allocated at main.cpp.o's input section because that's where it appeared first.Corrected per-archive table (REAL bytes only, classified by category)
libFastLED.a(platforms+.cpp.o)main.cpp.olibFastLED.a(fl.channels+.cpp.o)libFastLED.a(fl.audio+.cpp.o)libFastLED.a(fl.stl+.cpp.o)libFastLED.a(fl.gfx+.cpp.o)libFastLED.a(fl.remote+.cpp.o)libesp_driver_uart.a(uart.c.obj)libFastLED.a(fl.net+.cpp.o)libFastLED.a(third_party+.cpp.o)libFastLED.a(fl.fx+.cpp.o)libFastLED.a roll-up
.eh_frame(unwind metadata)Global cross-archive overhead
.eh_framein binary: 250,208 bytes (~244 KB) — that's 70% of the entire.flash.rodatasection (which is 359 KB).Why audio/remote/net/fx/gfx end up linked at all (eh_frame survives, code doesn't)
Map's "Archive member included to satisfy reference" section shows the reference chains that pull suspect TUs into the link. Once a TU is pulled in for ANY symbol, GCC's
.eh_framefor that TU is retained as a single section even if--gc-sectionsstrips all the code:fl.audio+.cpp.osrc.cpp.ofl::audio::AudioManager::instance()fl.gfx+.cpp.ofl.channels+.cpp.ofl::rgb_2_rgbw_exact(...)fl.fx+.cpp.ofl.system+.cpp.ofl::Video::begin(...)fl.video+.cpp.ofl.fx+.cpp.ofl::video::VideoImpl::setTimeScale(...)fl.net+.cpp.ofl.stl+.cpp.ofl::net::http::ChunkedReader::hasChunk()fl.remote+.cpp.oplatforms+.cpp.ofl::formatJsonResponse(...)third_party+.cpp.ofl.audio+.cpp.oapply_kernelsThese cross-TU references form a cascade:
src→ audio → third_party;channels→ gfx;system→ fx → video;stl→ net;platforms→ remote. Each new TU pulled in adds its.eh_frameto the binary even though--gc-sectionsstrips the code.Corrected bloat budget vs 3.10.3
.eh_frame(exception unwind metadata)-fno-exceptions -fno-asynchronous-unwind-tables(FastLED disables exceptions but doesn't suppress unwind tables)platforms+.cpp.ocode (all 12 driver families)_build.cpp.hppfl.channels+.cpp.ocode (Channel API)fl.stl,fl.task,fl.system, etc.)Revised priorities for the fix
.eh_frame— biggest single win, ~180 KB. Add-fno-asynchronous-unwind-tablesand-fno-unwind-tablesto FastLED's compile flags (or to the user-facinglib_compile_flagsin our PlatformIO templates). FastLED already uses-fno-exceptions. Need to verify whether ESP-IDF code that backtraces (panic handler, coredump) requires the system-side.eh_frame; if so, scope this to just the libFastLED.a build.src/platforms/esp/32/drivers/_build.cpp.hpp— recovers ~80 KB FastLED + ~46 KB ESP-IDF dependents = ~125 KB.src.cpp.oreferencefl::audio::AudioManager::instance()? (Probably aCFastLED::add(UIAudio&)overload triggering ODR-use of audio singleton.)fl.channelsreferencefl::rgb_2_rgbw_exact?fl.stlreferencefl::net::http::ChunkedReader?platformsreferencefl::formatJsonResponse?FASTLED_TIGHT_TIMINGdefine to skip the per-showvTaskDelay(1)floor. That's the timing regression, independent of binary size.Updated TODO
-fno-asynchronous-unwind-tableson FastLED-only sources, measure size delta_build.cpp.hppApologies for the misleading first-pass numbers. Lesson: when parsing GNU LD maps, always (a) filter addr 0 (gc'd), (b) separate
.eh_framefrom.rodata, and (c) account for the merged-strings pool being attributed to a single first-input slot.zackees commentedon May 1, 2026
Concrete next-step recommendation: apply
FL_NO_UNWINDvia TU-level pragma to ESP32 unity-build headersPer the analysis above, ~180 KB of
libFastLED.a's contribution to.flash.rodatais.eh_frameexception-unwind metadata, of which 79% are orphan FDEs (covering zero-byte ranges left behind after--gc-sectionsstripped the underlying code). The user's Arduino-ESP32 build has no clean way to pass compiler flags to FastLED sources only, so the fix needs to be source-level via GCC's#pragma GCC optimize(a per-TU mechanism that does work in Arduino builds).Action item
Add a new macro
FL_NO_UNWIND(separate fromFL_NOEXCEPT— see discussion above for why these should not be merged) and apply via#pragma GCC push_options/#pragma GCC optimize("no-unwind-tables")/#pragma GCC pop_optionsto the two ESP32 unity-build headers:src/platforms/esp/32/_build.cpp.hpp— wrapscondition_variable,init,io,lwip_hooks,mutex,platform_time,semaphore,watchdog, and recursively pulls inaudio/,codec/,core/,drivers/,interrupts/,ota/, etc.src/platforms/esp/32/drivers/_build.cpp.hpp— wrapschannel_manager_esp32,cled,spi_hw_manager_esp32, plus the 11 sub-driver families (ble, gpio_isr_rx, i2s, i2s_spi, lcd_cam, lcd_spi, parlio, rmt, rmt_rx, spi, uart). This is the file responsible for the 80 KBplatforms+.cpp.ocontribution to.flash.text— wrapping it strips the corresponding ~36 KB of.eh_framefor that TU and ~20-30 KB of orphan FDEs from gc'd driver code.Sketch of the change
Add to
src/fl/stl/codegen.h(new header, or extend an existing one):Wrap the two ESP32 unity headers:
Expected delta
Based on the symbol analysis of @nomakewan's
master#ea5d8ecbuild of the #2420 minimal sketch:.eh_framebyteslibFastLED.a(platforms+.cpp.o)libFastLED.a(fl.audio+.cpp.o)(orphan)libFastLED.a(fl.gfx+.cpp.o)(orphan)libFastLED.a(fl.channels+.cpp.o)libFastLED.a(fl.remote+.cpp.o)(orphan)libFastLED.a(fl.net+.cpp.o)(orphan)libFastLED.a(third_party+.cpp.o)(orphan)libFastLED.a(fl.fx+.cpp.o)(orphan).eh_frameEstimated binary savings: 150-180 KB for the reporter's sketch, taking it from 783 KB down to ~600-630 KB. Still ~280 KB above 3.10.3 baseline (344 KB), so this is a partial fix — the per-driver feature gating (item #2 on the priority list) is needed to recover the rest.
Phased rollout plan
fl/channels/channel.cpp.hppandfl/channels/manager.cpp.hpp(the Channel API itself). Adds ~15 KB savings.fl.audio,fl.remote,fl.net,fl.fx,fl.gfx). These contribute pure-orphan FDEs; wrapping them eliminates the spill even before we fix the cross-TU references.Caveats to note in the PR
???for any frame inside a wrapped TU. Need to test whatidf.py monitor/esp32_exception_decodershows for a forced crash insideChannel::showPixelsafter this change. If it's unusable, scope the wrap more narrowly (e.g., only_build.cpp.hppfor drivers, not the Channel API itself).#pragma GCC optimize("no-unwind-tables")is supported by GCC 4.4+. Modern Xtensa toolchains (GCC 8.4 and 13.2 in pioarduino) handle it. Safe.#pragma GCC optimizebut with a warning. If FastLED supports clang-on-ESP32 (uncommon but possible), test there.TODO update
FL_NO_UNWIND/FL_NO_UNWIND_BEGIN/_ENDmacros tosrc/fl/stl/codegen.hsrc/platforms/esp/32/_build.cpp.hppwithFL_NO_UNWIND_BEGIN/_ENDsrc/platforms/esp/32/drivers/_build.cpp.hppwithFL_NO_UNWIND_BEGIN/_ENDChannel::showPixels, runesp32_exception_decoder, confirm output is still actionable)_build.cpp.hppfor the remaining ~125 KBFASTLED_TIGHT_TIMINGfor the per-showvTaskDelay(1)regressionzackees commentedon May 1, 2026
Refinement: gate
FL_NO_UNWINDon debug + ESP32 backtrace configThe previous proposal would strip
.eh_frameunconditionally for any function/TU it covers, breaking ESP32 panic-handler backtraces inside that code. That's fine for release builds where users want a small binary, but unacceptable for development where they need actionable crash dumps.The macro should be opt-in to stripping only when the build environment indicates the user is OK losing backtrace fidelity — meaning: not a debug build, and not a build that has explicitly enabled ESP-IDF backtrace printing.
Updated macro definition
Behavior matrix (ESP32 builds)
CORE_DEBUG_LEVEL=0,RELEASEdefined,CONFIG_ESP_SYSTEM_PANIC_PRINT_BACKTRACE=y(ESP-IDF default)-DFASTLED_FORCE_NO_UNWIND_TABLESCONFIG_ESP_SYSTEM_PANIC_PRINT_BACKTRACE=n(user disabled it) + no debug flagsCORE_DEBUG_LEVEL=3,LOG_LOCAL_LEVEL=ESP_LOG_INFO, default panic configCORE_DEBUG_LEVEL>=3triggers backtrace preservationFASTLED_TESTINGdefined, noRELEASE-DFASTLED_FORCE_NO_UNWIND_TABLES-DFASTLED_FORCE_UNWIND_TABLESImplication for the reporter's specific case (#2420)
platformio.inishows-D "CORE_DEBUG_LEVEL=3"— so under this proposal, FL_NO_UNWIND would be a no-op for them by default. They'd still see the 783 KB binary unless they explicitly opt in with-DFASTLED_FORCE_NO_UNWIND_TABLES.That's the safest default: don't silently strip backtraces from a build that's clearly configured for diagnostics. The 783 → 600 KB win has to be opted into.
Updated rollout for the two ESP32 unity headers
Same files as before, just now with a debug-aware macro:
Wrappings are conditional at preprocessing — wrap-or-not depends on the build environment's debug signals at the time the unity header is included.
Updated TODO
FL_NO_UNWIND/FL_NO_UNWIND_BEGIN/_ENDtosrc/fl/stl/codegen.hwith debug + ESP32 backtrace config gating as abovesrc/platforms/esp/32/_build.cpp.hppwithFL_NO_UNWIND_BEGIN/_ENDsrc/platforms/esp/32/drivers/_build.cpp.hppwithFL_NO_UNWIND_BEGIN/_ENDagents/docs/cpp-standards.mdand the ESP32 README that:-DFASTLED_FORCE_NO_UNWIND_TABLES(~180 KB savings)-DFASTLED_FORCE_UNWIND_TABLESif they need backtraces in a debug-flag-free build-DFASTLED_FORCE_NO_UNWIND_TABLES), measure binary delta, confirm panic decoder still works in default modeesp32_exception_decoder, document expected output)zackees commentedon May 1, 2026
Status update — implementation in flight
Landed-as-PR work
#2423 —
feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headersFL_NO_UNWIND/FL_NO_UNWIND_BEGIN/FL_NO_UNWIND_ENDtosrc/fl/stl/compiler_control.h(chose this over a newcodegen.hsince the file already hosts every other_Pragma-based macro pair in the codebase)src/platforms/esp/32/_build.cpp.hppandsrc/platforms/esp/32/drivers/_build.cpp.hpp!RELEASE,FASTLED_TESTING,FASTLED_FORCE_DBG,FASTLED_DEBUG,FL_DEBUG,!NDEBUG), or whenFL_IS_ESP32is defined and ESP-IDF / Arduino-ESP32 indicates the user wants backtraces (CONFIG_ESP_SYSTEM_PANIC_PRINT_BACKTRACE,CONFIG_ESP_SYSTEM_PANIC_GDBSTUB,CONFIG_ESP_DEBUG_OCDAWARE,CONFIG_COMPILER_OPTIMIZATION_DEBUG,CONFIG_COMPILER_OPTIMIZATION_NONE,CORE_DEBUG_LEVEL >= 3). User can override withFASTLED_FORCE_UNWIND_TABLES/FASTLED_FORCE_NO_UNWIND_TABLES.CORE_DEBUG_LEVEL=3which keeps unwind tables on)FL_IS_ESP32instead of the spec'sdefined(ESP32) || defined(ESP_PLATFORM)because the lint ruleNativePlatformDefinesCheckerforbids bare native platform defines. Strictly equivalent or broader gate.optimize("no-unwind-tables")(single flag) instead of the redundant pair —-fno-unwind-tablesimplies-fno-asynchronous-unwind-tableson GCC.FL_IS_GCC(not clang) because clang's per-function optimize attribute support is uneven.Filed-as-issue work
#2424 —
[Tracking] Break unwanted cross-TU references that drag optional subsystems into all buildsfile:linereferences in FastLED source where core/system code unconditionally references symbols from optional subsystems (audio, remote, net, fx, gfx, video, third_party)src/FastLED.cpp.hpp:706,711,716,721— fourCFastLED::add()overloads unconditionally referencefl::audio::AudioManager::instance(), dragging in the entire audio TU. Easy fix with#if FASTLED_HAS_AUDIOguards.Still in this tracking issue (no PR yet)
FASTLED_TIGHT_TIMINGdefine for the per-show()vTaskDelay(1)regression — this is the TIMING half of the bug from [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420, untouched by feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headers #2423 which only addresses binary size_build.cpp.hppto actually shrink driver code (feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headers #2423 only kills the eh_frame, not the code itself)bloaty/nm --size-sortautomation as a CI check to catch future regressionsWhat this means for @nomakewan and #2420
Once #2423 lands, you can rebuild your sketch with
-D FASTLED_FORCE_NO_UNWIND_TABLESinbuild_flags. Expected savings: ~150-180 KB, taking your binary from 783 KB → ~600-630 KB. Still ~280 KB above 3.10.3 baseline (344 KB), so this is a partial fix — the timing regression and the per-driver gating are both still needed for a full fix.Backtraces from
esp32_exception_decoderwill show???for any frame inside the wrapped TUs (the ESP32 driver code) when you opt in. If you need actionable backtraces for crash reports, leave the flag off and accept the larger binary.feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headers
feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headers
zackees commentedon May 5, 2026
ESP32-S3 .bin symbol analysis (Blink, master)
Compiled
examples/Blinkwith default options (NEOPIXEL pin 3, 1 LED). Build:release,-Os. Bin = 830,304 B (matches the reporter's ~783 KB). Working fromfirmware.elf+firmware.bin(not just ELF — segment-level filter applied so debug/comment sections are excluded).Section layout of firmware.bin (LOAD-flagged PROGBITS only)
.flash.rodata.flash.text.iram0.text.dram0.data.iram0.vectors.flash.appdesc.rtc.force_slownm-attributed bytes by category (452 KB attributed; rest is anonymous .rodata strings — see bottom)
FastLED breakdown — where the FastLED bytes actually go (158 KB total)
fl::*other (RMTBufferPool, gamma, etc.)Channel::showPixelsfl::containers (vector/string/shared_ptr/HashMap)fl::platforms::initChannelDriversregistryTop 15 individual symbols in bin
_vfprintf_r(newlib)_svfprintf_r(newlib)fl::wave3Transpose_16(...)— bit-bang transposer in IRAMfl::ChannelEngineRMTImpl::createChannel(...)fl::platforms::initChannelDrivers()← the registryfl::ChannelEngineSpi::createChannel(...)port_IntStack(FreeRTOS)fl::Channel::showPixels(...)fl::wave8Transpose_16(...)fl::RmtMemoryManager::allocateTx(...)fl::ChannelEngineUART::beginTransmission(...)fl::ChannelEngineSpi::acquireChannel(...)fl::ChannelEngineRMTImpl::reconfigureForNetwork()fl::UartPeripheralEsp::initialize(...)fl::ChannelEngineI2S::beginTransmission(...)ESP-IDF transitively pulled in because of the Channel API
These ESP-IDF translation units only get linked because FastLED's Channel drivers reference their entry points. None of them are needed by stock 3.10.3 RMT4 path.
esp_driver_rmt/rmt_tx.cesp_hw_support/dma/gdma.cesp_driver_spi/spi_master.cesp_lcd/i80/esp_lcd_panel_io_i80.cesp_driver_spi/spi_common.cesp_driver_rmt/rmt_rx.cespcoredump/core_dump_elf.cesp_driver_gpio/gpio.cesp32-hal-uart.cSubtotal of "pulled by Channel API": ~30 KB of ESP-IDF code that 3.10.3 wouldn't have linked.
.flash.rodata — the 365 KB elephant
.flash.rodatais 385,900 B, butnm/objdump -tonly attribute 21,208 B to named symbols (vtables, gamma LUTs, error tables). The remaining ~365 KB is anonymous string literals — predominantly ESP-IDFESP_LOGE/ESP_LOGW/ESP_LOGIformat strings + filenames + function names from each__func__artifact. Each driver TU pulled in adds its own log/error strings here.Top named rodata symbols:
esp_err_msg_tablertc_io_descintr_desc_tablefl::ProgmemLUT16<fl::GammaEval16<...>, 256>::kDataesp_isr_namesm_CRC7Table,__chclasssoc_memory_regions,__mprec_tensConclusion (what's confirmed vs. the issue's hypothesis)
src/platforms/esp/32/drivers/_build.cpp.hppunconditionally#includes every driver family (ble, gpio_isr_rx, i2s, i2s_spi, lcd_cam, lcd_spi, parlio, rmt, rmt_rx, spi, uart). Each driver'sstaticregistration inChannelManager::mDriversdefeats--gc-sections, so the linker keeps them all.rmt_rx.c,esp_lcd_panel_io_i80.c,spi_master.c,gdma.c, ...) plus their rodata log strings which dominate the otherwise-mysterious 365 KB anonymous-rodata bulge.Tooling used:
xtensa-esp32s3-elf-{nm,readelf,objdump,addr2line,c++filt}+ two helper scripts I added atci/bin_bloat_analysis.py(regex categorization) andci/bin_bloat_attribute.py(addr2line source-file attribution). They take only thefirmware.elf+ section LOAD-flag map as input, so the same scripts will work on the reporter's binary from #2420 once they upload it.ci: fix ty errors, fingerprint cache canonicalization, add bin-bloat …
zackees commentedon May 9, 2026
Filed #2428 as the proposed source-level fix for the binary-bloat half of this tracker. Compile-time
Busbinding via templatedChannelConfig<Chipset>so only the named driver(s) survive the linker — NEOPIXEL-only sketches should drop back to the ~344 KB 3.10.3 baseline. Also removes the manager-sidevTaskDelay(1)floor in the default path (manager moves to opt-inenableDrivers<...>()).feat(channels): add fl::Bus enum + BusTraits foundation (Phase 1 of #…
feat(channels): pre-bind legacy clockless to BusTraits singleton (Pha…
feat(channels): add fl::enableAllDrivers() one-shot driver enrollment (…
feat(channels): add fl::enableAllDrivers() one-shot driver enrollment (…
5 remaining items
feat(channels): remove FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY macro (…
feat(channels): remove FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY macro (…
refactor(stdio): route libFastLED.a printf through fl::snprintf + lin…
feat(stl): FL_NO_INLINE portable macro + cold-helper split for showPi…
zackees commentedon Jun 8, 2026
@nomakewan as you can see from the flurry of PR's I've focused on the binary bloat over the last few days. Feel free to give it a spin.
nomakewan commentedon Jun 8, 2026
On the test program from #2420, the code from
master#91602d5gives a binary size of 633KB withCORE_DEBUG_LEVEL=0andLOG_LOCAL_LEVEL=ESP_LOG_NONE, and a binary size of 644KB withCORE_DEBUG_LEVEL=3andLOG_LOCAL_LEVEL=ESP_LOG_INFOA significant improvement over the initial 768KB/783KB, but still not quite as lean 'n' mean as 3.10.3's 330KB/344KB.
EDIT: Just for reference, updating the framework to Arduino-ESP32 3.3.9 increased the binary size by ~1KB. So 3.10.3 on 3.3.9 went up to 331/345KB. So moving to the latest-and-greatest ESP-IDF did not meaningfully increase the binary sizes.
zackees commentedon Jun 8, 2026
Can you swap out
platformiowith fbuild and tell me what your numbers are. Platformio wants to insert exception handling frames where a lot of the bloat is coming from.fbuilddoes the right thing.pip install fbuildfbuildis a drop in replacement, all theplatformiocommands work, and will work with yourplatformio.ininomakewan commentedon Jun 8, 2026
My apologies, but I am not willing to do that, just as I am not willing to swap out our timekeeping functions with FastLED's either.
My stance is that this setup worked previously with any timekeeping function in the Arduino ecosystem and that compiling worked both on the Arduino IDE as well as vanilla PlatformIO without bloat. FastLED, in my opinion, should continue to do the same as it has in the past. An addressable LED control library should be agnostic of non-addressable-LED-related user code as well as build environment.
zackees commentedon Jun 9, 2026
The bloat you are seeing is coming from PlatformIO injecting exception-handling frames, even when the affected functions are not actually used.
There is no library-side fix for that.
The only workaround is to suppress those sections with SCons build flags in platformio.ini. But if you do that, good luck getting a useful crash dump when something goes wrong.
I have already rewritten the Channels API so drivers are only selectively included. I added FL_NOEXCEPT across the codebase. I have done the work. It does not solve this, because the problem is not the API. The problem is the build tool.
What you are asking for is not reasonable.
FastLED 4.0 is going to be the most important release this project has ever had. I am not going to fork the entire codebase, compromise the architecture, and punish every other user because replacing a broken build tool with a real professional build tool is "too much for you".