letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.22k stars 2.2k forks source link

delayBackground(time) is not working properly and might cause crashes #683

Closed TD-er closed 6 years ago

TD-er commented 6 years ago

See pull request #682 and issues #679, #676 and #674 and this topic on the forum.

Call to delayBackground() is now removed from the Controller::sendData(), which was probably the most frequently used call to this function.

This function is a wrapper to run backgroundtasks() often while waiting.

It is also called from:

backgroundtasts() is called from:

It looks like calling the backgroundtasks() too often may trigger something strange.

Also strange is the special usecase for Controller[0], which is sometimes hard-coded in the code. Then calls like this are being made: getProtocolIndex(Settings.Protocol[0]); While something like this is to be expected: getProtocolIndex(Settings.Protocol[event->ControllerIndex]);

psy0rz commented 6 years ago

Ok i moved the mqtt stuff out of backgroundtasks. This fixes it in my scenario. (domotics MQTT with a message delay of 10000ms)

TD-er commented 6 years ago

I've looked at the code-change. Please also test with Domoticz MQTT as first (only?) controller and the switch and press it as fast as you can. The yield is not always called, since sometimes the time between processing of messages is just about 1 sec (the default delay) and then it will not always call the yield.

psy0rz commented 6 years ago

I did exactly that. Before it crashed immediately, and after the change it seems stable.

If the time is short enough you dont need to call yield. The watchdog will only kick in after 5 or 10 seconds or something.

psy0rz commented 6 years ago

together with the memory issue fixes i consider this fixed for now. otherwise please comment/reopen. :)