Closed Bug 2025329 Opened 5 months ago Closed 2 months ago

[Wayland] Re-implement back Wayland custom/specific clipboard and D&D handlers

Categories

(Core :: Widget: Gtk, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: stransky, Assigned: stransky)

References

(Blocks 4 open bugs)

Details

Attachments

(18 files, 5 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Bug 1752503 removed Wayland specific D&D and clipboard handlers. We'd need to re-implement that (D&D at lead) to support toplevel D&D operations.

Flags: needinfo?(stransky)
Attachment #9558508 - Attachment is obsolete: true
See Also: → 2022428
Attachment #9558630 - Attachment is obsolete: true
Attachment #9563398 - Attachment is obsolete: true

There are some try failures here:
https://treeherder.mozilla.org/jobs?repo=try&revision=e4b5cf61860f2bba5671bfbf8a01805eea0fe152

./mach test dom/events/test/clipboard/test_paste_image.html

Blocks: gtkclipboard
Severity: -- → S3
Flags: needinfo?(stransky)
Priority: -- → P3
Assignee: nobody → stransky
Status: NEW → ASSIGNED

This is re-implementation of gtk3/filetransferportal.c code to Mozilla codebase.

Implement base AsyncClipboardRequest to get data from clipboard and move platform specific code to DataRequestGtk / DataRequestWayland classes.
Wayland code uses the same data read logic/functions as gtk3 clipboard implementation.

Use AsyncClipboardRequest to implement Wayland specific clipboard.
As Wayland uses the same wl_data_offer struct for clipboard and D&D the implementation is also used by D&D code.

Move clipboard target cache from nsClipboard to nsClipboardX11 as X11/Gtk uses clipboard query to get targets.
We don't use the cache on Wayland as targets are provided in advance here.

Attachment #9567608 - Attachment is obsolete: true
Keywords: leave-open

Landing Bug 2025329 [Wayland] Add widget/gtk/WUniquePtr.h to use smart pointers with Wayland objects r?emilio to use it on other patches.

Blocks: 1955221
See Also: → 1955221
Blocks: 2041588
Attachment #9570793 - Attachment description: Bug 2025329 [Wayland] Add widget/gtk/WUniquePtr.h to use smart pointers with Wayland objects r?emilio → Bug 2025329 [Wayland] Update WUniquePtr.h for more Wayland objects r?emilio
Keywords: leave-open
Pushed by stransky@redhat.com: https://github.com/mozilla-firefox/firefox/commit/35c76d4735c4 https://hg.mozilla.org/integration/autoland/rev/9b0a377719d3 [Wayland] Update WUniquePtr.h for more Wayland objects r=emilio https://github.com/mozilla-firefox/firefox/commit/e3650476177c https://hg.mozilla.org/integration/autoland/rev/87b0c5fa0a87 Add file transfer portal implementation r=emilio https://github.com/mozilla-firefox/firefox/commit/2ef17a77eb7d https://hg.mozilla.org/integration/autoland/rev/b56b9c5573f8 Add glib/gio to system headers r=emilio https://github.com/mozilla-firefox/firefox/commit/27faf8ee7b06 https://hg.mozilla.org/integration/autoland/rev/9f5423432a74 Add more glib types to GUniquePtr.h r=emilio https://github.com/mozilla-firefox/firefox/commit/1af410f31fcc https://hg.mozilla.org/integration/autoland/rev/2d09c370fd8f Load Wayland primary selection protocols in nsWaylandDisplay r=emilio https://github.com/mozilla-firefox/firefox/commit/d85ec8b5ec82 https://hg.mozilla.org/integration/autoland/rev/52d3c3203115 Rename AsyncGtkClipboardRequest to AsyncClipboardRequest and update it to work with DataRequestGtk/DataRequestWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/9110ac848507 https://hg.mozilla.org/integration/autoland/rev/911815b61772 Implement custom native Wayland clipboard at nsClipboardWayland.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/37806df3b4f8 https://hg.mozilla.org/integration/autoland/rev/6a463b946031 Move Gtk/X11 clipboard to nsClipboardX11.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/8eb7aa362f21 https://hg.mozilla.org/integration/autoland/rev/249ae1e92af0 Update nsClipboard module to work with nsClipboardX11/nsClipboardWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/923a133025fb https://hg.mozilla.org/integration/autoland/rev/be3a4bd220dc Move Gtk/X11 D&D implementation to nsDragServiceX11 r=emilio https://github.com/mozilla-firefox/firefox/commit/dbf005cf0916 https://hg.mozilla.org/integration/autoland/rev/f15807a3a5de Implement Wayland custom D&D handler as nsDragServiceWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/1bdd4d9efe85 https://hg.mozilla.org/integration/autoland/rev/f01ed4c576f2 Update nsDragService for nsDragServiceX11/nsDragServiceWayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/738c6200b02a https://hg.mozilla.org/integration/autoland/rev/ac8dee604c28 Update nsWindow for X11/Wayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/a31ec3f0a6fa https://hg.mozilla.org/integration/autoland/rev/f7e89a3b16bb Update build config r=emilio

Updated, Thanks.

Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://github.com/mozilla-firefox/firefox/commit/de30d5218d8b https://hg.mozilla.org/integration/autoland/rev/530ae06690bd [Wayland] Update WUniquePtr.h for more Wayland objects r=emilio https://github.com/mozilla-firefox/firefox/commit/b0ceca5fa523 https://hg.mozilla.org/integration/autoland/rev/73bbaa61c458 Add file transfer portal implementation r=emilio https://github.com/mozilla-firefox/firefox/commit/e3f6b182d225 https://hg.mozilla.org/integration/autoland/rev/b463a578bdb2 Add glib/gio to system headers r=emilio https://github.com/mozilla-firefox/firefox/commit/1283288b63ec https://hg.mozilla.org/integration/autoland/rev/058a49d2a8a4 Add more glib types to GUniquePtr.h r=emilio https://github.com/mozilla-firefox/firefox/commit/a3c48837467b https://hg.mozilla.org/integration/autoland/rev/03adf2760390 Load Wayland primary selection protocols in nsWaylandDisplay r=emilio https://github.com/mozilla-firefox/firefox/commit/a6bd267b7ecd https://hg.mozilla.org/integration/autoland/rev/20d6e8680b34 Rename AsyncGtkClipboardRequest to AsyncClipboardRequest and update it to work with DataRequestGtk/DataRequestWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/06bb245a673b https://hg.mozilla.org/integration/autoland/rev/2c51f9817e73 Implement custom native Wayland clipboard at nsClipboardWayland.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/bb24aa5c2e43 https://hg.mozilla.org/integration/autoland/rev/df4baf27b7c3 Move Gtk/X11 clipboard to nsClipboardX11.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/9a2a59f00f3e https://hg.mozilla.org/integration/autoland/rev/45e8f5e29c9e Update nsClipboard module to work with nsClipboardX11/nsClipboardWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/2dee0c586015 https://hg.mozilla.org/integration/autoland/rev/8d54606a6f34 Move Gtk/X11 D&D implementation to nsDragServiceX11 r=emilio https://github.com/mozilla-firefox/firefox/commit/e9324c589db1 https://hg.mozilla.org/integration/autoland/rev/79a484087f7b Implement Wayland custom D&D handler as nsDragServiceWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/6a12519f9f6a https://hg.mozilla.org/integration/autoland/rev/5bc2fa1e6352 Update nsDragService for nsDragServiceX11/nsDragServiceWayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/fe94adfae909 https://hg.mozilla.org/integration/autoland/rev/bcf4357deea1 Update nsWindow for X11/Wayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/c87eb69f7742 https://hg.mozilla.org/integration/autoland/rev/1fcaa69f025f Update build config r=emilio https://github.com/mozilla-firefox/firefox/commit/fb480cf02d5f https://hg.mozilla.org/integration/autoland/rev/d64d4ddffef4 apply code formatting via Lando
Regressions: 2042811
Pushed by imoraru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2f9b76f3f42c https://hg.mozilla.org/integration/autoland/rev/5ca77033679d Revert "Bug 2025329: apply code formatting via Lando" for causing failures on test_bug1247483.html.

Revert for causing failures on test_bug1247483.html.

Flags: needinfo?(stransky)

Looks like there's missing gap when clipboard data is set by us by Gtk interface - we're quick enough to ear the data before it goes back to us via. event loop in the test.

We're hitting Bug 1857075 variant here. We may also round-trip after data set to make sure they're there.

Gtk solves that by implementing data cache for such cases. We have data cache for D&D so we may also re-use it here.

Duplicate of this bug: 2034559

./mach test editor/libeditor/tests/ is the failing test command.

./mach test dom/events/test/clipboard/test_paste_image.html also fails.

./mach test widget/tests/

./mach test widget/tests/test_clipboard_owner_chrome.html

Don't use RetrievalContextWayland on Wayland as Gtk/Wayland doesn't work correctly together when a data is set by Gtk but retrieved by Wayland.
Rather use Gtk backend (as we did before) to set/get clipboard data.

Don't use RetrievalContextWayland on Wayland as Gtk/Wayland doesn't work correctly together when a data is set by Gtk but retrieved by Wayland.
Rather use Gtk backend (as we did before) to set/get clipboard data.

Attachment #9594823 - Attachment is obsolete: true
Attachment #9594824 - Attachment description: Bug 2025329 [Wayland] Add RetrievalContextGtk to get clipboard data by Gtk generic interface on Wayland as we do before r?emilio → Bug 2025329 [Wayland] Add RetrievalContextGtk to get clipboard data by Gtk generic interface on Wayland r?emilio

! In D305175#10592779, @emilio wrote:
I'm confused about that change, is it really needed? Can you comment on it if so?

Putting the reply here to make it more visible.

Yes. This change is result of investigation of various clipboard failures like:
https://treeherder.mozilla.org/logviewer?job_id=569031835&repo=autoland&task=Fy-c0XhKTh6qrUXiBu-HXg.0&lineNumber=15719

Generally we use Gtk to set clipboard data but we use Wayland to retrieve it. Gtk caches the clipboard data and process them somehow, makes internal data cache and so. And then (after some time) sends it to system (X11/Wayland).
It doesn't matter much if it's used by 'regular' scenario like user interaction - copy/paste - with long delay between the ops.

But that gap breaks the Mozilla automation - we set/get clipboard data quickly and Gtk fails to send clipboard data to OS in the time we're requesting it. So we see various clipboard inconsistency and random bugs.
Also Gtk caches the clipboard data (and MIME types) so set/get clipboard by the same app may not get to OS at all - it's retrieved from Gtk cache.

So the Gtk->Wayland clipboard data path contains various bumps/breaks which may or may not affect the data transfer.

I tried various approaches (add display flush/roundtrips after gtk data set) but it still's fails in some cases like clipboard clearing (that's more Gtk internal thing that Wayland compositor one).

The best approach is to use Gtk for X11 and native Wayland for Wayland. But that will need to implement Wayland data set which is not trivial.
So as the intermediate step I decided to put back the clipboard Gtk/Gtk path for Wayland and use Gtk/Wayland for D&D only where the most issues are visible (various wayland protocol error crashes due to obsoleted wayland object). The Wayland D&D handler will also help us to implement toplevel D&D.

The final state should be:

  • Use Gtk for clipboard/D&D on X11
  • Use Wayland for clipboard (set/get)
  • Use Wayland for D&D (set/get)
  • Integrate Wayland clipboard and D&D data caches
Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://github.com/mozilla-firefox/firefox/commit/b958058aab72 https://hg.mozilla.org/integration/autoland/rev/06df32ea8552 [Wayland] Update WUniquePtr.h for more Wayland objects r=emilio https://github.com/mozilla-firefox/firefox/commit/9af2222172d4 https://hg.mozilla.org/integration/autoland/rev/8c154a30f15e Add file transfer portal implementation r=emilio https://github.com/mozilla-firefox/firefox/commit/f1605c7eaa44 https://hg.mozilla.org/integration/autoland/rev/2ebf061741c1 Add glib/gio to system headers r=emilio https://github.com/mozilla-firefox/firefox/commit/4a53f2ba59cb https://hg.mozilla.org/integration/autoland/rev/af9117a91081 Add more glib types to GUniquePtr.h r=emilio https://github.com/mozilla-firefox/firefox/commit/a6a83c0ea15d https://hg.mozilla.org/integration/autoland/rev/fc73fd382cd9 Load Wayland primary selection protocols in nsWaylandDisplay r=emilio https://github.com/mozilla-firefox/firefox/commit/78a59a833532 https://hg.mozilla.org/integration/autoland/rev/9218ae1696e5 Rename AsyncGtkClipboardRequest to AsyncClipboardRequest and update it to work with DataRequestGtk/DataRequestWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/d64052cc0c60 https://hg.mozilla.org/integration/autoland/rev/08aa764e9d47 Implement custom native Wayland clipboard at nsClipboardWayland.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/ab899eb94980 https://hg.mozilla.org/integration/autoland/rev/43ad83f517df Move Gtk/X11 clipboard to nsClipboardX11.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/9040fff9a000 https://hg.mozilla.org/integration/autoland/rev/9a187a577db3 Update nsClipboard module to work with nsClipboardX11/nsClipboardWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/9fbced002406 https://hg.mozilla.org/integration/autoland/rev/dafa6dd571ee Move Gtk/X11 D&D implementation to nsDragServiceX11 r=emilio https://github.com/mozilla-firefox/firefox/commit/d03532f47020 https://hg.mozilla.org/integration/autoland/rev/161fcbb42ef1 Implement Wayland custom D&D handler as nsDragServiceWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/5c09c8a0c46e https://hg.mozilla.org/integration/autoland/rev/8b5596ec92a1 Update nsDragService for nsDragServiceX11/nsDragServiceWayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/71798ff1c539 https://hg.mozilla.org/integration/autoland/rev/daaadadaf0b4 Update nsWindow for X11/Wayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/8c2e9ecf5389 https://hg.mozilla.org/integration/autoland/rev/29327ed680ba Update build config r=emilio https://github.com/mozilla-firefox/firefox/commit/051b89587e51 https://hg.mozilla.org/integration/autoland/rev/6fc3684ff92b [Wayland] Add RetrievalContextGtk to get clipboard data by Gtk generic interface on Wayland r=emilio https://github.com/mozilla-firefox/firefox/commit/9cc851f2dc51 https://hg.mozilla.org/integration/autoland/rev/72b27392cfd4 [Linux] Rename nsClipboardX11/Gtk/Wayland files to RetrievalContextX11/Gtk/Wayland r=emilio https://github.com/mozilla-firefox/firefox/commit/6dda3a3493fd https://hg.mozilla.org/integration/autoland/rev/b5bdfbf2a8fa [Wayland] Create RetrievalContextWayland for D&D service only r=emilio
Pushed by ctuns@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5e1db46485db https://hg.mozilla.org/integration/autoland/rev/b49398450312 Revert "Bug 2025329 [Wayland] Create RetrievalContextWayland for D&D service only r=emilio" for causing lint failures in RetrievalContextGtk.h

Backed out for causing lint failures

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/widget/gtk/RetrievalContextGtk.h:0 | invalid header guard RetrievalContextGtk_h, leading underscore followed by a capital letter in a macro name is reserved (header-guards)
Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://github.com/mozilla-firefox/firefox/commit/f375ac09c664 https://hg.mozilla.org/integration/autoland/rev/a16ae311a516 [Wayland] Update WUniquePtr.h for more Wayland objects r=emilio https://github.com/mozilla-firefox/firefox/commit/65ae68ca0259 https://hg.mozilla.org/integration/autoland/rev/954ecebcc58e Add file transfer portal implementation r=emilio https://github.com/mozilla-firefox/firefox/commit/879285cd7c71 https://hg.mozilla.org/integration/autoland/rev/d29f4626c7ce Add glib/gio to system headers r=emilio https://github.com/mozilla-firefox/firefox/commit/05ac307674a5 https://hg.mozilla.org/integration/autoland/rev/51d5f649637e Add more glib types to GUniquePtr.h r=emilio https://github.com/mozilla-firefox/firefox/commit/5609d0b237c2 https://hg.mozilla.org/integration/autoland/rev/f8def2b92b9c Load Wayland primary selection protocols in nsWaylandDisplay r=emilio https://github.com/mozilla-firefox/firefox/commit/2e1be66282fa https://hg.mozilla.org/integration/autoland/rev/acdc2d1e7932 Rename AsyncGtkClipboardRequest to AsyncClipboardRequest and update it to work with DataRequestGtk/DataRequestWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/7e0dd129f08d https://hg.mozilla.org/integration/autoland/rev/868548dec07b Implement custom native Wayland clipboard at nsClipboardWayland.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/54c23f72460c https://hg.mozilla.org/integration/autoland/rev/1a3fd5ab37a3 Move Gtk/X11 clipboard to nsClipboardX11.cpp r=emilio https://github.com/mozilla-firefox/firefox/commit/1f584256a884 https://hg.mozilla.org/integration/autoland/rev/54c1fad1f00a Update nsClipboard module to work with nsClipboardX11/nsClipboardWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/3f9dd00b747b https://hg.mozilla.org/integration/autoland/rev/74597811818e Move Gtk/X11 D&D implementation to nsDragServiceX11 r=emilio https://github.com/mozilla-firefox/firefox/commit/d41c530fc0ff https://hg.mozilla.org/integration/autoland/rev/1a5d01572033 Implement Wayland custom D&D handler as nsDragServiceWayland r=emilio https://github.com/mozilla-firefox/firefox/commit/613f4c9468b8 https://hg.mozilla.org/integration/autoland/rev/382e905cea6b Update nsDragService for nsDragServiceX11/nsDragServiceWayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/e141df0f35d0 https://hg.mozilla.org/integration/autoland/rev/e041b7b649c7 Update nsWindow for X11/Wayland backends r=emilio https://github.com/mozilla-firefox/firefox/commit/786914670937 https://hg.mozilla.org/integration/autoland/rev/52152d197dc1 Update build config r=emilio https://github.com/mozilla-firefox/firefox/commit/10eb6f980021 https://hg.mozilla.org/integration/autoland/rev/f88dda635762 [Wayland] Add RetrievalContextGtk to get clipboard data by Gtk generic interface on Wayland r=emilio https://github.com/mozilla-firefox/firefox/commit/c134464e7cf7 https://hg.mozilla.org/integration/autoland/rev/a122e8a111c6 [Linux] Rename nsClipboardX11/Gtk/Wayland files to RetrievalContextX11/Gtk/Wayland r=emilio https://github.com/mozilla-firefox/firefox/commit/43dd765f2f20 https://hg.mozilla.org/integration/autoland/rev/7dc5ffa47071 [Wayland] Create RetrievalContextWayland for D&D service only r=emilio
Flags: needinfo?(stransky)
Depends on: 2046911
No longer depends on: 2046911
Regressions: 2046911
Regressions: 2047217
Regressions: 2047409
See Also: → 2047946
Blocks: 2048548
See Also: → 2048548
QA Whiteboard: [qa-triage-done-c154/b153]
Regressions: 2049720
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: