gpui: Defer thermal/keyboard state updates when app is borrowed#49189
Merged
morgankrey merged 2 commits intomainfrom Feb 14, 2026
Merged
gpui: Defer thermal/keyboard state updates when app is borrowed#49189morgankrey merged 2 commits intomainfrom
morgankrey merged 2 commits intomainfrom
Conversation
Follow-up to #49187. Always spawn the update on the foreground executor instead of borrowing the app directly in the callback. This avoids RefCell panics when macOS fires these callbacks asynchronously while the app is already borrowed. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
ace1b32 to
c27dc9f
Compare
Adds a non-exhaustive rules file for the GPUI crate, starting with the platform callback pattern: defer work via ForegroundExecutor rather than borrowing AppCell directly, since macOS can fire these callbacks asynchronously while the app is already borrowed. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Contributor
This comment was marked as outdated.
This comment was marked as outdated.
3 tasks
Contributor
|
@notpeter thank you so much. Yes we need somebody to cherry pick this to the preview channel! |
Contributor
|
Update: new crash for the code which was introduced in this PR. Lines 757 to 762 in 99a558f |
3 tasks
Member
|
/cherry-pick preview |
Member
|
/cherry-pick stable |
Contributor
|
🍒💥 Cherry-pick did not succeed |
Contributor
|
🍒💥 Cherry-pick did not succeed |
marcocondrache
added a commit
to marcocondrache/zed
that referenced
this pull request
Feb 16, 2026
…ed (zed-industries#49189)" This reverts commit 99a558f.
bennetbo
pushed a commit
that referenced
this pull request
Feb 16, 2026
…ed" (#49251) Reverts #49189 Reverts #49187 #49189 introduces a panic (#49189 (comment), #49181 (comment)) #49187 It's wrong since it leads to missing updates The original crash should be fixed with #49086 cc: @bennetbo Release Notes: - N/A
rtfeldman
pushed a commit
that referenced
this pull request
Feb 17, 2026
Follow-up to #49187. Instead of silently skipping updates when `try_borrow_mut` fails, this PR defers the update by spawning it on the foreground executor. This ensures the state change is eventually processed after the current borrow completes. Release Notes: - N/A
rtfeldman
pushed a commit
that referenced
this pull request
Feb 17, 2026
…ed" (#49251) Reverts #49189 Reverts #49187 #49189 introduces a panic (#49189 (comment), #49181 (comment)) #49187 It's wrong since it leads to missing updates The original crash should be fixed with #49086 cc: @bennetbo Release Notes: - N/A
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.
Follow-up to #49187.
Instead of silently skipping updates when
try_borrow_mutfails, this PR defers the update by spawning it on the foreground executor. This ensures the state change is eventually processed after the current borrow completes.This addresses the feedback: "if we pull something out of the event queue asynchronously and the state we want to update is unavailable, either we should put it back in the queue or if that doesn't work, retry in a loop."
Release Notes: