partly disable waitUntilIdle() as its still work-in-progress

This disables parts of the new feature that might lead to delays, so basicially there is some detection, but no protection any more.

further development needed --> audio_fastpath branch

compile with -D WLEDMM_PROTECT_SERVICE to enable full protection.
This commit is contained in:
Frank
2023-06-01 21:55:46 +02:00
parent 333f5ac2a1
commit 404fb566fa
7 changed files with 19 additions and 12 deletions

View File

@@ -817,6 +817,7 @@ build_flags_S =
-D USERMOD_AUDIOREACTIVE
-D UM_AUDIOREACTIVE_USE_NEW_FFT ; use latest (upstream) FFTLib, instead of older library modified by blazoncek. Slightly faster, more accurate, needs 2KB RAM extra
-D USERMOD_ARTIFX ; WLEDMM usermod
; -D WLEDMM_PROTECT_SERVICE ;; WLEDMM experimental feature to prevent crashes when effects are drawing while async_tcp tries to modify segment or strip objects.
; -D WLED_DISABLE_LOXONE
; -D WLED_DISABLE_ALEXA
; -D WLED_DISABLE_HUESYNC

View File

@@ -75,10 +75,12 @@
// WLEDMM experimental . this is a "C style" wrapper for strip.waitUntilIdle()
// This workaround is just needed for the segment class, that does't know about "strip"
void strip_wait_until_idle(String whoCalledMe) {
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental
if (strip.isServicing() && (strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) != 0)) { // if we are in looptask (arduino loop), its safe to proceed without waiting
USER_PRINTLN(whoCalledMe + String(": strip is still drawing effects, waiting ..."));
USER_PRINTLN(whoCalledMe + String(": strip is still drawing effects."));
strip.waitUntilIdle();
}
#endif
}
@@ -1520,7 +1522,7 @@ void WS2812FX::finalizeInit(void)
// on 8266 this function does nothing, because we can only do "buisy waiting" on ESP32
#define MAX_IDLE_WAIT_MS 50 // seems to work in most cases
void WS2812FX::waitUntilIdle(void) {
#ifdef ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE)
if (isServicing()) {
unsigned long waitStarted = millis();
do {

View File

@@ -95,9 +95,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
#ifdef ARDUINO_ARCH_ESP32
if (strip.isServicing() && (strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) != 0)) { // if we are in looptask (arduino loop), its safe to proceed without waiting
if (fromFS) {
USER_PRINTLN(F("deserializeConfig(fromFS): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("deserializeConfig(fromFS): strip is still drawing effects."));
} else {
USER_PRINTLN(F("deserializeConfig(): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("deserializeConfig(): strip is still drawing effects."));
}
strip.waitUntilIdle();
}

View File

@@ -91,7 +91,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
// WLEDMM: before changing segments, make sure our strip is _not_ servicing effects in parallel
suspendStripService = true; // temporarily lock out strip updates
if (strip.isServicing()) {
USER_PRINTLN(F("deserializeSegment(): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("deserializeSegment(): strip is still drawing effects."));
strip.waitUntilIdle();
}
@@ -410,7 +410,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
// WLEDMM: before changing strip, make sure our strip is _not_ servicing effects in parallel
suspendStripService = true; // temporarily lock out strip updates
if (strip.isServicing()) {
USER_PRINTLN(F("deserializeState(): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("deserializeState(): strip is still drawing effects."));
strip.waitUntilIdle();
}

View File

@@ -21,11 +21,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 7: DMX 8: usermods 9: N/A 10: 2D
if (subPage <1 || subPage >10 || !correctPIN) return;
// WLEDMM: before changing bus or strip settings, make sure our strip is _not_ servicing effects in parallel
if ((subPage == 2) || (subPage == 10)) {
// WLEDMM: before changing bus, ledmap, strip or 2D settings, make sure our strip is _not_ servicing effects in parallel
if ((subPage == 2) || (subPage == 3) || (subPage == 10)) {
suspendStripService = true; // temporarily lock out strip updates
if (strip.isServicing()) {
USER_PRINTLN(F("handleSettingsSet(): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("handleSettingsSet(): strip is still drawing effects."));
strip.waitUntilIdle();
}
}
@@ -775,7 +775,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
}
#endif
if ((subPage == 2) || (subPage == 10)) {
if ((subPage == 2) || (subPage == 3) || (subPage == 10)) {
suspendStripService = false; // WLEDMM release lock
}
@@ -817,7 +817,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
// WLEDMM: before changing segment settings, make sure our strip is _not_ servicing effects in parallel
if (strip.isServicing()) {
USER_PRINTLN(F("handleSet(): strip is still drawing effects, waiting ..."));
USER_PRINTLN(F("handleSet(): strip is still drawing effects."));
strip.waitUntilIdle();
}

View File

@@ -165,15 +165,19 @@ void WLED::loop()
unsigned long stripMillis = millis();
#endif
if (!offMode || strip.isOffRefreshRequired()) {
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE) // WLEDMM experimental
static unsigned long lastTimeService = 0; // WLEMM needed to remove stale lock
if (!suspendStripService && !doInitBusses && !loadLedmap) { // WLEDMM prevent effect drawing while strip or segments are being updated
#endif
strip.service();
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_PROTECT_SERVICE)
lastTimeService = millis();
} else {
if (suspendStripService && (millis() - lastTimeService > 1500)) { // WLEDMM remove stale lock after 1.5 seconds
USER_PRINTLN("--> looptask: stale suspendStripService lock removed after 1500 ms."); // should not happen - check for missing "suspendStripService = false"
}
}
#endif
}
#ifdef ESP8266
else if (!noWifiSleep)

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2306010
#define VERSION 2306011
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG