Repository navigation
Description
Description
Problem: high CPU during active use
During active use (terminal output streaming, AI responses rendering, scrolling), the desktop app consumes an unreasonable amount of CPU.
Workaround:
launchctl setenv CHROME_HEADLESS 1 # applies to all GUI apps at login(or a per-app LaunchAgent wrapper setting the var only for OpenCode)
With the variable set, CPU usage under the same workload drops significantly (reproducible across relaunches). Idle CPU is ~0% in both states; the burn is usage-dependent.
Side effect of the workaround: CHROME_HEADLESS is read by Chromium's remote_cocoa layer as a bot workaround that force-disables window shadows for the whole process: components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm:
bool AreWindowShadowsDisabled() {
// ...disable window shadows when running on a bot
static bool is_headless = getenv("CHROME_HEADLESS") != nullptr;
return is_headless;
}
- (void)setHasShadow:(BOOL)flag {
[super setHasShadow:flag && !AreWindowShadowsDisabled()];
}Every OpenCode window loses its drop shadow (especially visible because the app uses titleBarStyle: "hidden" + trafficLightPosition on macOS), and it cannot be re-enabled from the Electron main process: win.setHasShadow(true) goes through the same swizzled setter and is clamped. Because launchctl setenv is login-wide, every other Chromium/Electron app the user runs also loses shadows.
Questions worth investigating upstream:
- What does
CHROME_HEADLESSactually change for an Electron renderer here? The only consumers in Chromium are: the macOS window-shadow bot workaround (see above),NativeWindowOcclusionTracker(Windows-only), and crash-reporter behaviour. The CPU improvement suggests occlusion/visibility tracking is involved, possibly the app's windows being marked occluded/throttled, or a vsync/occlusion-related compositor path differing when the var is set. - Is there a supported switch that achieves the same effect without the side effects? (e.g. an Electron flag or app setting controlling the same compositor/occlusion behaviour.)
Suggested fixes
- Fix the CPU issue directly so the env var isn't needed. Profiling the renderer during active use with/without the var would likely point at the culprit (occlusion-driven throttling vs. missing throttling, compositor scheduling, PTY output rendering, etc.).
- If the CPU issue can't be fixed soon, consider a supported opt-in (Electron command-line switch or app setting) that reproduces whatever
CHROME_HEADLESSchanges for CPU without the shadow/occlusion side effects. - Expose a way to restore shadows when the var is present, e.g. call through to the underlying
NativeWidgetMacNSWindowsuper implementation ofsetHasShadow:(bypassing the swizzle), or invoke thedisableHeadlessModepath Electron already has (ElectronNSWindow) at window-show time. - At minimum: document that
CHROME_HEADLESS=1disables all window shadows in every Chromium/Electron app, so users applying it as a CPU workaround understand the trade-off.
Notes for triage
- The app's
app.asarnever readsCHROME_HEADLESS; the reader is Chromium/Electron framework code (stringsonElectron Frameworkshows the symbol adjacent to theremote_cocoaheadless-window codenative_widget_mac_nswindow_headless.mmandscreen_mac_headless.mm). - Upstream context: https://crbug.com/899286 (window-server crashes with shadows + software compositing, the reason for the bot workaround) and https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/env_vars.h (
kHeadless = "CHROME_HEADLESS").
Plugins
No response
OpenCode version
1.18.29 (Electron 42.3.3)
Steps to reproduce
- Use the app under active load (terminal output streaming, AI responses rendering, scrolling) → CPU usage is unreasonably high.
launchctl setenv CHROME_HEADLESS 1(or a per-app LaunchAgent wrapper), relaunch → CPU drops significantly, but every window loses its drop shadow.launchctl unsetenv CHROME_HEADLESS, quit + relaunch → shadows are back, high CPU returns.
A/B tested across relaunches: shadow presence tracks the variable 100% of the time. Window nudges, re-ordering, and fullscreen toggles do not restore shadows.
Screenshot and/or share link
No response
Operating System
MacBook Pro (M1 Max), macOS 27.0 Beta (26A5421a)
Terminal
N/A (desktop app)
Activity
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊