python-editor-v3
python-editor-v3 copied to clipboard
[Simulator] while True: radio.on() locks up sim
while True:
radio.on()
Appears to lock up the sim.
We should get a change to break out but we don't.
This doesn't seem to be an issue when using the simulator demo so perhaps we're just doing much more work on each simulator state change. Perhaps we should RAF rate-limit the simulator state updates.
It gets better with useRafState (stoppable again) but you can see re-rendering play out for some time after you click stop. Probably fixable with some re-render optimisation. Probably enough just to push down the listening so we have state fields that are the relevant components of the sim state rather than everything. Or a bunch of memoising. Might be better to try RAF inside the sim.
Just tried this and it seemed fine, needs a little more digging at some point.
This is still currently an issue for me. The longer you let the while loop run, the worse the effect is as everything waits to catch up. The same thing happens with radio.send(). Forgetting a call to sleep() is probably going to be common error as well.
We only disable the radio on radio.on() in order to reconfigure the radio in drv_radio.c. Can we check whether the configuration has changed and only disabled/re-enable if it has? This won't help in the case of radio.send() so some form of rate-limiting will likely be required.