WIP: reduce stack buffer usage for AudioReactive settings page #94
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we cannot add any more options to the AudioReactive settings page, as the buffer used by
oappend()
is very limited and cannot be expanded any more (its placed into the task stack, not into the heap ... for historical reasons and to help tiny 8266).This is an attempt to work around the problem, by shortening the strings that are passed into
oappend()
. A typical call looks like this:oappend(SET_F("dd=addDropdown('AudioReactive','config:AGC');"));
. We can shorten the JS function names like thisbefore: String buffer usage: 3540 of 3871 bytes
after: String buffer usage: 3158 of 3871 bytes
==> 382 bytes saved
Actually its even possible to save more buffer space, if "AudioReactive" gets replaced by "AR": String buffer usage: 2784 of 3871 bytes
==> another 368 bytes of potential savings
To be discussed:
a) depending on predefined PINs from the buildenv, stack buffer usage can be bigger because descriptions get longer.
b) source code is harder to read after replacing names; so maybe better that
oappend()
peforms the replacement behind the scenes, without needing to modify audioreactive code.c) Changing "AudioReactive" to "AR" in parameters causes problems in other areas; so maybe that could be another behind-the-scenes optimimization done by oappend. It would then need to be "undone" in the JS part, so that parameters with "AR" become "AudioReactive" again.
actually for point c) i don't have an idea for implementation yet - I'm still a "hobby coder" when it comes to JavaScript 😅
@netmindz, @ewoudwijma and other devs: I would be happy to get your opinions, ideas, and possible alternatives.
Right now we are at the limits and cannot add new options to the AudioReactive settings page any more.