-->
Page 1 of 1

Crashing problems with CSSID ?

PostPosted: Mon May 29, 2017 10:24 am
by PhilTilson
I am posting this in both General and Bugs as I'm not sure it IS a bug and want to have the widest audience!

A while ago I posted in Projects some software for a 'wake-up light' that uses RGB LEDs. This seemed to have been working fine, but recently had crashed every time it started up, sometimes doing multiple crashes which were difficult to interrupt!

Having done some debugging, the problem seems to be with CSSID. I establish some buttons for controlling the light with lines like this:

Code: Select allbutton "Morning", [dayon]
btnday = htmlid()
cssid btnday, "background-color: lightgray; left: 130px;"

Later in the program, if the button is clicked, I call the routine:

Code: Select all[dayon]
io(pwo,rr,daylevel)
io(pwo,gg,daylevel)
io(pwo,bb,daylevel)
cssid btnday, "background-color: aqua;"
serialprintln dtg$ & "  Day_on: " & daylevel
wait

in order to change the button colour to indicate that the day lights are on. This works. Later, to turn them off, I use:

Code: Select all[alloff]
day_inc_active = 0
inclevel = 0
night_active = 0
io(pwo,rr,0)
io(pwo,gg,0)
io(pwo,bb,0)
cssid btnday, "background-color: lightgray;"
cssid btnnight, "background-color: lightgray;"
serialprintln dtg$ & "  All Off"
wait

This seems to work the first time, but subsequent calls cause a crash and memory dump. Once rebooted, I try again and the same thing happens.

If I remove the CSSID calls, the system is rock solid.

Surely I should be able to save the values obtained from HTMLID() in a variable and then use it subsequently for CSSID? It seems to work fine most of the time, but not here!

If anyone wants the full code to try running it to see if you get the same problem, let me know and I'll post it.

Phil

Re: Crashing problems with CSSID ?

PostPosted: Thu Jun 01, 2017 2:54 am
by mariolatronico
HI,
The following lines eat memory each time they are run:
cssid btnday, "background-color: aqua;"
cssid btnday, "background-color: lightgray;"
cssid btnnight, "background-color: lightgray;"
please, see: http://www.esp8266.com/viewtopic.php?f=42&t=13024
Electoguard's Memory Gauge is very useful for studying the event.
Try erasing and redrawing the graphical interface instead of change it.
regards

Re: Crashing problems with CSSID ?

PostPosted: Fri Jun 02, 2017 1:32 pm
by PhilTilson
Thanks - that's very helpful! I am pretty sure that this is what is causing the problem.

I'll confirm later!

Phil

Re: Crashing problems with CSSID ?

PostPosted: Sun Jun 04, 2017 11:48 am
by Mmiscool
This problem occurs because the CSS is constantly added to the bottom of the HTML buffer internally.

The only sure fire way to prevent this kind of problem is to redraw the gui and change the colors of an item only once.