Gtk-CRITICAL: gtk_widget_get_scale_factor failed - cc-switch
Quick fix
On a GTK assertion failure running cc-switch under Linux or WSL2, edit settings.json to turn silent startup off, or clean the leftovers and reinstall.
Symptom
Section titled “Symptom”(cc-switch:643): Gtk-CRITICAL **: 22:56:19.052: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failedThis error usually appears running the cc-switch GUI under Linux or WSL2. Compatibility problems between the WSL2 display server and GTK/WebKit window scaling mean querying the scale factor before the window is fully initialised — during a silent startup, for instance — trips the assertion. That leads to a frozen interface, dead window buttons, the main window never showing, or WebKit internal errors. Community solutions differ: some users resolved it by turning silent startup off, while others still hit the error with it already off and finally resolved it by cleaning out the leftover config and reinstalling, or by switching to the CLI.
Edit the cc-switch config file and make sure silent startup mode is off.
// ~/.cc-switch/settings.json (root 用户为 /root/.cc-switch/settings.json){"silentStartup": false}If it still errors after changing the config, uninstall cc-switch completely, clean out all leftover config files, and reinstall.
If the GUI keeps crashing and is unusable, use the command-line build cc-switch-cli for proxy and model management for now.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 3 real issues
- Why does the close button stop working when the window is not maximised?
- A known GTK window management compatibility problem under WSL2. Try maximising the window before clicking, or resolve it by changing the config and cleaning/reinstalling.
- I am the root user — where is the config file?
- The root user config file is at /root/.cc-switch/settings.json. Make sure "silentStartup" is set to false there.
- I get a WebKit internal error adding Codex OAuth authentication. What now?
- Also caused by abnormal WebKitGTK rendering under WSL2. Try turning silent startup off and cleaning/reinstalling first; if the auth window still will not open, configure it with cc-switch-cli for now.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.