DND Wayland: premature termination because of gtk_get_drag_data() causing entire Xwayland hangs up
Hi,
the story is beginning here nautilus-dnd-issue-under-wayland. Please read to see what I am talking about (also there is all necessary stuffing to reproduce).
So tracking it I did the following: removed all a calls to gtk_get_drag_data()
, leaving the only one. Removed all related to drag-data-received
signal to exclude their possible influence to the behaviour. Limited the number a calls to gtk_drag_get_data()
to be a single call only or no calls at all.
debugging.patch
diff -aur '--exclude=.git' '--exclude=meson_options.txt' a/nautilus/src/nautilus-canvas-dnd.c b/nautilus/src/nautilus-canvas-dnd.c
--- a/nautilus/src/nautilus-canvas-dnd.c 2019-01-18 00:14:05.836665849 +0000
+++ b/nautilus/src/nautilus-canvas-dnd.c 2019-01-18 00:15:39.716665838 +0000
@@ -557,8 +557,17 @@
{
set_direct_save_uri (widget, context, drag_info, x, y);
}
+if (1)
+{
+ static int once = 0;
+ if (++once == 1) // calling it even once is enough for unexpected dnd termination
+ {
+ g_print ("nau-dnd-getting-data-begins\n");
gtk_drag_get_data (GTK_WIDGET (widget), context,
target, time);
+ g_print ("nau-dnd-getting-data-finished\n");
+ }
+}
}
}
}
@@ -1522,6 +1531,9 @@
guint32 time)
{
int action;
+ static int data_get_delay_sim = 0;
+
+ ++data_get_delay_sim;
nautilus_canvas_container_ensure_drag_data (NAUTILUS_CANVAS_CONTAINER (widget), context, time);
nautilus_canvas_container_position_shadow (NAUTILUS_CANVAS_CONTAINER (widget), x, y);
@@ -1547,6 +1559,10 @@
remove_hover_timer (NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info);
}
+ if (data_get_delay_sim >= 5)
+ {
+ action = GDK_ACTION_COPY;
+ }
gdk_drag_status (context, action, time);
return TRUE;
@@ -1562,6 +1578,7 @@
{
NautilusCanvasDndInfo *dnd_info;
+g_print ("nau-drop-sensor: dropped\n");
dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info;
/* tell the drag_data_received callback that
@@ -1737,10 +1754,6 @@
selection_length == 1 &&
selection_data[0] == 'F')
{
- gtk_drag_get_data (widget, context,
- gdk_atom_intern (NAUTILUS_ICON_DND_RAW_TYPE,
- FALSE),
- time);
return;
}
else if (selection_format == 8 &&
@@ -1791,6 +1804,7 @@
*/
n_elements = G_N_ELEMENTS (drop_types) - 1;
gtk_drag_dest_set (GTK_WIDGET (container),
+ //GTK_DEST_DEFAULT_MOTION,
0,
drop_types, n_elements,
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
@@ -1808,8 +1822,6 @@
G_CALLBACK (drag_end_callback), NULL);
/* Messages for incoming drag. */
- g_signal_connect (container, "drag-data-received",
- G_CALLBACK (drag_data_received_callback), NULL);
g_signal_connect (container, "drag-motion",
G_CALLBACK (drag_motion_callback), NULL);
g_signal_connect (container, "drag-drop",
diff -aur '--exclude=.git' '--exclude=meson_options.txt' a/nautilus/src/nautilus-location-entry.c b/nautilus/src/nautilus-location-entry.c
--- a/nautilus/src/nautilus-location-entry.c 2019-01-18 00:14:05.836665849 +0000
+++ b/nautilus/src/nautilus-location-entry.c 2019-01-18 00:13:52.173332518 +0000
@@ -885,8 +885,6 @@
GTK_DEST_DEFAULT_ALL,
drop_types, G_N_ELEMENTS (drop_types),
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
- g_signal_connect (entry, "drag-data-received",
- G_CALLBACK (drag_data_received_callback), NULL);
g_signal_connect_object (entry, "activate",
G_CALLBACK (editable_activate_callback), entry, G_CONNECT_AFTER);
diff -aur '--exclude=.git' '--exclude=meson_options.txt' a/nautilus/src/nautilus-properties-window.c b/nautilus/src/nautilus-properties-window.c
--- a/nautilus/src/nautilus-properties-window.c 2019-01-18 00:14:05.836665849 +0000
+++ b/nautilus/src/nautilus-properties-window.c 2019-01-18 00:13:52.173332518 +0000
@@ -543,8 +543,6 @@
target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
- g_signal_connect (image, "drag-data-received",
- G_CALLBACK (nautilus_properties_window_drag_data_received), NULL);
g_signal_connect (button, "clicked",
G_CALLBACK (select_image_button_callback), window);
}
diff -aur '--exclude=.git' '--exclude=meson_options.txt' a/nautilus/src/nautilus-tree-view-drag-dest.c b/nautilus/src/nautilus-tree-view-drag-dest.c
--- a/nautilus/src/nautilus-tree-view-drag-dest.c 2019-01-18 00:14:05.836665849 +0000
+++ b/nautilus/src/nautilus-tree-view-drag-dest.c 2019-01-18 00:13:52.173332518 +0000
@@ -287,9 +287,6 @@
return TRUE;
}
- gtk_drag_get_data (GTK_WIDGET (dest->details->tree_view),
- context, target, time);
-
return TRUE;
}
@@ -931,10 +928,6 @@
&& selection_length == 1
&& selection_data[0] == 'F')
{
- gtk_drag_get_data (widget, context,
- gdk_atom_intern (NAUTILUS_ICON_DND_RAW_TYPE,
- FALSE),
- time);
return FALSE;
}
else if (selection_format == 8
@@ -1044,8 +1037,6 @@
/* appease GtkTreeView by preventing its drag_data_receive
* from being called */
- g_signal_stop_emission_by_name (dest->details->tree_view,
- "drag-data-received");
return TRUE;
}
@@ -1363,10 +1354,6 @@
"drag-drop",
G_CALLBACK (drag_drop_callback),
dest, 0);
- g_signal_connect_object (tree_view,
- "drag-data-received",
- G_CALLBACK (drag_data_received_callback),
- dest, 0);
return dest;
}
diff -aur '--exclude=.git' '--exclude=meson_options.txt' a/nautilus/src/nautilus-window-slot-dnd.c b/nautilus/src/nautilus-window-slot-dnd.c
--- a/nautilus/src/nautilus-window-slot-dnd.c 2019-01-18 00:14:05.836665849 +0000
+++ b/nautilus/src/nautilus-window-slot-dnd.c 2019-01-18 00:13:52.173332518 +0000
@@ -189,8 +189,6 @@
{
goto out;
}
-
- gtk_drag_get_data (widget, context, target, time);
}
target_uri = NULL;
@@ -354,8 +352,6 @@
drag_info->drop_occurred = TRUE;
target = gtk_drag_dest_find_target (widget, context, NULL);
- gtk_drag_get_data (widget, context, target, time);
-
return TRUE;
}
@@ -559,9 +555,6 @@
g_signal_connect (widget, "drag-drop",
G_CALLBACK (slot_proxy_drag_drop),
drag_info);
- g_signal_connect (widget, "drag-data-received",
- G_CALLBACK (slot_proxy_drag_data_received),
- drag_info);
g_signal_connect (widget, "drag-leave",
G_CALLBACK (slot_proxy_drag_leave),
drag_info);
Results:
a. when there are not any calls to gtk_get_drag_data()
all is working as expected:
wo-get-data-log.txt
$ WAYLAND_DEBUG=1 nautilus ~/Music/ 2>&1 |egrep 'wl_data[^@]+|nau-' &
[1] 26829
[jm@jm nau]$ [433691.070] wl_registry@2.global(5, "wl_data_device_manager", 3)
[433691.397] -> wl_registry@2.bind(5, "wl_data_device_manager", 3, new id [unknown]@9)
[433697.008] -> wl_data_device_manager@9.get_data_device(new id wl_data_device@18, wl_seat@15)
[434016.282] wl_registry@27.global(5, "wl_data_device_manager", 3)
[434284.315] wl_data_device@18.data_offer(new id wl_data_offer@1898179680)
[434284.401] wl_data_offer@4278190080.offer("UTF8_STRING")
[434284.461] wl_data_offer@4278190080.offer("COMPOUND_TEXT")
[434284.500] wl_data_offer@4278190080.offer("TEXT")
[434284.539] wl_data_offer@4278190080.offer("STRING")
[434284.578] wl_data_offer@4278190080.offer("text/plain;charset=utf-8")
[434284.633] wl_data_offer@4278190080.offer("text/plain")
[434284.674] wl_data_offer@4278190080.offer("SAVE_TARGETS")
[434284.825] wl_data_device@18.selection(wl_data_offer@4278190080)
[434293.729] -> wl_data_offer@4278190080.accept(10546, "text/plain;charset=utf-8")
[434306.316] -> wl_data_offer@4278190080.receive("text/plain;charset=utf-8", fd 31)
[434307.202] -> wl_data_offer@4278190080.accept(10546, "text/plain;charset=utf-8")
[434327.881] -> wl_data_offer@4278190080.accept(10546, "text/plain;charset=utf-8")
[434328.633] -> wl_data_offer@4278190080.accept(10546, "text/plain;charset=utf-8")
[434346.726] -> wl_data_offer@4278190080.accept(10546, "text/plain;charset=utf-8")
[438912.234] wl_data_device@18.data_offer(new id wl_data_offer@1897038368)
[438912.403] wl_data_offer@4278190082.offer("GTK_TEXT_BUFFER_CONTENTS")
[438912.484] wl_data_offer@4278190082.offer("application/x-gtk-text-buffer-rich-text")
[438912.567] wl_data_offer@4278190082.offer("text/plain;charset=utf-8")
[438912.659] wl_data_offer@4278190082.offer("UTF8_STRING")
[438912.743] wl_data_offer@4278190082.offer("COMPOUND_TEXT")
[438912.822] wl_data_offer@4278190082.offer("TEXT")
[438912.909] wl_data_offer@4278190082.offer("STRING")
[438912.998] wl_data_offer@4278190082.offer("text/plain;charset=utf-8")
[438913.084] wl_data_offer@4278190082.offer("text/plain")
[438913.132] wl_data_offer@4278190082.action(0)
[438913.187] wl_data_offer@4278190082.source_actions(1)
[438913.833] wl_data_device@18.enter(10560, wl_surface@28, 73.234375, 267.242188, wl_data_offer@4278190082)
[438914.398] wl_data_device@18.motion(5591616, 73.234375, 267.242188)
[438923.300] -> wl_data_offer@4278190080.accept(10556, "text/plain;charset=utf-8")
[438931.885] -> wl_data_offer@4278190080.accept(10556, "text/plain;charset=utf-8")
[438932.128] -> wl_data_offer@4278190082.set_actions(0, 0)
[438932.243] -> wl_data_offer@4278190082.accept(10560, "(null)")
[438966.871] wl_data_device@18.motion(5591661, 73.234375, 266.238281)
[438967.166] -> wl_data_offer@4278190082.set_actions(0, 0)
[438967.347] -> wl_data_offer@4278190082.accept(10560, "(null)")
[439018.141] wl_data_device@18.motion(5591729, 72.246094, 265.246094)
[439018.363] -> wl_data_offer@4278190082.set_actions(0, 0)
[439018.452] -> wl_data_offer@4278190082.accept(10560, "(null)")
[439129.937] wl_data_device@18.motion(5591842, 72.246094, 262.242188)
[439130.288] -> wl_data_offer@4278190082.set_actions(0, 0)
[439130.414] -> wl_data_offer@4278190082.accept(10560, "(null)")
[439169.031] wl_data_device@18.motion(5591875, 72.246094, 261.238281)
[439169.391] -> wl_data_offer@4278190082.set_actions(7, 1)
[439169.533] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439170.917] wl_data_offer@4278190082.action(1)
[439171.072] -> wl_data_offer@4278190082.set_actions(7, 1)
[439171.197] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439217.526] wl_data_device@18.motion(5591908, 72.246094, 259.238281)
[439217.834] -> wl_data_offer@4278190082.set_actions(7, 1)
[439217.936] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439256.303] wl_data_device@18.motion(5591953, 72.246094, 258.246094)
[439256.864] -> wl_data_offer@4278190082.set_actions(7, 1)
[439257.015] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439335.907] wl_data_device@18.motion(5592043, 72.246094, 256.238281)
[439336.222] -> wl_data_offer@4278190082.set_actions(7, 1)
[439336.327] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439382.809] wl_data_device@18.motion(5592077, 72.246094, 255.242188)
[439383.148] -> wl_data_offer@4278190082.set_actions(7, 1)
[439383.279] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439421.886] wl_data_device@18.motion(5592138, 72.246094, 253.246094)
[439422.175] -> wl_data_offer@4278190082.set_actions(7, 1)
[439422.278] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439468.975] wl_data_device@18.motion(5592167, 72.246094, 252.242188)
[439469.454] -> wl_data_offer@4278190082.set_actions(7, 1)
[439469.574] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[439507.090] wl_data_device@18.motion(5592213, 72.246094, 252.242188)
[439507.461] -> wl_data_offer@4278190082.set_actions(7, 1)
[439507.718] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[440676.693] wl_data_device@18.motion(5593427, 72.246094, 251.238281)
[440676.927] -> wl_data_offer@4278190082.set_actions(7, 1)
[440676.998] -> wl_data_offer@4278190082.accept(10560, "text/plain")
[441611.914] wl_data_device@18.drop()
[441612.016] wl_data_device@18.leave()
nau-drop-sensor: dropped
[441613.319] -> wl_data_offer@4278190082.set_actions(7, 1)
b. even a single call to gtk_get_drag_data()
causes premature drag-n-drop operation termination in some unusual way, leaving x11 app with all mouse events blocked (kbd still works), entire Xwayland loses a mouse.
with-get-data-log.txt
$ WAYLAND_DEBUG=1 nautilus ~/Music/ 2>&1 |egrep 'wl_data[^@]+|nau-' &
[1] 31054
[jm@jm nau]$ [1185973.265] wl_registry@2.global(5, "wl_data_device_manager", 3)
[1185973.561] -> wl_registry@2.bind(5, "wl_data_device_manager", 3, new id [unknown]@9)
[1185979.111] -> wl_data_device_manager@9.get_data_device(new id wl_data_device@18, wl_seat@15)
[1186301.876] wl_registry@27.global(5, "wl_data_device_manager", 3)
[1186541.666] wl_data_device@18.data_offer(new id wl_data_offer@19388640)
[1186541.742] wl_data_offer@4278190080.offer("UTF8_STRING")
[1186541.785] wl_data_offer@4278190080.offer("COMPOUND_TEXT")
[1186541.871] wl_data_offer@4278190080.offer("TEXT")
[1186541.968] wl_data_offer@4278190080.offer("STRING")
[1186542.056] wl_data_offer@4278190080.offer("text/plain;charset=utf-8")
[1186542.141] wl_data_offer@4278190080.offer("text/plain")
[1186542.226] wl_data_offer@4278190080.offer("SAVE_TARGETS")
[1186542.311] wl_data_device@18.selection(wl_data_offer@4278190080)
[1186561.308] -> wl_data_offer@4278190080.accept(11892, "text/plain;charset=utf-8")
[1186563.376] -> wl_data_offer@4278190080.receive("text/plain;charset=utf-8", fd 31)
[1186564.015] -> wl_data_offer@4278190080.accept(11892, "text/plain;charset=utf-8")
[1186576.383] -> wl_data_offer@4278190080.accept(11892, "text/plain;charset=utf-8")
[1186586.174] -> wl_data_offer@4278190080.accept(11892, "text/plain;charset=utf-8")
[1186626.000] -> wl_data_offer@4278190080.accept(11892, "text/plain;charset=utf-8")
[1195612.337] wl_data_device@18.data_offer(new id wl_data_offer@19578128)
[1195612.537] wl_data_offer@4278190081.offer("GTK_TEXT_BUFFER_CONTENTS")
[1195612.677] wl_data_offer@4278190081.offer("application/x-gtk-text-buffer-rich-text")
[1195612.801] wl_data_offer@4278190081.offer("text/plain;charset=utf-8")
[1195612.998] wl_data_offer@4278190081.offer("UTF8_STRING")
[1195613.081] wl_data_offer@4278190081.offer("COMPOUND_TEXT")
[1195613.169] wl_data_offer@4278190081.offer("TEXT")
[1195613.253] wl_data_offer@4278190081.offer("STRING")
[1195613.950] wl_data_offer@4278190081.offer("text/plain;charset=utf-8")
[1195614.337] wl_data_offer@4278190081.offer("text/plain")
[1195614.612] wl_data_offer@4278190081.action(0)
[1195614.947] wl_data_offer@4278190081.source_actions(0)
[1195615.190] wl_data_device@18.enter(11915, wl_surface@28, 192.242188, 252.242188, wl_data_offer@4278190081)
[1195615.659] wl_data_device@18.motion(6348351, 192.242188, 252.242188)
[1195651.008] -> wl_data_offer@4278190080.accept(11896, "text/plain;charset=utf-8")
[1195651.910] -> wl_data_offer@4278190080.accept(11896, "text/plain;charset=utf-8")
nau-dnd-getting-data-begins
[1195653.476] -> wl_data_offer@4278190081.accept(11896, "UTF8_STRING")
[1195653.967] -> wl_data_offer@4278190081.receive("UTF8_STRING", fd 31)
nau-dnd-getting-data-finished
[1195654.872] -> wl_data_offer@4278190081.set_actions(0, 0)
[1195655.062] -> wl_data_offer@4278190081.accept(11915, "(null)")
[1195656.029] wl_data_device@18.motion(6348373, 191.000000, 249.000000)
[1195656.350] -> wl_data_offer@4278190081.set_actions(0, 0)
[1195656.534] -> wl_data_offer@4278190081.accept(11915, "(null)")
[1195689.615] -> wl_data_offer@4278190081.set_actions(0, 0)
[1195689.783] -> wl_data_offer@4278190081.accept(11915, "(null)")
[1195693.660] wl_data_device@18.leave()
Well, it could be mutter issue as well, not gtk/gdk one (or even wayland?). I just was unable to track it down further.
BTW, despite of drag-motion signal documentation this equally works (or does not, when we call gtk_drag_get_data) regardless of GTK_DEST_DEFAULT_MOTION
setting of gtk_drag_dest_set()
, which states that it must be set. Need not it be changed to should instead?
Thanks