For over a decade, the Factor programming language has relied on GTK2 for rendering its Linux user interface through OpenGL – an increasingly problematic dependency given GTK2's end-of-life status since 2020. The aging stack utilized X11 and libgtkglext for OpenGL integration, creating compatibility hurdles as Linux distributions shifted to Wayland-based environments and modern GTK3/GTK4 toolkits.

Article illustration 1

"Does that message mean that Factor still relies on GTK2? IIRC it was EOL:ed around 2020."

This user question served as the catalyst for action, prompting Factor maintainers to confront technical debt accumulated in the UI stack.

The migration required two significant architectural changes: First, replacing GTK2 with GTK3 via a community-contributed pull request extended to maintain GTK3 compatibility. Second, and more substantially, overhauling OpenGL rendering pipelines from version 1.x to 3.x – a necessity because GTK3+ environments no longer support the legacy OpenGL approach.

-        { [ os unix? ] [ "ui.backend.gtk2" ] }
+        { [ os unix? ] [ "ui.backend.gtk3" ] }

Code snippet showing the backend switch in Factor's bootstrap configuration

Initial nightly builds reveal performance regressions, particularly noticeable as rendering lag during scrolling operations. Maintainers speculate this stems from differences in caching behavior between OpenGL 1.x and 3.x pipelines. As a stopgap, users can revert to the GTK2 backend by modifying the bootstrap configuration, though this is positioned as a temporary solution.

The OpenGL 3.x rendering pipeline has simultaneously been implemented for Factor's macOS backend, enabling cross-platform stress testing of the new graphics infrastructure. While the GTK3 migration marks significant progress in modernizing Factor's Linux compatibility, optimization work continues to achieve parity with the older implementation's performance characteristics.

Source: Factor Language Blog