Mir

Merge lp:~albaguirre/mir/fix-not-compositing-last-client-posted-buffer into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1486
Proposed branch: lp:~albaguirre/mir/fix-not-compositing-last-client-posted-buffer
Merge into: lp:mir
Diff against target: 16 lines (+1/-1)
1 file modified
src/server/compositor/rendering_operator.cpp (+1/-1)
To merge this branch: bzr merge lp:~albaguirre/mir/fix-not-compositing-last-client-posted-buffer
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Review via email: mp+211593@code.launchpad.net

Commit message

Fix not compositing the client's last posted buffer (LP: #1294048, LP: #1294051, LP: #1294053, LP: #1290306, LP: #1293896)

In single-display cases the number of ready buffers decreases after a buffer is acquired by the rendering operator.
Determine if there will be uncomposited buffers before acquiring a buffer so it works for single and multi display use cases.

Description of the change

Fix not compositing the client's last posted buffer (LP: #1294048, LP: #1294051, LP: #1294053, LP: #1290306, LP: #1293896)

In single-display cases the number of ready buffers decreases after a buffer is acquired by the rendering operator.
Determine if there will be uncomposited buffers before acquiring a buffer so it works for single and multi display use cases.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Great!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

this might conflict with mir rev 1480 too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Nice catch.

I think it would be clearer to keep the statement at the end of the function and just change it from:
   uncomposited_buffers_ |= renderable.buffers_ready_for_compositor() > 1;
to:
   uncomposited_buffers_ |= renderable.buffers_ready_for_compositor() > 0;

Because I supposedly know how this stuff works and even I was tripped up when I first saw "> 1".

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I approve either solution because it's a critical bug. But I would prefer to see the "> 0" form.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> I approve either solution because it's a critical bug. But I would prefer to
> see the "> 0" form.

I arrived at the original form after checking the behavior on a multi-monitor setup. In that scenario buffers_ready_for_compositor() usually doesn't change between the start and end of this function. (When it does we see bug 290306.)

Hence I don't think that > 0 works in multi-montor setups.

I agree it is confusing that nready is updated differently in single and multi-montor configurations.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Sounds like we might be racing compositor threads in using "buffers_ready_for_compositor". But I'm not yet sure how.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Sounds like we might be racing compositor threads in using
> "buffers_ready_for_compositor". But I'm not yet sure how.

The race that leads to bug 290306 is that in multi-monitor the client thread can update nready after the composite and before the (original) call to buffers_ready_for_compositor(). Moving the call avoids this and AFAICS give correct results on both single and multi-montor setups.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

My concern is that the result of buffers_ready_for_compositor() changes depending on how many threads/monitors there are. This is dangerous unless what you're suggesting has somehow resolved that danger. I'm not sure.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Incidentally, I'm working on a separate proposal that would resolve the raciness (if any). So we don't need to block on it. Just be concerned until proven otherwise.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

The worst case with this proposal is that:

1. compositor A renders the first of two ready buffers
2. compositor B sees "2" and sets uncomposited_buffers_
3. the client takes the buffer and nready is decremented
4. compositor B composites the second buffer

For compositor B uncomposited_buffers_ is now set unnecessarily and an unnecessary composite pass happens. Not perfect, but not a serious problem.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Top approving as Daniel and I are probably the most familiar with this code and we've both decided its good enough. (And it is already -r 1181 on trunk)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/rendering_operator.cpp'
2--- src/server/compositor/rendering_operator.cpp 2014-03-13 00:13:17 +0000
3+++ src/server/compositor/rendering_operator.cpp 2014-03-19 00:23:05 +0000
4@@ -33,11 +33,11 @@
5
6 void mc::RenderingOperator::operator()(graphics::Renderable const& renderable)
7 {
8+ uncomposited_buffers_ |= renderable.buffers_ready_for_compositor() > 1;
9 auto compositor_buffer = renderable.buffer(frameno);
10 // preserves buffers used in rendering until after post_update()
11 saved_resources.push_back(compositor_buffer);
12 renderer.render(renderable, *compositor_buffer);
13- uncomposited_buffers_ |= renderable.buffers_ready_for_compositor() > 1;
14 }
15
16 bool mc::RenderingOperator::uncomposited_buffers() const

Subscribers

People subscribed via source and target branches