Repository navigation
Some Wayland fixes - #18888
Some Wayland fixes#18888llyyr wants to merge 14 commits into
Conversation
No. mpv has no duty to comply. The Wayland protocol is very clear about this: the event "asks" the client to resize its surface, and that the width and height arguments specify a "hint" only. The window surface is the responsibility of the client, and the server has no say on this matter. |
|
Not everything needs to be explicitly spelled out in the spec. What possible use case could there be for a negative size that isn't a compositor bug? Can you point to a single implementation that sends negative configure not as a bug? Just because the spec doesn't explicitly say you may not dereference a NULL pointer doesn't mean you should go ahead and do it. https://gitlab.freedesktop.org/wayland/wayland-protocols/-/work_items/141 Negative dimensions have no defined meaning, and treating them as zero is just inventing semantics for invalid input. |
It looks like nothing has changed since my PR, the same arguments are still being used, so there is no need to repeat these again. I think this means there is no rationale for this change, which is a net negative anyway: in one case the player crashes and the user loses playback state, in another case it does not.
Then is should be formalized in the spec. That issue shows that I am not alone in this interpretation. Also, because mpv is free to do whatever thing it wants when the semantic is not defined, no behavior is inherently superior in the scope of Wayland protocol, so this is not an argument that the current behavior is "nonsense". |
It's not a net negative, this change hides compositor bugs. Negative configure size is considered a bug by every Wayland member, it's not up for argument that it's technically allowed. Only reason it's not explicitly written in the protocol is because it's obviously to everyone but you.
It's not because there's no need to do so, please find me a single client implementation that shares your interpretation.
That is an interesting interpretation of the issue. There's 3 participants, and none of them believe your interpretation is correct. Even the person opening the issue says: "Most usage of Wayland's protocols heavily imply that sizes of surfaces should not be negative, but nothing explicitly stated that is the expected behavior for configures." I don't believe such things need to be explicitly stated, unless you can state any use case where negative configure size makes sense and the client could have reasonable confusion about it. I was wrong to approve of the MR then, and allowing it to be merged has bothered me since and I want to revert it now. I don't think we should workaround broken compositors in mpv, there's no other code that is explicitly workaround for broken compositors. This is the positive rationale for this change. P.S.: If you find any code that's working around broken compositors, let me know. I'll fix the compositor and remove the workaround, but I'm not aware of any. |
|
The configure event says:
set_window_geometry says:
Therefore mpv cannot possibly ever set a negative size or zero size for the window geometry. This further specifies that negative configure sizes are not intended. |
mpv's job is being a media player. Its job is not exposing bugs in other programs. mpv is free to interpret the values in the scope of the Wayland standard. The standard does not currently determine which interpretation is correct. Also, the interpretation of the values depends on the state value. A newer version of the standard could add a state value that gives negative values a meaningful interpretation.
The broken thing is the Wayland standard here. Create a MR to make this explicit in the Wayland standard is the correct way to resolve this issue, and I will fully support this change once that goes in.
The values provided is a hint, the client ultimately decides what is used for |
|
You can waffle all you want, but I'm going not going to respond to any of that until you can respond to my original comment fully.
How is a negative value ever an intended hint when no client could possibly ever adhere to that hint? |
|
Added |
If you read the commit message, you'd realize that your fix only ever worked because sway is lenient and doesn't kill clients when it should. In the issue you were fixing, mpv receives The only reason your fix "worked" is because sway had another bug, that it's not raising this error.
I don't know what you're trying to say or what you're responding to.
I'm not going to respond because both are addressed in the commit message, which you clearly haven't read before responding.
Your interpretation is novel nonsense, I'll keep asking you to find me a single client or compositor that agrees with you if you want me to take anything you say seriously. |
Before this commit you have always said there is no need to fix this in the upstream because it's "obvious to everyone". It's only because I pushed for it that you decided to open the MR. I have no obligation to open that MR myself, neither do you. Open source contributors decide how and where they spend their time. You could have dismissed my commit based on technical arguments alone, with the 3 toplevel state cases violating the Wayland protocol, but clearly your interest is in somewhere else.
I can write one myself, but you will just dismiss it anyway. This is not a technical argument, and there is no need to engage with this kind of argument. The correct way is to fix it in the technical spec, which you did. |
I don't believe the clarification is needed. Feel free to also argue your point as if the amendment hasn't been made, I don't believe I need it to dismiss what you're saying.
Of course I would dismiss it, the whole premise of me asking for it is to show that something else in the real world shares the same belief as you. If you're the author of this example client, then obviously that isn't proved. Why would you even state this as a point?
There is no need to engage with bad faith actors such as yourself, correct.
I only made made the fix because it's obviously easier for everyone if it's stated explicitly, instead of requiring brain power to reach the same conclusion. However, I don't believe the clarification changes the outcome |
Dudemanguy
left a comment
There was a problem hiding this comment.
Ehhh I personally don't really like the needless aggression with the wording in xdg-shell commit but you fixed the spec so sure let's revert it. Anyway changes LGTM
kasper93
left a comment
There was a problem hiding this comment.
Ehhh I personally don't really like the needless aggression with the wording in xdg-shell commit
I agree with @Dudemanguy.
| cat ./build/meson-logs/meson-log.txt | ||
|
|
||
| linux-ffmpeg-6-1: | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
This commit does three things in single commit
- changes CI configuration
- removes unused code
- moves meson definitions
- and finally bumps requirement
Do you think it has to be in single commit?
There was a problem hiding this comment.
This commit got dropped, but to answer the question I'd split ci changes to its own commit because it might need to be reverted or referenced on its own later. The rest is fine in a single commit, because it's super small as is.
| container: | ||
| # We want to test ffmpeg 6.1.2, which Alpine 3.21 includes. | ||
| # Also test compatibility with Wayland Protocols 1.38 and Wayland libs 1.23. | ||
| # Also test compatibility with Wayland Protocols >=1.47 and Wayland libs 1.23. |
There was a problem hiding this comment.
This is not accurate, this job is meant to test exact version. And since Alpine 3.24 has wp 1.48, the 1.47 is currently not tested by any configuration.
There was a problem hiding this comment.
Dropped this commit, but if we want to be testing exact version on ci it's kind of painful. We'll run into this whenever we do a bump next, so we'll have to consider how to do this.
I think we should just vendor the xmls in mpv, no point having a dependency like this which just adds complexity that's easily avoided
|
|
||
| linux-ffmpeg-6-1: | ||
| runs-on: ubuntu-latest | ||
| container: |
There was a problem hiding this comment.
Debian Stable has 1.50
What did you get this? Debian stable has 1.44, with trixie-backports that user can enable up to 1.47.
Ubuntu LTS has 1.47.
Be specific here about version, Ubuntu LTS has 1.25, 1.45, 1.47, in supported versions. Generally we support two most recent LTS.
There was a problem hiding this comment.
My bad I thought Debian 14 was out already but indeed 13 is the latest one. I'll drop this commit.
Generally we support two most recent LTS.
This is not true, we usually support the latest LTS of Debian and Ubuntu, whichever is older.
| struct vo_wayland_output *o; | ||
| wl_list_for_each(o, &wl->output_list, link) { | ||
| if (o->output == output) { | ||
| o->has_surface = true; |
There was a problem hiding this comment.
Cosmetic changes like this shouldn't be in the same commit.
There was a problem hiding this comment.
This commit got reworked, so this review is stale now. But to answer the question, it's cosmetic change on a block that was already functionally changed by the commit. I think it's fine for it to be in the same commit.
|
|
||
| int outputs = 0; | ||
| struct vo_wayland_output *o; | ||
| wl_list_for_each(o, &wl->output_list, link) { |
There was a problem hiding this comment.
This commit is confusing. Why you move half of the duplication into the helper and leave the rest of the duplication in the function leave/enter functions? It makes things less readable imho.
| struct vo_wayland_output *output; | ||
| wl_list_for_each(output, &wl->output_list, link) { | ||
| if (output->id == id) { | ||
| bool affected = output->has_surface || wl->current_output == output; |
There was a problem hiding this comment.
When it's possible to have !output->has_surface and wl->current_output == output?
There was a problem hiding this comment.
When mpv first starts, it selects an output for geometry/screen/screen-name option purposes before it's actually entered any output. It can have current_output while also not having a surface.
| @@ -3614,13 +3614,13 @@ static void remove_seat(struct vo_wayland_seat *seat) | |||
| if (seat == seat->wl->last_button_seat) | |||
| seat->wl->last_button_seat = NULL; | |||
| if (seat->keyboard) | |||
There was a problem hiding this comment.
You can just call seat_handle_caps(seat, seat->seat, 0); to avoid manually clearing all related capabilities states.
There was a problem hiding this comment.
Not a fan of this since seat_handle_caps could do other things in caps=0 path in the future, but done
| #include "vo.h" | ||
| #include "xdg-activation-v1.h" | ||
|
|
||
| #define WL_RELEASE_OR_DESTROY(type, object, since) do { \ |
There was a problem hiding this comment.
Don't steal the WL_ namespace for custom macros. Also you can drop the typed local variable and just call it directly.
#define WL_RELEASE_OR_DESTROY(type, object, since) \
(type##_get_version(object) >= (since) ? type##_release : type##_destroy)(object)
There was a problem hiding this comment.
Prepended MP_ and copied your version
We only bind if WL_FIXES_ACK_GLOBAL_REMOVE is available, since we don't care about version 1 for anything. Fix the guard for consistency.
The safe iterator is only for safe iteration after removing the current element. Since we're only ever expected to get registry global_remove one at a time, and we exit the loop on the first item, no need to use the safe iterator.
With sufficiently large --wayland-edge-pixels-{pointer,touch} and
sufficiently small mpv window, it was possible to have edge pixels
larger than the mpv window itself. In that case, we'd pick mutually
exclusive resizes edges and get disconnected by the compositor.
It's still user error to set those kinds of values, but at least mpv
shouldn't do something illegal.
This could apply pending viewport to old buffer or mark old frame opaque before its replacement is drawn. Or commit some other pending state that's not supposed to be committed yet. It's upto VOs to request redraw when render opts change. Don't commit opaque region changes so the next swap commits it with new buffer.
Output may send done after some other property changes, without sending a mode event again. Don't set the mode directly to wl->geometry otherwise we might add x0/y0 or apply rotation multiple times
Repeated wl_output.geometry events kept old make and model strings allocated until wayland uninit. Use ta_replace instead of allocating new strings, and parent them all to vo_wayland_output instead of vo_wayland_state. Also initialize the strings to empty values, so logs and find_output don't require multiple guards to use them before outputs are configured. This can happen on master and causes a crash when the output mpv is out disappears.
The cursor shape device becomes inert when the seat loses pointer capability. Destroy it so mpv creates a new one when pointer capability returns.
Use `wl_*_release` requests so the compositor can free resources when an output, input capability, or seat is removed. Calling only the client-side `wl_*_destroy` frees the proxy but the server-side resource lives until the connection is closed. Data devices don't need the destroy path, because the lowest version we bind to already has release request.
|
Please give me an example or two of specifically what you found aggressive in the xdg-shell commit, so I can reword it |
Storing them as their scaled values left stale values in use after a scale change.
Fixes UAF when the output mpv is on disappears... How did no one notice?
A surface can already span another output when the current one is removed. Select the remaining output that contains the surface, or clear the selection if none remain.
Eh honestly most of the stuff in the "commentary". Like this paragraph in particular,
It's just unnecessary ranting imo. I personally would just keep the first paragraph:
Then after that just briefly say how now the spec explicitly forbids it and there is doubly no reason to have the commit. |
I can delete the commentary part as long as we can agree that we shouldn't merge commits like that one in mpv in the future. I don't want mpv to gain reputation that anyone who finds some contradiction or mistake in spec can come and merge their change in mpv to protest against whatever $technology they're not a fan of. Doesn't matter if it's Wayland or vulkan or opengl, or whatever other specified API mpv uses. |
|
I'm not sure why you're making a mountain out of an ant hill. I only merged that commit because it was a harmless "why not". Maybe it would have been better to fix the spec instead but it's really not a big deal. |
I'm not making a mountain out of an ant hill. This particular contributor has a reputation of this. If you remember #14210 #14803, there are probably other examples too that I'm not remembering off the top of my head. This commit message didn't come out of nowhere, it's repeated behavior I've been seeing from nanahi and mpv maintainers constantly tolerating it |
|
Why are you turning this PR into your personal crusade against someone else? It's good set of fixes to the wayland code so let's just keep it as that. OK nanahi clashed with upstream wayland maybe 2-3 times in the past couple of years over some disagreements on how to interpret some things. Is this really such a huge deal? I think I was the one that merged them all so feel free to blame me too. In the end, things were fixed on both sides and got better so it seems like the net result is positive anyway. If you have some continued issue with him, feel free to send him messages via whatever channel is appropriate. Scolding in project commit messages is obviously not the way to go. |
This reverts commit 146bef0. There was never a compositor identified that actually sent these negative values and didn't consider them a bug. The whole premise of this commit was that a compositor could be perfectly valid in sending configure (-1, -1) because it wasn't explicitly forbidden from doing so, even though there was no way for any client to ever possibly comply with that request. Even if the premise is to be accepted that negative values are allowed by the protocol, then it must also be the case that mpv must also comply with the negative size hints. Certain xdg_toplevel.state enums have their own additional requirements on top of the text in the configure event. Such as: - maximized state requires that the window geometry specified in the configure event _must_ be obeyed by the client, or the invalid_surface_error is raised. By this, mpv must be killed by any compositor if it sends a negative configure size. 146bef0 treats them as zero, which is explicitly forbidden. - fullscreen state says that the window geometry specified in the configure event is a maximum; the client cannot resize beyond it. By this, mpv must also violate the specification if a compositor sends a negative configure size. 146bef0 treats them as zero, which is beyond the maximum negative size specified in the configure event. - resizing state says the same as the fullscreen state, and mpv would be violating the spec on negative configure size for the same reason as well. With 146bef0, mpv would try to size itself however it wants, and end up not satisfying protocol requirements if it's maximized, fullscreen or resizing. There were already multiple reasons besides just that why it was possible to deduce that it was not valid to send negative configure sizes, even if the protocol text was admittedly not as tight as it could be for states not mentioned above. For one, even if the size hint is only a recommendation, it's useless to make a recommendation that cannot be followed by clients under any circumstances whatsoever. Even 146bef0 didn't try to make mpv size to negative surface sizes (How would you?), it simply ignored negative configure sizes if it got them and treated it as if the compositor sent configure (0, 0) and scaled itself however it wanted. From this, one might infer that configure events can't be negative, even if it's not explicitly stated for the particular state (at that time). It has since been made explicit*, even though I have yet to be shown a single client or compositor that had this particular interpretation of the protocol text before the protocol forbid negative sizes explicitly. * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/commit/309f384d8811c424cee01fd91612c0c1b176ae36
|
Dropped the non technical part of the message.
I reject this framing. You can have disagree with opinions, you can't disagree with facts. When the intended interpretation is being offered to you on a silver platter, and you reject it, it is not a disagreement.
I also reject this framing that the fixes on the protocol side were needed whatsoever, except to satisfy one client (mpv) with insane reading of the text. I still ask you to find me a single client or compositor that reads the text in the same way mpv does on master right now.
Only because I bothered to amend it on both sides. I will refer back to this discussion when this inevitably happens again and mpv merges some insane code based on insane reading of XML files. edit: I'll put some actionable thing here because my goal isn't to make conflict or admonish someone. All I ask is that if you have some disagreements about how something is to be interpreted, ask upstream first. If upstream takes too long to respond, then feel free to do whatever you want. You don't even need to ask it upstream yourself, if there's an open PR I'll do it, just wait some time before merging these things instead of instantly approving stuff. |
Good practice is to split the controversial changes into it's own PR where the discussion can be focused on one specific thing. It also makes reviewing easier, rather than looking at bundle of various things in the module. |
I didn't anticipate it would be a controversial change. In fact the original commit message was just a paragraph until discussion above this #18888 (comment) It's laughable that this is "controversial" |
Each commit is its own fix with the commit describing the fix, except the last 3