Wayland foreign protocol
ClosedPublic

Authored by mart on Aug 17 2017, 3:47 PM.

Details

Summary

Implement the "foreign" wayland protocol.
A client can export a surface with an unique string as handle,
then another client can refer to that surface and set an own surface as
child of that surface.
Potential use cases are out-of-process dialogs, such as file dialogs,
meant to be used by sandboxed processes that may not have the access
it needs to implement such dialogs.
The handle needs to be shared between the processes with other means,
such as dbus or command line paramenters.

The public api of the server side only tracks parent/child relationships as this is the only data kwin would need it for, the rest of the api is not exported so should be safer from eventual protocol changes

Test Plan

the autotest works, but has a lot of random crashes when deleting surfaces,
unfortunately backtraces don't tell much and the crashes never occur when running into valgrind
behavior may still be wrong, depending on how the protocol is supposed
to work if more clients try to set the same exported surface as parent

Diff Detail

Repository
R127 KWayland
Branch
mart/xdgforeign
Lint
No Linters Available
Unit
No Unit Test Coverage
mart created this revision.Aug 17 2017, 3:47 PM
Restricted Application added projects: Plasma on Wayland, Frameworks. · View Herald TranscriptAug 17 2017, 3:47 PM
Restricted Application added subscribers: Frameworks, plasma-devel. · View Herald Transcript
mart edited the summary of this revision. (Show Details)Aug 17 2017, 3:53 PM
mart added inline comments.
src/server/xdgforeign_v1_interface.cpp
213 ↗(On Diff #18767)

the children hash may have to become a multihash to permit more children for a single parent

graesslin added inline comments.
src/client/registry.h
940–941

The general pattern I used for protocols which might get another revision is to create a "meta" class which hides the UnstableV1 mess. C.f. the PointerConstraints a line above.

src/server/xdgforeign_v1_interface.cpp
164 ↗(On Diff #18767)

shouldn't we verify that the Uuid is unique? I just checked the docs and don't see a requirement that the created Uuid is unique.

src/server/xdgforeign_v1_interface.h
38 ↗(On Diff #18294)

also on the server I tried to hide the unstable mess from the class names. The advantage is that the user does not have to change all it's code to support this. Example is the text input protocol.

davidedmundson requested changes to this revision.Aug 17 2017, 4:39 PM
davidedmundson added a subscriber: davidedmundson.
davidedmundson added inline comments.
src/client/xdgforeign_v1.cpp
190 ↗(On Diff #18767)

Some idiot left a comment all over your code after fixing it.

We don't do the thing I was saying about anymore.

src/server/xdgforeign_v1_interface.cpp
300 ↗(On Diff #18767)

this should be connected to unbound.

308 ↗(On Diff #18767)

I don't think this is right.

Second half of this line:

A surface may be exported multiple times, and each exported handle may be used to create a xdg_imported multiple times.

498 ↗(On Diff #18767)

the super class destructor (Resource::Private::~Private) does this

src/server/xdgforeign_v1_interface.h
51 ↗(On Diff #18294)

docs, especially on what either argument being null means.

This revision now requires changes to proceed.Aug 17 2017, 4:39 PM
mart added inline comments.Aug 18 2017, 10:19 AM
src/client/registry.h
940–941

i see the types are named zxdg_exporter_v1 because it's how the interface is calledin the wayland protocol xml.
woudl i need to make another copy of the xml where the interface name is unversioned?

mart marked 2 inline comments as done.Aug 18 2017, 10:28 AM
mart added inline comments.
src/server/xdgforeign_v1_interface.cpp
300 ↗(On Diff #18767)

perhaps the connects to the destruction of the SurfaceInterface* are not even necessary?

mart updated this revision to Diff 18357.Aug 18 2017, 4:07 PM
mart edited edge metadata.
  • get rid of the v1 from the verver side
  • dress some issues
  • Q_DECL_HIDDEN for all non exported classes
  • track surface destruction
  • more attention to data integrity
  • wait for server surfaces deletion
  • more qpointers out of pure desperation
Restricted Application edited projects, added Plasma; removed Plasma on Wayland. · View Herald TranscriptAug 18 2017, 4:07 PM
mart added a comment.Aug 18 2017, 4:09 PM

part of the comments adressed, still to wrap the client part in order to hide the v1 implementation.

the status right now is that, when running in valgrind all test pass, while then invoked directly it almost always crashes, but every time at a different, random place.
there is some serious memory corruption somewhere, but i'm completely at loss in figuring out where it is (and valgrind output, as gdb backtraces seem quite useless)

mart updated this revision to Diff 18596.Aug 23 2017, 1:02 PM
  • Don't call release twice
  • Correctly set
  • don't call destroy in the destroyed callback
  • add a test exporting a surface two times
  • test importing two times the same surface
  • wrap XdgForeignUnstableV1 to XdgForeignUnstable
  • unexport classes that should be private
Restricted Application edited projects, added Plasma on Wayland; removed Plasma. · View Herald TranscriptAug 23 2017, 1:02 PM
mart added a comment.Aug 23 2017, 1:10 PM

now the client part is wrapped too, so no V1 exported (the public facing classes should lose "Unstable" probably)
two more tests to check that importing the same exported in two clients works and exporting the same surface two times works as well.
thanks to david's help most of the random crashes are fixed, there is still to solve one crash at exit of the autotest and the warning message:
wl_display@1: error 0: invalid object 9 in a couple of autotests, which still suggests something wrong.

i think it's getting near feature completness to implement the kwin part tough

mart updated this revision to Diff 18744.Aug 25 2017, 11:14 AM
  • add a manual test for foreign
  • remove Unstable from public symbols
Restricted Application edited projects, added Plasma; removed Plasma on Wayland. · View Herald TranscriptAug 25 2017, 11:14 AM
mart updated this revision to Diff 18760.Aug 25 2017, 5:03 PM
  • add a serverside setTransientFor in xdgshell
Restricted Application edited projects, added Plasma on Wayland; removed Plasma. · View Herald TranscriptAug 25 2017, 5:03 PM
mart updated this revision to Diff 18767.Aug 25 2017, 5:47 PM
  • get rid of setTransientFor
Restricted Application edited projects, added Plasma; removed Plasma on Wayland. · View Herald TranscriptAug 25 2017, 5:47 PM
mart retitled this revision from [WIP] Wayland foreign protocol to Wayland foreign protocol.Sep 5 2017, 1:17 PM
graesslin requested changes to this revision.Sep 5 2017, 4:57 PM

Overall lots of documentation is missing.

From API layout that looks much better now, but we still have a few places where "Unstable" is needlessly in the API. Most important in Display the create method is not forward compatible by not having an enum to describe which interface version should be created.

src/client/registry.h
527–528 ↗(On Diff #18767)

please add documentation

940–941 ↗(On Diff #18767)

please add documentation

940–941 ↗(On Diff #18767)

Why did you keep the suffix "Unstable"?

1132–1133 ↗(On Diff #18767)

please add documentation

1288–1290 ↗(On Diff #18767)

please add documentation

src/server/display.h
223 ↗(On Diff #18767)

please add documentation.

Also the common way would be to have an enum to describe which interface should be created, but therefore drop the Unstable from the API name.

src/server/xdgforeign_interface.h
37 ↗(On Diff #18767)

Something like an enum ForeignInterfaceVersion is missing, please compare TextInputInterface

src/server/xdgforeign_v1_interface.cpp
260 ↗(On Diff #18767)

what's an imp? Could you please write full variable names?

This revision now requires changes to proceed.Sep 5 2017, 4:57 PM
mart updated this revision to Diff 20257.Oct 2 2017, 3:55 PM
  • move to xdg-foreign-unstable-v2
  • get rid of setTransientFor
Restricted Application edited projects, added Plasma on Wayland; removed Plasma. · View Herald TranscriptOct 2 2017, 3:55 PM
graesslin requested changes to this revision.Oct 4 2017, 6:41 PM

Documentation is still missing, Unstable suffix is still in two many API calls.

src/client/registry.h
527–528

documentation missing

This revision now requires changes to proceed.Oct 4 2017, 6:41 PM
mart added a comment.Oct 10 2017, 10:43 AM

Documentation is still missing, Unstable suffix is still in two many API calls.

i think the importerUnstableV2Announced exporterUnstableV2Announced should remain with unstable and versioned?

mart updated this revision to Diff 20553.Oct 10 2017, 11:11 AM
  • add api docs, getridof some unstable, calls with unstable follow the other interfaces
Restricted Application edited projects, added Plasma; removed Plasma on Wayland. · View Herald TranscriptOct 10 2017, 11:11 AM
In D7369#153978, @mart wrote:

Documentation is still missing, Unstable suffix is still in two many API calls.

i think the importerUnstableV2Announced exporterUnstableV2Announced should remain with unstable and versioned?

Yes, those can stay. Other signals are similar.

mart updated this revision to Diff 20584.Oct 11 2017, 9:10 AM
  • update to the upstream xml protocol
Restricted Application edited projects, added Plasma on Wayland; removed Plasma. · View Herald TranscriptOct 11 2017, 9:10 AM
mart added a comment.Oct 11 2017, 9:12 AM
In D7369#153978, @mart wrote:

Documentation is still missing, Unstable suffix is still in two many API calls.

i think the importerUnstableV2Announced exporterUnstableV2Announced should remain with unstable and versioned?

Yes, those can stay. Other signals are similar.

so how is the current state, can go in? (btw, the unstable-v2 protocol was just pushed to master, so another roadblock done)

There is still quite some documentation missing. Especially the server side is not yet documented enough that I would know how to use the new API and what it does. It's totally fine to copy and adapt the documentation from the Wayland xml protocol.

src/client/xdgforeign.h
117 ↗(On Diff #18767)

Please add documentation

209 ↗(On Diff #18767)

Please add documentation

269 ↗(On Diff #18767)

what's the handle?

328 ↗(On Diff #18767)

please add documentation

src/server/xdgforeign_interface.h
39 ↗(On Diff #18767)

This needs documentation

46–47 ↗(On Diff #18767)

Please add documentation? I wouldn't know what create is needed for.

50 ↗(On Diff #18767)

did set "what"?

mart updated this revision to Diff 20638.Oct 12 2017, 12:51 PM
  • documentation++
  • name the methods exportTopLevel/importTopLevel
Restricted Application edited projects, added Plasma; removed Plasma on Wayland. · View Herald TranscriptOct 12 2017, 12:51 PM
mart updated this revision to Diff 20639.Oct 12 2017, 1:01 PM
mart marked 7 inline comments as done.
  • more documentation
Restricted Application edited projects, added Plasma on Wayland; removed Plasma. · View Herald TranscriptOct 12 2017, 1:01 PM
graesslin accepted this revision.Oct 12 2017, 3:39 PM
This revision was automatically updated to reflect the committed changes.