From ed3b092a47a842de8e34aa17779abad3b9853dd1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:37:06 +0000 Subject: [PATCH 1/2] Initial plan From 25a875e4d98ab95a5c90d3300ea9b4e027f7c053 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:45:54 +0000 Subject: [PATCH 2/2] Fix race condition in 2D config save by deferring resume() Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com> --- wled00/FX_2Dfcn.cpp | 3 ++- wled00/set.cpp | 1 + wled00/wled.cpp | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 751bc5ac14..2e1b3a86ef 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -113,7 +113,7 @@ void WS2812FX::setUpMatrix() { // delete gap array as we no longer need it p_free(gapTable); - resume(); + // NOTE: do not resume() here; caller must call resume() after segments are updated #ifdef WLED_DEBUG DEBUG_PRINT(F("Matrix ledmap:")); @@ -130,6 +130,7 @@ void WS2812FX::setUpMatrix() { Segment::maxWidth = _length; Segment::maxHeight = 1; resetSegments(); + resume(); // resume here since resetSegments() was called } } #else diff --git a/wled00/set.cpp b/wled00/set.cpp index 893081b986..12fd8f2207 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -817,6 +817,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) strip.panel.shrink_to_fit(); // release unused memory strip.deserializeMap(); // (re)load default ledmap (will also setUpMatrix() if ledmap does not exist) strip.makeAutoSegments(true); // force re-creation of segments + strip.resume(); // resume strip service after 2D config changes are complete } #endif diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 923688106d..f60f32b9f2 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -193,6 +193,7 @@ void WLED::loop() strip.finalizeInit(); // will create buses and also load default ledmap if present if (aligned) strip.makeAutoSegments(); else strip.fixInvalidSegments(); + strip.resume(); // resume strip service after bus re-initialization BusManager::setBrightness(scaledBri(bri)); // fix re-initialised bus' brightness #4005 and #4824 configNeedsWrite = true; } @@ -563,6 +564,7 @@ void WLED::beginStrip() strip.setTransition(0); // temporarily prevent transitions to reduce segment copies strip.finalizeInit(); // busses created during deserializeConfig() if config existed strip.makeAutoSegments(); + strip.resume(); // resume strip service after initialization strip.setBrightness(0); strip.setShowCallback(handleOverlayDraw); doInitBusses = false;