-
Notifications
You must be signed in to change notification settings - Fork 3.2k
wayland: switch to separate queue for wp_image_description_v1 #16844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Download the artifacts for this pull request: Windows |
This should not be needed. clipboard has a separate wl_display and queue and does not share a wl_display or queue with VO. |
You're right. Though I think it's still a good idea to create our own named queue for consistency, but I'll let the maintainers decide. |
11e3f80 to
6b18e55
Compare
e0a67ae to
81be00c
Compare
|
Dropped everything here except what's strictly needed to fix the issue, though I'd still prefer to name our queues because that's useful when looking at WAYLAND_DEBUG output but I don't want to stall this too long for that |
81be00c to
2e61ffe
Compare
|
A round trip does not guarantee that the image description is ready. |
Do I need to |
|
We already make the assumption in several places that a roundtrip will result in several wayland events being processed. |
2e61ffe to
0f6c06b
Compare
|
One problem now that I just realized. The |
Are you sure? wp_image_description_info_v1.done is still on the default queue |
|
Oh my bad, got |
Yes.
Some protocols guarantee that but this one does not. |
|
I'm not sure I understand how wl_display_dispatch_queue and waiting is any different than doing the roundtrip on the queue. The roundtrip internally does wl_display_dispatch_queue and waits for a callback so it should be the same thing no? |
|
wl_display_dispatch_queue needs to be called in a loop. |
|
That's what wl_display_roundtrip_queue does though. |
|
The loop in wl_display_roundtrip_queue can end before the image description is ready. |
|
Isn't setting the sync_listener supposed to ensure that everything beforehand is processed since the done is supposed to be the very last reply. |
|
It guarantees the the compositor has handled all messages sent before then. But the compositor is not required to respond to a wp_image_description_creator_params_v1_create request immediately. |
0f6c06b to
44b0b3b
Compare
|
Switched it back to the |
| wl->image_desc_done = false; | ||
| wp_image_description_v1_add_listener(image_description, &image_description_listener, wl); | ||
|
|
||
| /* Block here to ensure the compositor is ready to receive the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we instead of blocking thread, react in the callback and do rest of the work when compositor is ready for it? Blocking and callbacks generally doesn't go together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what happens before this MR. If we don't block here then we need some other syncing primitive in vo.c's render_frame to wait after draw_frame before calling flip_page.
As I've already said before, this only happens on the very first frame mpv displays for each file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm too be honest, I don't really like this hard block here. A roundtrip is fine but since evidentially that is not sufficient, putting this while loop here doesn't feel very good. e.g. what if the compositor never gives us this event. Sure it would be bad behavior but that means we would spin here forever.
Don't have any concrete suggestions at this time though. Maybe something like how we wait for frame callback needs to be done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the compositor never gives us this event
It is guaranteed that the compositor will give us this event eventually by the protocol. Any compositor where this takes long enough for it to get noticeable for the end user is severely buggy and not our responsibility.
Of course compositor can be buggy and violate the protocol and actually never give us this event, then there will be no mpv window when opening a video with dmabuf-wayland and it will be very obvious what the cause is from WAYLAND_DEBUG logs.
Keep in mind that if the compositor never gives us this event on master, what will happen is that dmabuf-wayland will continue to display video but never set any metadata for it and the user would have no clue why.
I'm personally fine with a hard block here, since it only happens at the start of playback one time. But we can return to the roundtrip version if you prefer since in practice most compositors won't wait more than a roundtrip, I verified that a roundtrip will be sufficient for Kwin/wlroots compositors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do a roundtrip and the event has not yet arrived, the process will be aborted when the event arrives after you've destroyed the queue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep the queue around then
Sorry, I know I'm probably coming off as argumentative here, but I'm just trying to understand this. The documentation for
To me, this sounds like exactly what we need. We add the image description listener in its own separate queue first, send the request and then wait for it to reply back. It doesn't need to be immediate or anything. The point is to block until the server replies to us. The only request in this queue is the image description one so surely the compositor has to handle our request. Is it possible for the compositor to "reply" in this case but somehow the reply isn't sending us either the failed/ready event (or protocol error)? If so, that seems quite unexpected and unintuitive with how everything else (AFAIK) works. |
"processed" only means that the compositor has seen all previously sent requests not that it has taken any positive action beyond that. For example, if you send wl_surface.attach, wl_surface.frame, wl_surface.commit, roundtrip, then the roundtrip will complete immediately but the response to the frame request might only arrive much later when the next vblank happens. Queues are a purely client-side construct. The compositor is not aware of them. |
If I am reading the document correctly, |
It's explained in the last comment, "processed" means the compositor has seen all the requests made by client. This specific protocol doesn't guarantee that it'll respond immediately. |
44b0b3b to
9a91a28
Compare
f0883cd fixed the issue that `set_color_management` would be called on every frame, however it didn't fix the problem that the first frame would have no image description set. Due to a lack of blocking here, events would end up happening in the following order: -> wl_surface.commit() -> wp_color_management_surface_v1.set_image_description(...) -> wl_surface.commit() -> wp_color_management_surface_v1.set_image_description(...) This would mean setting image description would always lag behind by 1 surface commit. This would effectively result in the first frame never having any image description set. Fix this by blocking until the compositor processes what's in the queue and responds with the ready event so we can set the image description.
9a91a28 to
554684d
Compare
Based on #16836
This is theoretically more correct