Page MenuHomePhabricator

Bug 1743144 [Wayland] Implement Wayland proxy r?jld,emilio
ClosedPublic

Authored by stransky on Dec 15 2023, 1:56 PM.
Referenced Files
Unknown Object (File)
Tue, Oct 14, 11:42 PM
Unknown Object (File)
Sep 6 2025, 1:14 PM
Unknown Object (File)
Aug 6 2025, 12:30 AM
Unknown Object (File)
Aug 5 2025, 12:09 PM
Unknown Object (File)
Aug 2 2025, 2:52 AM
Unknown Object (File)
Aug 1 2025, 11:58 AM
Unknown Object (File)
Jul 29 2025, 4:07 AM
Unknown Object (File)
Jul 16 2025, 12:59 PM
Subscribers

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
widget/gtk/waylandProxy/moz.build
11 ↗(On Diff #800505)

Can we make the directory wayland-proxy too perhaps, for consistency?

widget/gtk/waylandProxy/wayland-proxy.h
14 ↗(On Diff #800505)

Maybe namespace mozilla::widget {

widget/gtk/waylandProxy/wayland-proxy.h
14 ↗(On Diff #800505)

I'd like to keep wayland-proxy as independent project and publish that on github so other Wayland project may include it too. So I've used only c++ code without any Mozilla internals and external libraries.

emilio requested changes to this revision.Dec 16 2023, 11:04 AM

I've done only a general review and haven't gotten to the nitty-gritty stuff, but I got enough comments that I think it's worth commenting.

widget/gtk/waylandProxy/wayland-proxy.cpp
1 ↗(On Diff #800505)

Did you meant to use tab-width: 20?

91 ↗(On Diff #800505)

Shouldn't we set mFailed = true; then return false; here?

160 ↗(On Diff #800505)

Is this just for debugging? If so should it be ifdef'd somehow?

469 ↗(On Diff #800505)

no else after return probably.

487 ↗(On Diff #800505)

no else after return.

widget/gtk/waylandProxy/wayland-proxy.h
14 ↗(On Diff #800505)

Okay, that explains a lot of the choices here :)

Can you make sure to document that, so that people sending patches here know that it's a bit different from the rest of the codebase?

36 ↗(On Diff #800505)

I don't think you intend to expose this to consumers more generally, so probably just forward-declare them here and move the code to the cpp file.

59 ↗(On Diff #800505)

nit: redundant, it's already private.

103 ↗(On Diff #800505)

If you're using the STL, why not just returning an std::unique_ptr<WaylandProxy> here?

Also it might be worth having some documentation on how is this expected to be used.

Similarly, this could probably be a static std::unique_ptr<WaylandProxy> Create(); in the proxy class.

105 ↗(On Diff #800505)

It seems these two functions could just be methods in WaylandProxy. In fact, what is the difference between WaylandProxyRunChildApplication(proxy, args) and proxy->RunChildApplication(args)?

107 ↗(On Diff #800505)

Maybe WaylandProxySetVerbose or something would be a bit clearer.

This revision now requires changes to proceed.Dec 16 2023, 11:04 AM

If this will be released on GitHub without modifications it might be worth putting it under third_party/ instead

If this will be released on GitHub without modifications it might be worth putting it under third_party/ instead

That's good point, will move it there.

widget/gtk/waylandProxy/wayland-proxy.h
14 ↗(On Diff #800505)

Will move it to third-party for clarity as Gabriele suggested.
Thanks.

stransky added inline comments.
widget/gtk/waylandProxy/wayland-proxy.cpp
1 ↗(On Diff #800505)

I just copied the header from another file without modifications. I see gecko has various headers with tab-width: 2, 20, 40.

stransky updated this revision to Diff 801162.
stransky marked an inline comment as done.

Code analysis found 1 defect in diff 803049:

  • 1 defect found by py-black (Mozlint)
IMPORTANT: Found 1 defect (error level) that must be fixed before landing.

You can run this analysis locally with:

  • ./mach lint --warnings --outgoing

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 803049.

emilio requested changes to this revision.Jan 3 2024, 12:46 PM

I think the message queue should at the very least use an std::deque. The rest of the comments are mostly nits. Looks good with that fixed from my perspective, though my socket-foo is a bit rusty / forgotten, so I can only say it looks sane.

third_party/wayland-proxy/wayland-proxy.cpp
80

const probably.

81

const

134

Maybe we should have some sort of arena / freelist for these for performance, if heap-allocation here is hurting us.

181

Maybe worth noting here that resize() is guaranteed to not invalidate mData, as per:

In case the container shrinks, all iterators, pointers and references to elements that have not been removed remain valid after the resize and refer to the same elements they were referring to before the call.

In https://cplusplus.com/reference/vector/vector/resize/

289

Should these be >=? I guess it's unlikely to get a 0 fd, but maybe possible if someone closes stdin / stdout / stderr?

299

!mToApplicationQueue.empty()

306

!mToCompositorQueue.empty()

415

This is more expensive than it needs to be because it shifts all the elements in the vector. Let's use an std::deque instead of an std::vector?

641

You can use auto here if you want.

645

if (mConnections.empty())

664

Probably be explicit about the memory orderings here, at the very least, this should be acquire, and the = false should use release.

third_party/wayland-proxy/wayland-proxy.h
40

More documentation on these would be nice, either here or in the cpp file.

This revision now requires changes to proceed.Jan 3 2024, 12:46 PM
stransky updated this revision to Diff 805657.
stransky marked 8 inline comments as done.
third_party/wayland-proxy/wayland-proxy.cpp
415

AFAIK std::deque is a kind of linked-list, right? I think it's better to just shift the pointers once here. Also from my testing FlushQueue() is not used at all as all messages are usually written in time.

testing-exception-other: this fixes crashes that are not really trivial to reproduce.

third_party/wayland-proxy/wayland-proxy.cpp
415

Not really, it's the equivalent to rust's VecDeque, it's an std::vector-like thing and has constant time random access, see https://en.cppreference.com/w/cpp/container/deque

But sure.

third_party/wayland-proxy/wayland-proxy.h
16

Probably remove this typedef from the header.

widget/gtk/moz.build
2

Please fix the lint.

This revision is now accepted and ready to land.Jan 8 2024, 9:36 PM
stransky marked 2 inline comments as done.