Files
ghostty/src
Mitchell Hashimoto 36f841ee80 apprt/gtk: make GL context current in unrealize
Fixes #6872

This commit explicitly acquires the GL context in the `unrealize`
signal handler of the GTK Surface prior to cleaning up GPU resources.

A GLArea only guarantees that the associated GdkContext is current for
the `render` signal (see the docs[1]). This is why our OpenGL renderer
"defers" various operations such as resize, font grid changing, etc.
(see the `deferred_`-prefix fields in `renderer/OpenGL.zig`).
However, we missed a spot.

The `gtk-widget::unrealize` signal is emitted when the widget is
destroyed, and it is the last chance we have to clean up our GPU
resources. But it is not guaranteed that the GL context is current at
that point, and we weren't making it current. On the NGL GTK renderer,
this was freeing GPU resources we didn't own.

As best I can understand, the old GL renderer only ever used a handful
of GL resources that were early in the ID space, so by coincidence we
were probably freeing nothing and everything was fine. But with the new
NGL renderer uses a LOT more GL resources (make a few splits and the ID
space is already in the thousands, from GTK!), so we were freeing real
resources that we didn't own, which caused rendering issues. :)

I suspect the above also resulted in VRAM memory leaks (which would be
RAM memory leaks for unified memory GPUs). This potentially relates to
#5491.

The fix is to explicitly make the GL context current in the `unrealize`
handler.

[1]: https://docs.gtk.org/gtk4/method.GLArea.make_current.html
2025-03-22 14:20:01 -07:00
..
2024-03-26 16:14:25 -07:00
2025-03-18 13:58:49 -07:00
2025-03-12 09:55:52 -07:00
2025-03-12 10:04:17 -07:00
2025-03-12 10:15:14 -07:00
2025-03-18 13:58:49 -07:00
2025-01-18 22:47:18 +09:00
2025-03-18 13:58:49 -07:00
2025-03-12 10:04:17 -07:00
2025-03-12 09:55:52 -07:00
2025-02-11 16:43:50 -08:00
2024-09-26 22:00:11 -07:00
2025-03-11 14:39:04 -07:00
2024-10-18 08:11:11 -07:00
2025-03-12 16:29:17 -07:00
2025-03-12 10:04:17 -07:00
2025-03-12 09:55:52 -07:00
2025-03-11 14:53:30 -07:00
2025-03-07 13:42:00 -08:00
2024-08-16 14:35:10 -07:00
2022-08-18 11:42:32 -07:00
2025-03-12 16:29:17 -07:00
2025-03-12 11:29:13 -07:00
2025-03-12 09:55:52 -07:00
2024-08-16 10:36:10 -07:00