Conversation
added 7 commits
March 18, 2026 21:55
Comment on lines
+28
to
+38
| case STATE_PLAYING: | ||
| confirm_choice(); | ||
| break; | ||
| case STATE_OVER_LOST: | ||
| start_game(); | ||
| break; | ||
| case STATE_OVER_WIN: | ||
| break; | ||
| } | ||
| } | ||
| if(actionOpt == Action_Select && currentState == STATE_PLAYING) |
There was a problem hiding this comment.
Bug: Rapidly pressing the confirm button queues multiple actions. The sequential processing of these actions causes the result screen to be immediately overwritten by the new game screen.
Severity: HIGH
Suggested Fix
To prevent this, consider clearing the action queue after a significant state transition. For example, after processing an action that moves the game from STATE_PLAYING to STATE_OVER_LOST/STATE_OVER_WIN, call xQueueReset(actionQueue) to discard any stale, queued-up actions. Alternatively, add a state check before sending actions to the queue, or introduce a short delay or a "cooldown" state after showing the result screen to prevent immediate restarts.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/main.c#L28-L38
Potential issue: Due to the use of an action queue with a capacity of 8 and non-blocking
sends from button callbacks, rapid presses of the confirm button can queue multiple
`Action_Confirm` events. The `queueHandle` task processes these sequentially. The first
event triggers `confirm_choice()`, which displays the result screen and sets the state
to `STATE_OVER_LOST` or `STATE_OVER_WIN`. The loop immediately processes the next queued
`Action_Confirm`, which then calls `start_game()` based on the new state. This
overwrites the result screen with a new game screen, making the result screen flash for
only a few milliseconds or not appear at all.
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.
Cut down "IO wait" time on main game thread.
Still doesnt resolve the random crash issue smh