Re: Gtk::GLArea throws "Couldn't find current GLX or EGL context.\n"' on unrealizing

Gerlof Fokkema via gtkmm-list <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CAAk3=usMT8sLr-uwtESHjFCN=EaYp-57rAUYaTMwqeyoRS9g=A@mail.gmail.com>
Dear list,

I did some more digging and found that there is no context associated
to Gtk::GLArea anymore when signal_unrealize is triggered.
I assume that somewhere between calling the Gtk::GLArea destructor and
signal_unrealize the GL context is already unset:

https://gist.github.com/gfokkema/a0c73de5c9df476b5b31057ebb63394f/revisions
> ┌─gerlof@gerlof-laptop ~/workspace/build-gtk-renderer-Desktop-Debug $
> └─╼./example
> Realize context: 0x55ed5dfa7590
> Destructor context: 0x55ed5dfa7590
> Unrealize context: (nil)
> example: ../libepoxy/src/dispatch_common.c:863: epoxy_get_proc_address: Assertion `0 && "Couldn't find current GLX or EGL context.\n"' failed.
> Aborted (core dumped)

After setting breakpoints in `gtk_gl_area_dispose` and
`gtk_gl_area_unrealize`, this makes sense:

First gtk_gl_area_dispose is called, which clears the context:
https://gitlab.gnome.org/GNOME/gtk/blob/3.24.13/gtk/gtkglarea.c#L200
1 gtk_gl_area_dispose
gtkglarea.c  200 0x7ffff716d628
2 g_object_run_dispose
                0x7ffff68a471a
3 Gtk::Object::_release_c_instance()
                0x7ffff7cc69e9
4 Gtk::GLArea::~GLArea()
                0x7ffff7c1fbad
5 Example::~Example
example.cpp  65  0x555555560dbc
6 Example::~Example
example.cpp  71  0x555555560e38
7 std::default_delete<Example>::operator()
unique_ptr.h 81  0x555555561d38
8 std::unique_ptr<Example, std::default_delete<Example>>::~unique_ptr
unique_ptr.h 284 0x555555561a9c
9 main
example.cpp  127 0x5555555614af

And then afterwards, gtk_gl_area_unrealize is called, which clears the
context again?
https://gitlab.gnome.org/GNOME/gtk/blob/3.24.13/gtk/gtkglarea.c#L593
1  gtk_gl_area_unrealize
        gtkglarea.c    580   0x7ffff7175721
2  g_closure_invoke
        gclosure.c     810   0x7ffff68a2d5a
3  signal_emit_unlocked_R
        gsignal.c      3679  0x7ffff688fff8
4  g_signal_emit_valist
        gsignal.c      3397  0x7ffff689498a
5  g_signal_emit
        gsignal.c      3453  0x7ffff68957f0
6  gtk_widget_unrealize
        gtkwidget.c    5578  0x7ffff6fea3b6
7  gtk_widget_unparent
        gtkwidget.c    4670  0x7ffff6feae66
8  gtk_bin_remove
        gtkbin.c       151   0x7ffff725043a
9  Gtk::Container_Class::remove_callback_normal(_GtkContainer *,
_GtkWidget *)                      0x7ffff7bff3ee
10 g_cclosure_marshal_VOID__OBJECTv
        gmarshal.c     1910  0x7ffff68a47d0
11 _g_closure_invoke_va
        gclosure.c     873   0x7ffff6894b4a
12 g_signal_emit_valist
        gsignal.c      3306  0x7ffff6894b4a
13 g_signal_emit
        gsignal.c      3453  0x7ffff68957f0
14 gtk_container_remove
        gtkcontainer.c 1906  0x7ffff7201f9a
15 gtk_widget_dispose
        gtkwidget.c    12151 0x7ffff6fe1275
16 g_object_run_dispose
        gobject.c      1130  0x7ffff68a471a
17 Gtk::Object::_release_c_instance()
                             0x7ffff7cc69e9
18 Gtk::GLArea::~GLArea()
                             0x7ffff7c1fbad
19 Example::~Example
        example.cpp    65    0x555555560dbc
20 Example::~Example
        example.cpp    71    0x555555560e38
21 std::default_delete<Example>::operator()
        unique_ptr.h   81    0x555555561d38
22 std::unique_ptr<Example, std::default_delete<Example>>::~unique_ptr
        unique_ptr.h   284   0x555555561a9c
23 main
        example.cpp    127   0x5555555614af

Something doesn't seem right in the order of disposal of GtkGLArea.

Regards,
Gerlof Fokkema
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.