From 84729d1c38e6bfb901267a21175eea6b9f67376d Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:59:11 +0000 Subject: [PATCH] gpui: Read thermal state from window handle (#49847) (cherry-pick to preview) (#49991) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick of #49847 to preview ---- Should close #49566 Inside `on_request_frame`, it’s conceptually incorrect to update the application directly. Instead, we should read the thermal state through the window handle, just like in the rest of the callback. That path uses `try_borrow_mut` internally, so if the application is already being updated elsewhere, we can safely skip checking the thermal state for that frame and retry on the next one. Before you mark this PR as ready for review, make sure that you have: - [ ] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - N/A Co-authored-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/gpui/src/window.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 8be96c418f49262db6a57b6ca5ad0f30424d36c9..55f8ee45a0ffb1bcdd400f1881716da58905616a 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -1185,9 +1185,12 @@ impl Window { let next_frame_callbacks = next_frame_callbacks.clone(); let input_rate_tracker = input_rate_tracker.clone(); move |request_frame_options| { - let thermal_state = cx.update(|cx| cx.thermal_state()); + let thermal_state = handle + .update(&mut cx, |_, _, cx| cx.thermal_state()) + .log_err(); - if thermal_state == ThermalState::Serious || thermal_state == ThermalState::Critical + if thermal_state == Some(ThermalState::Serious) + || thermal_state == Some(ThermalState::Critical) { let now = Instant::now(); let last_frame_time = last_frame_time.replace(Some(now));