Skip to content

gpui: Detect thermal state to help the system#45638

Merged
Anthony-Eid merged 18 commits intozed-industries:mainfrom
marcocondrache:feat/thermal-state
Feb 5, 2026
Merged

gpui: Detect thermal state to help the system#45638
Anthony-Eid merged 18 commits intozed-industries:mainfrom
marcocondrache:feat/thermal-state

Conversation

@marcocondrache
Copy link
Contributor

Apple recommends checking the system’s thermal state and adjusting behavior to reduce resource usage, giving the system a chance to cool down. While this API is macOS-specific, the same idea likely applies to other platforms - those are intentionally out of scope for this PR.

As a first step, we cap the frame rate at 60 fps when the system reports a critical thermal state. In that situation, pushing higher frame rates doesn’t buy us anything and just adds more heat. This also gives us a hook for future improvements, like reducing other work when the system is under sustained thermal pressure.

Ref: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html

Release Notes:

  • Zed now reduces resource usage when the system is under high thermal stress

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 24, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Dec 24, 2025
@marcocondrache marcocondrache marked this pull request as ready for review December 24, 2025 21:24
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
@Anthony-Eid Anthony-Eid enabled auto-merge (squash) February 5, 2026 10:44
@Anthony-Eid Anthony-Eid merged commit 7694ea2 into zed-industries:main Feb 5, 2026
43 of 45 checks passed
rtfeldman pushed a commit that referenced this pull request Feb 5, 2026
Apple recommends checking the system’s thermal state and adjusting
behavior to reduce resource usage, giving the system a chance to cool
down. While this API is macOS-specific, the same idea likely applies to
other platforms - those are intentionally out of scope for this PR.

As a first step, we cap the frame rate at 60 fps when the system reports
a critical thermal state. In that situation, pushing higher frame rates
doesn’t buy us anything and just adds more heat. This also gives us a
hook for future improvements, like reducing other work when the system
is under sustained thermal pressure.

Ref:
https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html

Release Notes:

- Zed now reduces resource usage when the system is under high thermal
stress

---------

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Co-authored-by: Anthony Eid <anthony@zed.dev>
@notpeter
Copy link
Contributor

notpeter commented Feb 12, 2026

I've been seeing frequent crashes on my Macbook Pro (2019 Intel) referencing code introduced in this PR: crates/gpui/src/app.rs:749:39

zed/crates/gpui/src/app.rs

Lines 745 to 756 in d453d95

platform.on_thermal_state_change(Box::new({
let app = Rc::downgrade(&app);
move || {
if let Some(app) = app.upgrade() {
let cx = &mut app.borrow_mut();
cx.thermal_state_observers
.clone()
.retain(&(), move |callback| (callback)(cx));
}
}
}));

2026-02-12T14:31:21-05:00 ERROR [crashes] thread '<unnamed>' panicked at crates/gpui/src/app.rs:749:39:
RefCell already borrowed...
2026-02-12T14:31:21-05:00 ERROR [crashes] triggering a crash to generate a minidump...

2026-02-12T14:44:45-05:00 ERROR [crashes] thread '<unnamed>' panicked at crates/gpui/src/app.rs:749:39:
RefCell already borrowed...
2026-02-12T14:44:45-05:00 ERROR [crashes] triggering a crash to generate a minidump...

2026-02-12T14:54:40-05:00 ERROR [crashes] thread '<unnamed>' panicked at crates/gpui/src/app.rs:749:39:
RefCell already borrowed...
2026-02-12T14:54:40-05:00 ERROR [crashes] triggering a crash to generate a minidump...

I first saw it on Friday less than a day after this was merged.
I switched to Zed Preview 0.223.x but when Preview was cut yesterday it started failing there too.

It makes Zed Preview/Nightly unusable on my Mac Intel machine.
I'm using Stable v0.223.x as a workaround.

Zed: v0.225.0+nightly.2178.ceec6ee5f52b9c0dde5d30616b15cea2316d4857 (Zed Nightly ceec6ee5f52b9c0dde5d30616b15cea2316d4857) 
OS: macOS 26.3
Memory: 64 GiB
Architecture: x86_64

Zed: v0.224.0+preview.150.64161d2d578b8c9d3bb01161d04e41c0b8dc8ddb (Zed Preview) 
OS: macOS 26.3
Memory: 64 GiB
Architecture: x86_64

I updated to macOS 26.3 yesterday, but saw it with 26.2 too.

@marcocondrache
Copy link
Contributor Author

@notpeter thank you so much for all the infos and sorry for the trouble. I believe I’ve identified the issue and have opened a PR

bennetbo pushed a commit that referenced this pull request Feb 16, 2026
Fixes
#45638 (comment)
Closes #49005

The issue was similar to the one we already had with the quit method
https://github.com/zed-industries/zed/blob/8249ef56187b966c33f6667d0d3a35d88d8f2dc0/crates/gpui/src/platform/mac/platform.rs#L491

@notpeter Could you please test this branch to confirm it resolves the
issue?

- [ ] Tests or screenshots needed?
- [x] Code Reviewed
- [ ] Manual QA

Release Notes:

- Fixed an issue where Zed would randomly crash on macOS intel
github-actions bot pushed a commit that referenced this pull request Feb 16, 2026
Fixes
#45638 (comment)
Closes #49005

The issue was similar to the one we already had with the quit method
https://github.com/zed-industries/zed/blob/8249ef56187b966c33f6667d0d3a35d88d8f2dc0/crates/gpui/src/platform/mac/platform.rs#L491

@notpeter Could you please test this branch to confirm it resolves the
issue?

- [ ] Tests or screenshots needed?
- [x] Code Reviewed
- [ ] Manual QA

Release Notes:

- Fixed an issue where Zed would randomly crash on macOS intel
zed-zippy bot added a commit that referenced this pull request Feb 16, 2026
…-pick to preview) (#49248)

Cherry-pick of #49086 to preview

----
Fixes
#45638 (comment)
Closes #49005

The issue was similar to the one we already had with the quit method

https://github.com/zed-industries/zed/blob/8249ef56187b966c33f6667d0d3a35d88d8f2dc0/crates/gpui/src/platform/mac/platform.rs#L491

@notpeter Could you please test this branch to confirm it resolves the
issue?

- [ ] Tests or screenshots needed?
- [x] Code Reviewed
- [ ] Manual QA

Release Notes:

- Fixed an issue where Zed would randomly crash on macOS intel

Co-authored-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
naaiyy added a commit to Glass-HQ/Glass that referenced this pull request Feb 16, 2026
Key changes:
- Thermal state detection (zed-industries#45638) - GPUI detects system thermal state, throttles to ~60fps when overheating
- Checkerboard shader for side-by-side diff (zed-industries#48417) - visual pattern for diff backgrounds
- cosmic-text v0.17 (zed-industries#48504) - fixes font ligatures on Linux
- Middle click tab close (zed-industries#44916) - on_aux_click/is_middle_click API additions
- Soft wrap modes for wrap width (zed-industries#46422)
- Tab switcher mode similar to vim/helix buffer picker (zed-industries#47079)
- Multi_buffer optimization batch (zed-industries#48519)
- TreeMap for diagnostics (zed-industries#48482) - performance improvement
- Semantic token follow-up fixes (zed-industries#48485)
- Claude Opus 4.6 and 1M context window model variants (zed-industries#48508)
- Anthropic adaptive thinking types (zed-industries#48517)
- Side-by-side diff: hunk gutter highlights restored, toolbar buttons for SplittableEditor
- Shell quote bypass fix in terminal permission system (zed-industries#48436)
- Project panel: Collapse All improvements (zed-industries#47328, zed-industries#48443)
- Edit prediction: trailing newlines fix, cursor position in global coords
- Properly discard tokens on language server stop (zed-industries#48490)
- AgentTool::NAME const instead of hardcoded strings (zed-industries#48506)

Conflict resolution:
- collab/editor_tests.rs: deleted (collab removed)
- vim (helix, motion, increment): deleted (vim removed)
- GPUI (17 files): deleted from Glass (handled in Obsydian-HQ/gpui)
- editor/items.rs: merged imports (added BufferId, kept Theme)
- project_diff.rs: removed old native_button toggle (upstream uses toolbar buttons now)
- lsp_store.rs: added SemanticTokenConfig, removed GlobalLogStore/LanguageServerKind
- project_panel.rs: merged UI imports (added ContextMenuEntry, ScrollAxes)
- Keymaps: took upstream JetBrains bindings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rtfeldman pushed a commit that referenced this pull request Feb 17, 2026
Fixes
#45638 (comment)
Closes #49005

The issue was similar to the one we already had with the quit method
https://github.com/zed-industries/zed/blob/8249ef56187b966c33f6667d0d3a35d88d8f2dc0/crates/gpui/src/platform/mac/platform.rs#L491

@notpeter Could you please test this branch to confirm it resolves the
issue?

- [ ] Tests or screenshots needed?
- [x] Code Reviewed
- [ ] Manual QA

Release Notes:

- Fixed an issue where Zed would randomly crash on macOS intel
@github-actions github-actions bot mentioned this pull request Feb 17, 2026
8 tasks
Caio-Ze pushed a commit to Caio-Ze/postprod-ide that referenced this pull request Feb 21, 2026
…49086)

Fixes
zed-industries#45638 (comment)
Closes zed-industries#49005

The issue was similar to the one we already had with the quit method
https://github.com/zed-industries/zed/blob/8249ef56187b966c33f6667d0d3a35d88d8f2dc0/crates/gpui/src/platform/mac/platform.rs#L491

@notpeter Could you please test this branch to confirm it resolves the
issue?

- [ ] Tests or screenshots needed?
- [x] Code Reviewed
- [ ] Manual QA

Release Notes:

- Fixed an issue where Zed would randomly crash on macOS intel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants