Repository navigation
gui, menu: one LVGL lock, shared by the launcher and the pause menu - #8
Merged
Merged
Conversation
LVGL is built without LV_USE_OS, so it is not thread-safe, but the launcher (Gui) and the pause menu (Menu) each had their own mutex. Changing the volume or mute in the pause menu publishes volume_changed; Gui::on_volume then updated the launcher's widgets on the event-manager task while the pause menu's timer was still dispatching the slider's event. The two event pushes interleaved and left LVGL's global event list (event_head) pointing at a dead stack frame, and the next object delete walked it: the pause menu's teardown on quit faulted in lv_event_mark_deleted (Load access fault, seen after TPM's menu was used). Both now lock Tab5Emu::lvgl_mutex(), and pause() takes the lock after stopping its timer, so a callback already in lv_timer_handler() finishes before the caller goes on (esp_timer_stop does not wait for it). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ESP-IDF Size Report for 'Tab5 Emu'
FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a crash when quitting a game after its pause menu was used (seen with TPM): a
Load access faultinlv_event_mark_deletedduringMenu::deinit_ui().Cause
LVGL is built without
LV_USE_OS, so it isn't thread-safe. The launcher (Gui) and the pause menu (Menu) each had their own mutex, so they didn't exclude each other.volume_changed.Gui::on_volumethen updates the launcher's widgets on the event-manager task.The two event pushes interleave and leave LVGL's global event list (
event_head) pointing at a dead stack frame. The next object delete walks that list, which here was the pause menu's teardown on quit.Fix
Tab5Emu::lvgl_mutex().pause()takes that lock after stopping its timer, so a callback already insidelv_timer_handler()finishes before the caller goes on.esp_timer_stopdoesn't wait for a running callback.Testing (Tab5)
A temporary stress hook (local, not part of this PR) opens the pause menu every 4 s and toggles volume and mute 150 times from another thread, while the cart cycles through every game.
Gui::on_volumeon the event task.🤖 Generated with Claude Code