mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
fix(sim): skip blocking pre-shutdown buzzer wait in SIM_PLATFORM builds
UITask::shutdown() busy-waits on buzzer.isPlaying() for up to 2.5s before powering off. On real hardware that's a real (if crude) wait; in the Emscripten sim it's a synchronous block on the browser's single JS/wasm thread, which freezes the whole page for the duration -- reported as the site "zacinanie się" (stuttering) whenever hibernate/shutdown triggers. Guards it with #ifdef SIM_PLATFORM, mirroring the identical pattern already used a few lines below for the low-battery pre-shutdown pause. Verified empirically (not just by reading the diff): measured real requestAnimationFrame throughput on meshcore-solo-site while triggering hibernate for real (Home -> Shutdown page -> Enter). Before: 135 frames in 3.5s (607ms max stall). After: 633 frames in the same window (110ms max) -- confirmed with a real stash/rebuild before-after control. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iubftDmKNWmkNnhJRz8UH
This commit is contained in:
@@ -2023,9 +2023,17 @@ void UITask::shutdown(bool restart){
|
|||||||
while a non-blocking buzzer.loop() plays out in UITask::loop()
|
while a non-blocking buzzer.loop() plays out in UITask::loop()
|
||||||
*/
|
*/
|
||||||
buzzer.shutdown();
|
buzzer.shutdown();
|
||||||
|
#ifdef SIM_PLATFORM
|
||||||
|
// The sim runs single-threaded on the browser's main JS thread (no real
|
||||||
|
// hardware to actually shut down) -- up to 2.5s of a real, synchronous
|
||||||
|
// busy-wait here blocks that thread and freezes the whole page for the
|
||||||
|
// duration, same class of issue as the low-battery pre-shutdown pause
|
||||||
|
// skipped below. Skip the wait entirely in the sim.
|
||||||
|
#else
|
||||||
uint32_t buzzer_timer = millis(); // fail-safe shutdown
|
uint32_t buzzer_timer = millis(); // fail-safe shutdown
|
||||||
while (buzzer.isPlaying() && (millis() - buzzer_timer) < 2500)
|
while (buzzer.isPlaying() && (millis() - buzzer_timer) < 2500)
|
||||||
buzzer.loop();
|
buzzer.loop();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // PIN_BUZZER
|
#endif // PIN_BUZZER
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user