Mir

Merge lp:~vanvugt/mir/fix-1315302 into lp:mir

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/fix-1315302
Merge into: lp:mir
Diff against target: 127 lines (+43/-7)
3 files modified
src/server/compositor/switching_bundle.cpp (+8/-5)
src/server/compositor/switching_bundle.h (+4/-2)
tests/unit-tests/compositor/test_switching_bundle.cpp (+31/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1315302
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
Robert Carr (community) Approve
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+218029@code.launchpad.net

Commit message

Ensure that if you have multiple client_acquire's outstanding, they each
get called back, eventually (LP: #1315302)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~vanvugt/mir/fix-1315302 updated
1593. By Daniel van Vugt

Merge latest development-branch

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM.

Nit:
+ std::deque<Callback> client_acquires_todo;

client_acquire_completions reads better to me.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Since the alternate implementation has been merged I've rebased this fix here:

https://code.launchpad.net/~mir-team/mir/fix-1315302/+merge/218348

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

Yeah this needs rewriting now BufferQueue has landed.

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

Rejected. The alternate fix has landed.

Unmerged revisions

1593. By Daniel van Vugt

Merge latest development-branch

1592. By Daniel van Vugt

Correct comment

1591. By Daniel van Vugt

Enable the failing test and fix it, using a queue of callbacks.

1590. By Daniel van Vugt

Add a regression test for LP: #1315302, currently failing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/compositor/switching_bundle.cpp'
--- src/server/compositor/switching_bundle.cpp 2014-04-15 05:31:19 +0000
+++ src/server/compositor/switching_bundle.cpp 2014-05-05 04:09:18 +0000
@@ -205,10 +205,10 @@
205 return nfree() >= min_free;205 return nfree() >= min_free;
206}206}
207207
208void mc::SwitchingBundle::client_acquire(std::function<void(graphics::Buffer* buffer)> complete)208void mc::SwitchingBundle::client_acquire(Callback complete)
209{209{
210 std::unique_lock<std::mutex> lock(guard);210 std::unique_lock<std::mutex> lock(guard);
211 client_acquire_todo = std::move(complete);211 client_acquires_todo.push_back(std::move(complete));
212212
213 if ((framedropping || force_drop) && nbuffers > 1)213 if ((framedropping || force_drop) && nbuffers > 1)
214 {214 {
@@ -230,7 +230,8 @@
230230
231void mc::SwitchingBundle::complete_client_acquire(std::unique_lock<std::mutex> lock)231void mc::SwitchingBundle::complete_client_acquire(std::unique_lock<std::mutex> lock)
232{232{
233 auto complete = std::move(client_acquire_todo);233 auto complete = std::move(client_acquires_todo.front());
234 client_acquires_todo.pop_front();
234235
235 if ((framedropping || force_drop) && nbuffers > 1)236 if ((framedropping || force_drop) && nbuffers > 1)
236 {237 {
@@ -381,8 +382,10 @@
381 ncompositors--;382 ncompositors--;
382 }383 }
383384
384 if (client_buffers_available(lock) && client_acquire_todo)385 if (client_buffers_available(lock) && !client_acquires_todo.empty())
386 {
385 complete_client_acquire(std::move(lock));387 complete_client_acquire(std::move(lock));
388 }
386 }389 }
387}390}
388391
@@ -435,7 +438,7 @@
435void mc::SwitchingBundle::force_requests_to_complete()438void mc::SwitchingBundle::force_requests_to_complete()
436{439{
437 std::unique_lock<std::mutex> lock(guard);440 std::unique_lock<std::mutex> lock(guard);
438 if (client_acquire_todo)441 if (!client_acquires_todo.empty())
439 {442 {
440 drop_frames(nready);443 drop_frames(nready);
441 force_drop = nbuffers + 1;444 force_drop = nbuffers + 1;
442445
=== modified file 'src/server/compositor/switching_bundle.h'
--- src/server/compositor/switching_bundle.h 2014-03-26 05:48:59 +0000
+++ src/server/compositor/switching_bundle.h 2014-05-05 04:09:18 +0000
@@ -26,6 +26,7 @@
26#include <memory>26#include <memory>
27#include <iosfwd>27#include <iosfwd>
28#include <unordered_set>28#include <unordered_set>
29#include <deque>
2930
30namespace mir31namespace mir
31{32{
@@ -41,6 +42,7 @@
41{42{
42public:43public:
43 enum {min_buffers = 1, max_buffers = 5};44 enum {min_buffers = 1, max_buffers = 5};
45 typedef std::function<void(graphics::Buffer* buffer)> Callback;
4446
45 SwitchingBundle(int nbuffers,47 SwitchingBundle(int nbuffers,
46 const std::shared_ptr<graphics::GraphicBufferAllocator> &,48 const std::shared_ptr<graphics::GraphicBufferAllocator> &,
@@ -50,7 +52,7 @@
5052
51 graphics::BufferProperties properties() const;53 graphics::BufferProperties properties() const;
5254
53 void client_acquire(std::function<void(graphics::Buffer* buffer)> complete) override;55 void client_acquire(Callback complete) override;
54 void client_release(graphics::Buffer* buffer);56 void client_release(graphics::Buffer* buffer);
55 std::shared_ptr<graphics::Buffer>57 std::shared_ptr<graphics::Buffer>
56 compositor_acquire(void const* user_id) override;58 compositor_acquire(void const* user_id) override;
@@ -111,7 +113,7 @@
111 bool framedropping;113 bool framedropping;
112 int force_drop;114 int force_drop;
113115
114 std::function<void(graphics::Buffer* buffer)> client_acquire_todo;116 std::deque<Callback> client_acquires_todo;
115117
116 friend std::ostream& operator<<(std::ostream& os, const SwitchingBundle& bundle);118 friend std::ostream& operator<<(std::ostream& os, const SwitchingBundle& bundle);
117};119};
118120
=== modified file 'tests/unit-tests/compositor/test_switching_bundle.cpp'
--- tests/unit-tests/compositor/test_switching_bundle.cpp 2014-04-15 05:31:19 +0000
+++ tests/unit-tests/compositor/test_switching_bundle.cpp 2014-05-05 04:09:18 +0000
@@ -254,6 +254,37 @@
254 }254 }
255}255}
256256
257TEST_F(SwitchingBundleTest, clients_can_acquire_multiple_buffers)
258{ // Regression test for LP: #1315302
259 int const nbuffers = 3;
260 mc::SwitchingBundle bundle(nbuffers, allocator, basic_properties);
261
262 for (int i = 0; i < nbuffers; ++i)
263 bundle.client_release(client_acquire_blocking(bundle));
264
265 mg::Buffer* acquired1 = nullptr;
266 bundle.client_acquire([&](mg::Buffer* buffer)
267 {
268 acquired1 = buffer;
269 });
270
271 mg::Buffer* acquired2 = nullptr;
272 bundle.client_acquire([&](mg::Buffer* buffer)
273 {
274 acquired2 = buffer;
275 });
276
277 for (int i = 0; i < nbuffers+2; ++i)
278 bundle.compositor_release(bundle.compositor_acquire(this));
279
280 EXPECT_NE(acquired1, acquired2);
281 ASSERT_NE(nullptr, acquired2);
282 ASSERT_NE(nullptr, acquired1);
283
284 bundle.client_release(acquired1);
285 bundle.client_release(acquired2);
286}
287
257TEST_F(SwitchingBundleTest, compositor_acquire_basic)288TEST_F(SwitchingBundleTest, compositor_acquire_basic)
258{289{
259 for (int nbuffers = mc::SwitchingBundle::min_buffers;290 for (int nbuffers = mc::SwitchingBundle::min_buffers;

Subscribers

People subscribed via source and target branches