Fix race condition with keyboard and Wifi entry#204
Merged
daveallie merged 1 commit intocrosspoint-reader:masterfrom Jan 2, 2026
Merged
Conversation
daveallie
approved these changes
Jan 2, 2026
Member
daveallie
left a comment
There was a problem hiding this comment.
Apologies, I think I broke this, thanks for fixing it!
yingirene
pushed a commit
to yingirene/crosspoint-reader
that referenced
this pull request
Jan 16, 2026
## Summary * **What is the goal of this PR?** Fixes a bug - crosspoint-reader#187 - where the screen would freeze after entering a WiFi password, causing the device to appear hung. * **What changes are included?** - Fixed a race condition in `WifiSelectionActivity::displayTaskLoop()` that caused rendering of an empty screen when transitioning from the keyboard subactivity - Added `vTaskDelay()` when a subactivity is active to prevent CPU starvation from a tight `continue` loop - Added a check to skip rendering when in `PASSWORD_ENTRY` state, allowing the state machine to properly transition to `CONNECTING` before the display updates ## Additional Context * **Root cause:** When the keyboard subactivity exited after password entry, the display task would wake up and attempt to render. However, the `state` was still `PASSWORD_ENTRY` (before `attemptConnection()` changed it to `CONNECTING`), and since there was no render case for `PASSWORD_ENTRY`, the display would show a cleared/empty buffer, appearing frozen. * **Performance implications:** The added `vTaskDelay(10)` calls when subactivity is active or in `PASSWORD_ENTRY` state actually improve performance by preventing CPU starvation - previously the display task would spin in a tight loop with `continue` while a subactivity was present. * **Testing focus:** Test the full WiFi connection flow: 1. Enter network selection 2. Select a network requiring a password 3. Enter password and press OK 4. Verify "Connecting..." screen appears 5. Verify connection completes and prompts to save password
Unintendedsideeffects
pushed a commit
to Unintendedsideeffects/crosspoint-reader
that referenced
this pull request
Feb 17, 2026
## Summary * **What is the goal of this PR?** Fixes a bug - crosspoint-reader#187 - where the screen would freeze after entering a WiFi password, causing the device to appear hung. * **What changes are included?** - Fixed a race condition in `WifiSelectionActivity::displayTaskLoop()` that caused rendering of an empty screen when transitioning from the keyboard subactivity - Added `vTaskDelay()` when a subactivity is active to prevent CPU starvation from a tight `continue` loop - Added a check to skip rendering when in `PASSWORD_ENTRY` state, allowing the state machine to properly transition to `CONNECTING` before the display updates ## Additional Context * **Root cause:** When the keyboard subactivity exited after password entry, the display task would wake up and attempt to render. However, the `state` was still `PASSWORD_ENTRY` (before `attemptConnection()` changed it to `CONNECTING`), and since there was no render case for `PASSWORD_ENTRY`, the display would show a cleared/empty buffer, appearing frozen. * **Performance implications:** The added `vTaskDelay(10)` calls when subactivity is active or in `PASSWORD_ENTRY` state actually improve performance by preventing CPU starvation - previously the display task would spin in a tight loop with `continue` while a subactivity was present. * **Testing focus:** Test the full WiFi connection flow: 1. Enter network selection 2. Select a network requiring a password 3. Enter password and press OK 4. Verify "Connecting..." screen appears 5. Verify connection completes and prompts to save password
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.
Summary
What is the goal of this PR? Fixes a bug - No connection to WiFi anymore #187 - where the screen would freeze after entering a WiFi password, causing the device to appear hung.
What changes are included?
WifiSelectionActivity::displayTaskLoop()that caused rendering of an empty screen when transitioning from the keyboard subactivityvTaskDelay()when a subactivity is active to prevent CPU starvation from a tightcontinueloopPASSWORD_ENTRYstate, allowing the state machine to properly transition toCONNECTINGbefore the display updatesAdditional Context
Root cause: When the keyboard subactivity exited after password entry, the display task would wake up and attempt to render. However, the
statewas stillPASSWORD_ENTRY(beforeattemptConnection()changed it toCONNECTING), and since there was no render case forPASSWORD_ENTRY, the display would show a cleared/empty buffer, appearing frozen.Performance implications: The added
vTaskDelay(10)calls when subactivity is active or inPASSWORD_ENTRYstate actually improve performance by preventing CPU starvation - previously the display task would spin in a tight loop withcontinuewhile a subactivity was present.Testing focus: Test the full WiFi connection flow: