After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696340 - wayland: device list is populated async
wayland: device list is populated async
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-03-21 22:22 UTC by Matthias Clasen
Modified: 2013-04-04 20:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
roundtrip until we've received all initial state (5.83 KB, patch)
2013-03-26 18:49 UTC, Kristian Høgsberg
none Details | Review
move init roundtrip accounting out of regular event handlers (5.17 KB, patch)
2013-03-27 17:39 UTC, Kristian Høgsberg
none Details | Review

Description Matthias Clasen 2013-03-21 22:22:29 UTC
This is a subtle incompatibility to the X backend. In our application tests, I've noticed quite a few criticals stemming from the fact that widget setup code that is running before entering the mainloop ends up accessing devices, e.g the core_pointer. In X that works, you can get the devices as soon as the display is opened. In wayland, the list of devices in the devicemanager is empty until you enter the mainloop.
Comment 1 Kristian Høgsberg 2013-03-26 18:49:18 UTC
Created attachment 239889 [details] [review]
roundtrip until we've received all initial state

I understand the problem and I've attached a suggested fix, but I'm not sure how to reproduce.  The idea in the patch is pretty simple, we spin in wl_display_roundtrip() until all parts of the initialization have received their initial state.  To track whether some part of the init process is still waiting, we use init_ref_count in GdkWaylandDisplay.
Comment 2 Kristian Høgsberg 2013-03-26 19:08:09 UTC
Pushed as:

commit a9e980e578adea65be0c97e398f0e59eb6338ac7
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Mar 26 14:42:14 2013 -0400

    wayland: Roundtrip until we've receive initial input and output configuratio
    
    We use a ref-count mechanism to track whether parts of the init sequence
    still needs round trips to receive remaining initial state.  Typically
    we need a couple of roundtrips total to get the global list, then the
    input and output configurations, but with the ref-count we avoid making
    global assumptions like that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696340
Comment 3 Rob Bradford 2013-03-27 10:20:37 UTC
I really like the methodology here, it's nicer than spinning until a wide set of invariants are set e.g. have a seat, have an output etc.

But this will break if we don't get a seat or if we don't have an output. Does wayland mandate that you are guaranteed at least one seat and at least one output? I know weston has a hardcoded single seat right now... :-)
Comment 4 Kristian Høgsberg 2013-03-27 17:20:06 UTC
(In reply to comment #3)
> I really like the methodology here, it's nicer than spinning until a wide set
> of invariants are set e.g. have a seat, have an output etc.
> 
> But this will break if we don't get a seat or if we don't have an output. Does
> wayland mandate that you are guaranteed at least one seat and at least one
> output? I know weston has a hardcoded single seat right now... :-)

We only increment the roundtrip refcount we set a bind request for a wl_output or a wl_seat.  So if we don't bind to any seats or outputs we won't wait for them to send events.
Comment 5 Kristian Høgsberg 2013-03-27 17:39:38 UTC
Created attachment 239978 [details] [review]
move init roundtrip accounting out of regular event handlers

Here's a somewhat cleaner approach, that doesn't rely on the regular event handles to maintain the init ref count.
Comment 6 Matthias Clasen 2013-04-04 20:03:33 UTC
sure, lets close this