GNOME Bugzilla – Bug 696340
wayland: device list is populated async
Last modified: 2013-04-04 20:03:33 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.
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.
Author: Kristian Høgsberg <email@example.com>
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.
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... :-)
(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.
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.
sure, lets close this