Skip to content

fix(desktop): raise Chromium WebGL context cap to 256#3834

Merged
Kitenite merged 2 commits into
mainfrom
debug-webgl-terminal-v2
Apr 28, 2026
Merged

fix(desktop): raise Chromium WebGL context cap to 256#3834
Kitenite merged 2 commits into
mainfrom
debug-webgl-terminal-v2

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 28, 2026

Chromium defaults max-active-webgl-contexts to 16 per renderer process. Each xterm holds one WebGL context, and the v2 parking model keeps panes alive across workspace switches, so cumulative panes routinely reach the low hundreds. Once over the cap, Blink forcibly fires webglcontextlost on the oldest pane, producing the blank/garbled terminals in #3572, #3504, #3527.

Raising to 256 covers low-hundreds of cumulative panes while staying bounded enough to surface a real leak. Does not address upstream xterm.js texture-atlas bugs (xtermjs/xterm.js#5849), which manifest as similar corruption but require a different fix.

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Summary by cubic

Raise Chromium’s active WebGL context limit from 16 to 256 to stop terminals from blanking when many panes persist across workspace switches. Adds the max-active-webgl-contexts command-line switch so older contexts aren’t evicted under load.

Written for commit bc55d17. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Chores
    • Enhanced WebGL context handling to improve stability and performance when using terminal panes across multiple workspaces.

Chromium defaults `max-active-webgl-contexts` to 16 per renderer process.
Each xterm holds one WebGL context, and the v2 parking model keeps panes
alive across workspace switches, so cumulative panes routinely reach the
low hundreds. Once over the cap, Blink forcibly fires `webglcontextlost`
on the oldest pane, producing the blank/garbled terminals in #3572, #3504,
#3527.

Raising to 256 covers low-hundreds of cumulative panes while staying
bounded enough to surface a real leak. Does not address upstream xterm.js
texture-atlas bugs (xtermjs/xterm.js#5849), which manifest as similar
corruption but require a different fix.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 098f2dd9-e40b-4217-ba0c-c0fc1ae47539

📥 Commits

Reviewing files that changed from the base of the PR and between 89285e4 and bc55d17.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/electron-app/factories/app/setup.ts

📝 Walkthrough

Walkthrough

A Chromium command-line switch max-active-webgl-contexts is configured with a value of 256 during Electron app initialization to increase the maximum number of retained WebGL contexts across workspace operations.

Changes

Cohort / File(s) Summary
WebGL Context Configuration
apps/desktop/src/lib/electron-app/factories/app/setup.ts
Added max-active-webgl-contexts Chromium command-line switch set to 256 to allow more concurrent WebGL contexts in terminal panes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A whisker twitch, a config line,
WebGL contexts now align!
Two hundred fifty-six gleam bright,
Terminal panes shine with light!
GPU memory takes its flight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: raising Chromium's WebGL context cap to 256, which directly corresponds to the code modification in the pull request.
Description check ✅ Passed The description is mostly complete with detailed rationale and context about the issue, but the template sections (Related Issues, Type of Change, Testing) are not filled in beyond the template placeholders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch debug-webgl-terminal-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Drop issue references (belong in PR description) and Chromium source path
(rots if files move). Keep the WHY: parking holds contexts, default 16 is
too low at hundreds of cumulative panes, 256 is bounded enough to surface
leaks.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR raises Chromium's max-active-webgl-contexts switch from the default 16 to 256 in the Electron app setup, fixing blank/garbled terminal panes caused by webglcontextlost events when the v2 parking model accumulates more than 16 live xterm WebGL contexts across workspace switches.

The fix is well-scoped and thoroughly documented. One minor observation: the switch is applied unconditionally on all platforms, including Linux where app.disableHardwareAcceleration() already disables WebGL — the switch is harmless there but has no effect.

Confidence Score: 5/5

Safe to merge — targeted one-liner fix with excellent rationale, no logic or security concerns.

The change is a single well-justified Chromium command-line switch addition. All findings are P2 or lower (Linux no-op is harmless). No data-integrity, security, or correctness issues are present.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/lib/electron-app/factories/app/setup.ts Adds max-active-webgl-contexts Chromium switch set to 256, raising the cap from the default 16 to prevent forced webglcontextlost events on xterm panes; change is unconditional across all platforms including Linux where hardware acceleration is already disabled.

Sequence Diagram

sequenceDiagram
    participant App as Electron App (startup)
    participant Chromium as Chromium Renderer Process
    participant xterm as xterm.js pane (WebGL)

    App->>Chromium: appendSwitch("max-active-webgl-contexts", "256")
    note over Chromium: cap raised from 16 → 256

    loop Each new pane opened / workspace switch
        xterm->>Chromium: request WebGL context
        Chromium-->>xterm: context granted (v2 parking keeps alive)
    end

    note over Chromium,xterm: Before fix: >16 contexts → ForciblyLoseOldestContext → webglcontextlost → blank terminal
    note over Chromium,xterm: After fix: up to 256 contexts before eviction kicks in
Loading

Reviews (1): Last reviewed commit: "deslop: trim WebGL cap-raise comment" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@Kitenite Kitenite merged commit a8e8556 into main Apr 28, 2026
7 checks passed
@Kitenite Kitenite deleted the debug-webgl-terminal-v2 branch April 28, 2026 18:30
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch

Thank you for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant