wlc: gtk3 applications crash when trying to open a GtkMenu

So after first submitting this issue on sway, I have tried and succeeded in reproducing it with orbment: When I open a menu in a gtk3 application (e.g. right click in a text view, pressing the hamburger button in Epiphany), the application terminates. This only happens with GtkMenus, not with the more recently added GtkPopovers. When using the gtk3 package from the official arch repositories, these crashes look like this:

(gedit:10785): Gdk-ERROR **: Error flushing display: Broken pipe
[1]    10785 trace trap (core dumped)  LC_ALL=C gedit

Weirdly, when using gtk3 with the typeahead patch (gtk3-typeahead in AUR) I don’t get a core dump, and the error message looks different:

# LANG=en_US.utf8
Gdk-WARNING **: Lost connection to Wayland compositor.

# LANG=de_DE.utf8
Gdk-WARNING **: Error 71 (Protokollfehler) dispatching to Wayland display.

I’m about to rebuild the official gtk3 package with debug symbols to hopefully obtain a stack trace.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 43 (35 by maintainers)

Commits related to this issue

Most upvoted comments

Here. With above, GTK menus are shown without crashing and compositor can display them correctly positioned.

@Drakulix Will get on this bit later today. I need to remind myself on the positioner details before I can answer well.

@Cloudef Because this issue is really annoying me in my daily use, I would like to try to tackle it.

I browsed through the source code and got some questions:

  • How would you like to see the positioner getting exposed by the api? It seems like it should almost be a new handle type. Alternatively don’t expose it and just respect it’s settings in the set_geometry call or stub it so it does not crash anymore.
  • Would the positioner be a new resource in src/resources/types? How would I allocate it in the create_positioner call? Looking at the rest of the code, I just use wlc_resource_create and wlc_resource_implement, right? Implementing it then seems pretty straight-forward.
  • Anything I am missing?

Views already have parent / child relationship, do the popups really need own?

Nope, I was not aware of that.

//edit: Anyway, that only means that last commit is not needed, just using view_get_parent works. I can tidy rest up and make PR.

Here’s the gdk_event_soure_prepare function from my local version of the source, with the line of the error message marked:

  static gboolean
  gdk_event_source_prepare (GSource *base,
                            gint    *timeout)
  {
    GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
    GdkWaylandDisplay *display = (GdkWaylandDisplay *) source->display;

    *timeout = -1;

    if (source->display->event_pause_count > 0)
      return _gdk_event_queue_find_first (source->display) != NULL;

    /* We have to add/remove the GPollFD if we want to update our
     * poll event mask dynamically.  Instead, let's just flush all
     * write on idle instead, which is what this amounts to.
     */

    if (_gdk_event_queue_find_first (source->display) != NULL)
      return TRUE;

    /* wl_display_prepare_read() needs to be balanced with either
     * wl_display_read_events() or wl_display_cancel_read()
     * (in gdk_event_source_check() */
    if (source->reading)
      return FALSE;

    /* if prepare_read() returns non-zero, there are events to be dispatched */
    if (wl_display_prepare_read (display->wl_display) != 0)
      return TRUE;
    source->reading = TRUE;

    if (wl_display_flush (display->wl_display) < 0)
*     g_error ("Error flushing display: %s", g_strerror (errno));

    return FALSE;
  }