Merge remote-tracking branch 'gitea/fix-refresh-race'

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
Adolfo Reyna
2026-02-13 16:16:14 -05:00
+6 -2
View File
@@ -88,7 +88,7 @@ void core1_entry() {
while (1) { while (1) {
// Wait for refresh request // Wait for refresh request
if (refresh_requested && refresh_buffer && refresh_display) { if (refresh_requested && refresh_buffer && refresh_display) {
refresh_in_progress = true; // refresh_in_progress is already set by Core 0 to lock the buffer
// Get local copies for safe access // Get local copies for safe access
LowLevelDisplay* display = refresh_display; LowLevelDisplay* display = refresh_display;
@@ -100,7 +100,7 @@ void core1_entry() {
// Clear flags // Clear flags
refresh_requested = false; refresh_requested = false;
refresh_in_progress = false; refresh_in_progress = false; // Unlock buffer for Core 0
} }
// Small delay to avoid busy-waiting // Small delay to avoid busy-waiting
@@ -124,6 +124,10 @@ bool refresh_screen_async(const uint8_t *buffer, LowLevelDisplay* display) {
return false; return false;
} }
// Lock the buffer immediately on Core 0 to prevent race condition
// Core 1 will unlock it (set to false) when done
refresh_in_progress = true;
// Queue refresh on Core 1 // Queue refresh on Core 1
refresh_buffer = buffer; refresh_buffer = buffer;
refresh_display = display; refresh_display = display;