-
Notifications
You must be signed in to change notification settings - Fork 207
support delayed blocker #1720
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?
support delayed blocker #1720
Conversation
d125eef
to
2c2ec49
Compare
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.
Only a cursory glance for now; will have to see how it looks in niri to give proper feedback.
ready_transactions.push(self.transactions.remove(i)); | ||
let transaction = &mut self.transactions[i]; | ||
|
||
transaction.notify_blockers(); |
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.
Won't this get called over and over after the immediate blockers are done but before the delayed blockers are done?
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.
Depends on the impl of the delayed blocker and the precense of other delayed blockers. It could unblock from within notify and if it is the last one it would not be called again. But yes, it could get notified multiple times until the transaction completed. Maybe something worth documenting on the notify function. Just FYI, I also evaluated a design based on a callback which could place additional blockers but that had its own shortcomings.
{ | ||
let signaled = self.ready.swap(true, std::sync::atomic::Ordering::Acquire); | ||
if !signaled { | ||
self.ping.ping(); |
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.
IIRC in niri I didn't use the Ping source for the actual ready notification because it would arrive only on the next event loop iteration. I'm not sure if this is a problem 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.
Interesting. I am also not sure this is a problem in this case. We could use a channel instead maybe?
2c2ec49
to
3f660ed
Compare
This PR extends the existing
Blocker
API with aBlockerKind
. Allowing to put blockers into two groups,Immediate
andDelayed
.Blocker
s withBlockerKind::Delayed
will only be evaluated once allImmediate
have been cleared.After all
Immediate
blockers have been cleared allBlocker
s will be notified, allowing delayed blockers to make a decision based on that.All blockers still need to be cleared for the transaction to be unblocked.
Additionally the PR adds a reference implementation of a delayed blocker,
SurfaceBarrier
.One example for this is implementing animation transactions spanning multiple otherwise unrelated surfaces.
While this can be implemented without the
SurfaceBarrier
, it might help to enhance synchronization when some other blockers further delay the buffer.A compositor could place a
Immediate
blocker, like for example a simpleBarrier
, on each surface participating in the animation transaction and also register it in aSurfaceBarrier
with the same scope as the animation transaction.Once the
Immediate
blocker representing the transaction is cleared, the blocker in theSurfaceBarrier
will try to resolve and ping the compositor once it completed.cc @YaLTeR