-
Notifications
You must be signed in to change notification settings - Fork 123
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
backend: fix prepare_read behavior #650
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #650 +/- ##
==========================================
+ Coverage 73.09% 73.11% +0.02%
==========================================
Files 47 47
Lines 7711 7691 -20
==========================================
- Hits 5636 5623 -13
+ Misses 2075 2068 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
Probably the same about #[must_use]
for other methods. Also, maybe we should use Result
instead, but use some io
type to indicate that lock can't be acquired? The mutex stuff uses Result
and it's more intuitive than the Option
.
if let Some(guard) = self.backend.prepare_read() { | ||
dispatched += blocking_read(guard)?; | ||
} else { | ||
dispatched += self.backend.dispatch_inner_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.
Hm, but you could have a blocking dispatch of the queue here as well? Non-blocking roundtrip doesn't sound like it'll work reliably or I don't understand something?
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.
This is in a loop, so it'll just try again at the next iteration.
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.
Ah, yeah, sure, I just know that there's mo efficient API to do the exact same thing, but I think it's not an option for us. The wl_display_dispatch_queue
https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__display_1ae027b09801474ac7c6b0f1ef25ff6e17
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 function in wayland-client does mostly exactly the same thing as wl_display_roundtrip
, but implemented in terms of wayland-backend's API, so I don't really get your point?
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.
wl_display_roundtrip
uses poll
under the hood to not do the loop.
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... ?
wl_display_roundtrip
does have a loop: https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/src/wayland-client.c#L1402
and blocking_read
uses poll
internally: https://github.com/Smithay/wayland-rs/blob/master/wayland-client/src/conn.rs#L224-L245
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.
@elinorbgr if you look closely what their code is and what we have, they use blocking dispatch. However we use it only in read_guard
branch, and the other branch is using regular non-blocking dispatch.
So while they have a loop
, the wait
, but we busy loop
from the else
. The blocking read is fine, the else
is a busy loop. dispatch_inner_queue
is a non_blocking API from what I can, see, but libwayland always using blocking API, with dispatch_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.
After reading the libwayland impl it's pretty much the same, when their docs are not really clear what exactly blocks and how it works.
e0372d0
to
3c0e2be
Compare
3c0e2be
to
1a7d18f
Compare
Not sure what we would gain from this? It feels to me that this |
1a7d18f
to
99876ca
Compare
99876ca
to
69eae18
Compare
This should fix the multithreading issues that have been encountered.
cc @kchibisov