GNOME Bugzilla – Bug 753185
gdk_device_get_source: assertion 'GDK_IS_DEVICE (device)' failed
Last modified: 2015-08-19 20:15:54 UTC
On wayland we may destroy the "master" pointer/keyboard devices right when we receive a wl_seat.capability event, despite the events that might be queued for these at that time. This is visible on tty switch, mutter will first send the key release for the ctrl/alt modifiers, gtk+ queues these events, but destroys the devices immediately after. The focused window will then spawn several: Gdk-CRITICAL **: gdk_device_get_source: assertion 'GDK_IS_DEVICE (device)' failed Triggered when the GtkGesture generic event handling code receives the event. This didn't use to trigger on X11 because VCP/VCK are not removed, only the slave devices are, although if we had performed any checks on the source devices, we would surely have received warnings as well. I'm attaching a patch that makes the private device/source_device event fields refcounted, so the events at least contain valid GdkDevices when processed.
Created attachment 308683 [details] [review] gdkevent: Hold refs to device/source_device The extra reference will be held from GdkEventPrivate data, so there's a common place to all events. Without this, events queued after devices/ capabilities disappear (eg. on TTY switch) might hold invalid pointers. Windowing level operations on those devices (queries, grabs...) are expected to fail at that time, but we should hold meaningful data for the regular event handling paths.
Not holding on to pointers that point to finalized objects seems good, of course. But can we recognize the 'deceased' status of the devices somehow ? Is there a GdkDevice api for that ?
Review of attachment 308683 [details] [review]: setting review status according to the previous comment
(In reply to Matthias Clasen from comment #2) > Not holding on to pointers that point to finalized objects seems good, of > course. But can we recognize the 'deceased' status of the devices somehow ? > Is there a GdkDevice api for that ? Hmm, right, there's actually nothing to let users know. On X11 I'd count on BadDevice to be received on any device operation, and GTK+ to bail out of there, on wayland this post-removal behavior is a bit more naive though. What AFAIR we would be emitting is grab broken events if there is one at the time of the removal, and I wouldn't expect that button/key releases will trigger grabs or device state queries too often, We should stress test device operations around removals nonetheless.
Attachment 308683 [details] pushed as 25557c1 - gdkevent: Hold refs to device/source_device