From 4a33809d6609d3016f523213f7146de22373bae3 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 18 Nov 2025 22:56:30 +0100 Subject: [PATCH] make waitForIt() timing logic robust against millis() rollover the timing logic did not work in case that millis()+100 + frametime rolls over; in this case millis() > maxWait, and waiting would be skipped which might lead to crashes. -> logic slightly adjusted to be robust against rollover. --- wled00/FX_fcn.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 465f1dcf..f83aed11 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1687,8 +1687,9 @@ void WS2812FX::setTransitionMode(bool t) { // rare circumstances are: setting FPS to high number (i.e. 120) and have very slow effect that will need more // time than 2 * _frametime (1000/FPS) to draw content void WS2812FX::waitForIt() { - unsigned long maxWait = millis() + 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779 - while (isServicing() && maxWait > millis()) delay(1); + unsigned long waitStart = millis(); + unsigned long maxWait = 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779 + while (isServicing() && (millis() - waitStart < maxWait)) delay(1); // safe even when millis() rolls over #ifdef WLED_DEBUG if (millis() >= maxWait) DEBUG_PRINTLN(F("Waited for strip to finish servicing.")); #endif