Watchdog triggered when loading a webpage form SPIFSS

Hey guys!

I got this ESP32 that hosts its own little web server, I load the HTML/ CSS and images out of the ESP using SPIFFS. But I get a watchdog trigger (most of the time) because loading takes too long. I read that adding delay(1) to the function would help fix it. But it still triggers it.

The file is about 200kb and just takes a bit too long for the ESP to load.

wifiHandler hotspot;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("startup");
  if (SPIFFS.begin()) { 
		Serial.println("SPIFFS MOUNTED");
	}
  eeprom.init();
  eeprom.dumbData();

  server.on("/", HTTP_GET, hotspot.handleOnHome);
  server.on("/get", HTTP_GET, hotspot.handleGetData);
  server.onNotFound(hotspot.handleNotFound);
  server.on("/logo", HTTP_GET, hotspot.handleGetLogo);
  server.on("/background", HTTP_GET, hotspot.handleGetBackground);
  server.on("/style.css", HTTP_GET, hotspot.handleGetCSS);  
  server.begin();
}

void loop(){

}

wifiHandler.cpp

void wifiHandler::handleGetCSS(AsyncWebServerRequest *request){
    Serial.println("function: handleGetCSS");

    request->send(SPIFFS, "/style.css", "text/css");
    delay(1);
}

void wifiHandler::handleOnHome(AsyncWebServerRequest *request){
    Serial.println("function: handleOnHome");

   request->send(SPIFFS, "/ServerMain.html", String());
   delay(1);
}

void wifiHandler::handleGetData(AsyncWebServerRequest *request){
    Serial.println("function: handleGetDataAP");

    String dataFromWebserver[PARAMETERS_EEPROM];
    if (request->hasParam("ssidFromSetup")) {
        dataFromWebserver[0] = request->getParam("ssidFromSetup")->value();
    } 
    if (request->hasParam("passwordFromSetup")) {
        dataFromWebserver[1] = request->getParam("passwordFromSetup")->value();
    }
    if (request->hasParam("urlFromSetup")){
        dataFromWebserver[2] = request->getParam("urlFromSetup")->value();
    }

    Serial.printf("Data of the website: %s, %s, %s\r\n", dataFromWebserver[0].c_str(), dataFromWebserver[1].c_str(), dataFromWebserver[2].c_str());

    if (eeprom.saveData(dataFromWebserver, (sizeof(dataFromWebserver) / sizeof(dataFromWebserver[0])), true)){
        request->send(SPIFFS, "/ServerSucces.html", String());
        for (uint8_t i  = 0; i < PARAMETERS_EEPROM; i++){
        eeprom.getParameter(0, fromEeprom[0]);
        }
        broadcast = true;
    } else {
        Serial.println("Something went wrong"); 
        request->send(200, "text/plain", "something went wrong, please restart and retry");
    }
    delay(1);
}

void wifiHandler::handleNotFound(AsyncWebServerRequest *request){
    Serial.println("function: handleNotFound");
    // TODO Make a 404 page
    request->send(SPIFFS, "/ServerNotFound.html", String());
    delay(1);
}

void wifiHandler::handleGetLogo(AsyncWebServerRequest *request){
    Serial.println("function: handleGetLogo");

    request->send(SPIFFS, "/logo.png", "image/png");
    delay(1);
}
void wifiHandler::handleGetBackground(AsyncWebServerRequest *request){
    Serial.println("function: handleGetBackground");

    request->send(SPIFFS, "/background.jpg", "image/jpg");
    delay(1);
}

Serial monitor:

devices connected to AP, MAC: c0:3c:59:32:9e:07
Hotspot assigned IP: 192.168.1.3
function: handleOnHome
function: handleGetCSS
function: handleGetLogo
function: handleGetBackground
E (189149) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (189149) task_wdt:  - async_tcp (CPU 0/1)
E (189149) task_wdt: Tasks currently running:
E (189149) task_wdt: CPU 0: IDLE0
E (189149) task_wdt: CPU 1: loopTask
E (189149) task_wdt: Aborting.
abort() was called at PC 0x40148a48 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x400890ec:0x3ffbfa40 0x40089369:0x3ffbfa60 0x40148a48:0x3ffbfa80 0x40087055:0x3ffbfaa0 0x4017dd63:0x3ffbc250 0x4014a343:0x3ffbc270 0x4008bb39:0x3ffbc290 0x4008a37a:0x3ffbc2b0
  #0  0x400890ec:0x3ffbfa40 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
  #1  0x40089369:0x3ffbfa60 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
  #2  0x40148a48:0x3ffbfa80 in task_wdt_isr at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/task_wdt.c:252
  #3  0x40087055:0x3ffbfaa0 in _xt_lowint1 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S:1154
  #4  0x4017dd63:0x3ffbc250 in esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c:492
  #5  0x4014a343:0x3ffbc270 in esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c:108
  #6  0x4008bb39:0x3ffbc290 in prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
  #7  0x4008a37a:0x3ffbc2b0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Rebooting...
ets Jun  8 2016 00:22:57
``

the doc states:

  • You can not use yield or delay or any function that uses them inside the callbacks

have you tried CSS compression tools? (eg CSS Minifier)

1 Like

Is it possible to break it up into smaller files and/or increase the watchdog time?

1 Like

Thanks for pointing that out, I removed the delay(1);

I just reduced the size of the image, the original file was 4K image of 330kb, and I reduced it to a 1080P image of just 90kb. That really helped with loading time.

Doesn't the ESP32 allow you to change the timeout of the watchdog? Is it as simple as increasing this time?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.