Skip to content

ESP32-S3 LCD_CLOCKLESS: let the application choose the worker task's core (currently created unpinned at priority 23) #5001

Closed

Description

@SuperDaftBros

Problem

I'm working on a project that requires tight timing and takes advantage of the ESP32-S3 dual core setup to ensure servicing the timing-critical components is not impacted by LED rendering and communication. In the current ChannelDriverLcdClockless::ensureWorkerTask() code, fl_lcd_clk starts with xTaskCreate() at priority configMAX_PRIORITIES - 2. This results in priority 23 based on the default priority 25, which is the same level as the Wi-Fi driver. The scheduler can then run it on either core, and it preempts everything below 23 on that core.

My app currently splits the cores as follows:
-loop() on Core 1 renders and calls FastLED.show();
-a network task on Core 0 (priority 5) handles an Ethernet controller and a latency-sensitive input path that needs each pass to finish within 5 ms.

With six WS2812B strips (170 LEDs each) on LCD_CLOCKLESS, FastLED 3.10.8, Arduino-ESP32 3.3.12 / ESP-IDF 5.5.5, our worst network-task pass went from 4.8 ms to 39 ms. With the worker pinned to Core 1 (one-line change below) it's back to 4.7 ms, and the LEDs still update cleanly (show() ≈ 8 ms for the frame).

ESP-IDF can't move a task to another core after it's created, and the task is created without a Core argument inside the driver, so an application has no way to fix this from outside without patching the library.

Proposed solution

Allow the user to specify core and priority, and potentially default to the same core as show():

  1. provide a build-time option, e.g. FASTLED_ESP32_LCD_WORKER_CORE (and maybe FASTLED_ESP32_LCD_WORKER_PRIORITY), passed to xTaskCreatePinnedToCore() in ensureWorkerTask(). tskNO_AFFINITY keeps today's behavior.
  2. default the core for the worker to the core that calls show(), since that's the core the application has chosen for LED work.

I've currently patched the driver as follows:

BaseType_t ok = xTaskCreatePinnedToCore(workerTaskEntry, "fl_lcd_clk",
                                        4096, this, priority, &handle, 1);

The same request may apply to other drivers that start worker tasks (e.g., the I2S/LCD_CAM and PARLIO engines), if they create them the same way.

Alternatives considered

  • Lowering the task's priority after FastLED creates it (vTaskPrioritySet): it stays unpinned, and a low priority risks DMA ring underruns, which show as glitches.
  • Patching the source at build time: what's implemented now (a PlatformIO pre-build script that swaps the one call and stops the build if the code changes), but it's fragile across releases.
  • The RMT driver instead: on the S3 it can't drive six strips in parallel (four TX channels), and 3.10.8's RMT5 engine leaks on channel reconfiguration (see the existing memory-leak issue #4993).

Platform relevance

ESP32

Additional context

Time data is from an ESP32-S3 (N16R8) with a W5500 Ethernet controller on Core 0 and six WS2812B strips on GPIO 1–6.
Happy to test or provide other details that might be helpful. Also willing to attempt a pull request, though it would be my first time.

Activity

  1. added
    status: triage
    type: feature
    on Nov 2, 2026
  2. moved this from Triage to Done in FastLED Trackeron Nov 3, 2026
  3. reopened this on Nov 3, 2026
  4. moved this from Done to Triage in FastLED Trackeron Nov 3, 2026
  5. zackees commented on Nov 3, 2026

    @zackees
    Member

    still need a priority argument

  6. added
    sanitized
    on Nov 6, 2026
  7. zackees commented on Nov 21, 2026

    @zackees
    Member

    Both parts of this are on master:

    So your pre-build patch can become -DFL_ENGINE_WORKER_CORE=fl::Core::Core1 (or fl::Core::CallingCore to follow show()). See src/fl/channels/README.md for the per-channel form.

    Scope note: these settings currently apply only to the LCD/I2S clockless engine. PARLIO and the other engines still use their own task setup. If you need the same control there, please open a new issue.

  8. moved this from Triage to Done in FastLED Trackeron Nov 21, 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

    sanitizedstatus: triagetype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions