Closed Bug 1717476 Opened 3 years ago Closed 3 years ago

[Wayland] Implement async clipboard for D&D data transfers

Categories

(Core :: Widget: Gtk, defect, P2)

defect

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: stransky, Assigned: stransky)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

This is a bug for https://gitlab.gnome.org/GNOME/mutter/-/issues/1855

Backtrace:
#0 0x00007fcdba1e994c in read () at /lib64/libpthread.so.0
#1 0x00007fcdb7e30102 in g_io_unix_read () at /lib64/libglib-2.0.so.0
#2 0x00007fcdb7dcf815 in g_io_channel_fill_buffer () at /lib64/libglib-2.0.so.0
#3 0x00007fcdb7dd073b in g_io_channel_read_to_end () at /lib64/libglib-2.0.so.0
#4 0x00007fcdb3d30e50 in DataOffer::GetData(wl_display*, char const*, unsigned int*)
(this=<optimized out>, aDisplay=0x7fcdb9a1c430, aMimeType=0x7fcd5d06aed0 "text/x-moz-url", aContentLength=0x7fcd5fd64de8) at /raid/src2/widget/gtk/nsClipboardWayland.cpp:131
#5 0x00007fcdb3d39699 in nsDragService::GetTargetDragData(_GdkAtom*) (this=this@entry=0x7fcd5fd64c80, aFlavor=aFlavor@entry=0x5f) at /raid/src2/widget/gtk/nsDragService.cpp:1141
#6 0x00007fcdb3d39e54 in nsDragService::GetData(nsITransferable*, unsigned int) (this=<optimized out>, aTransferable=0x7fcd5baf9040, aItemIndex=<optimized out>)
at /raid/src2/widget/gtk/nsDragService.cpp:662
#7 0x00007fcdb31bc7b1 in mozilla::dom::DataTransferItem::FillInExternalData() (this=this@entry=0x7fcd5c0215f0) at /raid/src2/dom/events/DataTransferItem.cpp:175
#8 0x00007fcdb31b8d16 in mozilla::dom::DataTransferItem::DataNoSecurityCheck() (this=0x7fcd5c0215f0) at /raid/src2/dom/events/DataTransferItem.cpp:487
#9 mozilla::dom::DataTransferItem::Data(nsIPrincipal*, mozilla::ErrorResult&) (this=this@entry=0x7fcd5c0215f0, aPrincipal=0x7fcd5b956000, aPrincipal@entry=0x7fcd9f303680, aRv=...)
at /raid/src2/dom/events/DataTransferItem.cpp:500
#10 0x00007fcdb31b8266 in mozilla::dom::DataTransfer::GetDataAtInternal(nsTSubstring<char16_t> const&, unsigned int, nsIPrincipal*, nsIVariant**) const
(this=<optimized out>, aFormat=<optimized out>, aIndex=<optimized out>, aSubjectPrincipal=0x7fcd9f303680, aData=aData@entry=0x7ffd8d90e1f0) at /raid/src2/dom/events/DataTransfer.cpp:529
#11 0x00007fcdb31b8f7f in mozilla::dom::DataTransfer::MozGetDataAt(JSContext*, nsTSubstring<char16_t> const&, unsigned int, JS::MutableHandle<JS::Value>, nsIPrincipal&, mozilla::ErrorResult&) (this=0x6b, aCx=0x7fcd9e823000, aFormat=..., aIndex=1024, aRetval=$JS::UndefinedValue(), aSubjectPrincipal=..., aRv=...) at /raid/src2/dom/events/DataTransfer.cpp:544
#12 0x00007fcdb2d4120b in mozilla::dom::DataTransfer_Binding::mozGetDataAt(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&)Python Exception <class 'gdb.error'> value has

Priority: -- → P2

This can be used for testing:
MOZ_ENABLE_WAYLAND=1 ./mach mochitest --setpref widget.wayland.test-workarounds.enabled=true dom/base/test/test_copypaste.html

Firefox uses synchronized clipboard data get/set which causes issues when clipboard data is transferred in scope of Firefox
itself as getting code blocks the sending one. As a workaround X11 clipboard code runs restricted message loop (processes clipboard events only),
Wayland clipboard handler uses fast (direct) path when clipboard data is owned by Firefox and D&D code runs main loop for some limited time.

When D&D operation is used on Wayland we can't determine clipboard data owner - so we can't use the fast (direct) data transfer but we always
read data from wayland clipboard. That approach block when D&D data comes from Firefox itself.

In orded to fix that this patch does:

  • Implement DataOffer::GetDataInternal() as non-blocking, i.e. fail when we can't get data from file descriptor provided by Wayland clipboard code.
  • Create new thread and run DataOffer::GetDataInternal() there
  • Run limited main event loop as D&D code does.

In order to make the changes possible we also need to better track wayland data offers:

  • Implement DataOffer as ref counted general wayland clipboard data placeholder
  • Implement WaylandDragAndDropDataOffer for D&D data events
  • Track all offers in offer cache (mActiveOffers)
Summary: [Wayland] D&D lockup → [Wayland] Implement async clipboard for D&D data transfers

Before I open a new bug: Could this be the reason why I cannot paste things from Firefox into other apps? (On Fedora 34, Firefox 89.0.2, KDE 5.22.1)

(In reply to Patrice Peterson from comment #5)

Before I open a new bug: Could this be the reason why I cannot paste things from Firefox into other apps? (On Fedora 34, Firefox 89.0.2, KDE 5.22.1)

No, we have issues with paste into Firefox. Copy data out of Firefox should work as we use standard Gtk handlers. Please file a new bug for it.

Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/c823c43f6d1e [Wayland] Imlement async clipboard data get, r=jhorak https://hg.mozilla.org/integration/autoland/rev/cc8f22f2278b [Wayland] Change nsWaylandDragContext to RefPtr<DataOffer> in nsWindow code, r=jhorak https://hg.mozilla.org/integration/autoland/rev/35d406f57982 [Wayland] Change nsWaylandDragContext to RefPtr<DataOffer> in DragService code, r=jhorak

(In reply to Patrice Peterson from comment #5)

Before I open a new bug: Could this be the reason why I cannot paste things from Firefox into other apps? (On Fedora 34, Firefox 89.0.2, KDE 5.22.1)

That should be https://bugzilla.mozilla.org/show_bug.cgi?id=1631061

Regressions: 1721563
Regressions: 1721564
Regressions: 1721707
Regressions: 1722700
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: