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
1=== modified file 'src/server/compositor/switching_bundle.cpp'
2--- src/server/compositor/switching_bundle.cpp 2014-04-15 05:31:19 +0000
3+++ src/server/compositor/switching_bundle.cpp 2014-05-05 04:09:18 +0000
4@@ -205,10 +205,10 @@
5 return nfree() >= min_free;
6 }
7
8-void mc::SwitchingBundle::client_acquire(std::function<void(graphics::Buffer* buffer)> complete)
9+void mc::SwitchingBundle::client_acquire(Callback complete)
10 {
11 std::unique_lock<std::mutex> lock(guard);
12- client_acquire_todo = std::move(complete);
13+ client_acquires_todo.push_back(std::move(complete));
14
15 if ((framedropping || force_drop) && nbuffers > 1)
16 {
17@@ -230,7 +230,8 @@
18
19 void mc::SwitchingBundle::complete_client_acquire(std::unique_lock<std::mutex> lock)
20 {
21- auto complete = std::move(client_acquire_todo);
22+ auto complete = std::move(client_acquires_todo.front());
23+ client_acquires_todo.pop_front();
24
25 if ((framedropping || force_drop) && nbuffers > 1)
26 {
27@@ -381,8 +382,10 @@
28 ncompositors--;
29 }
30
31- if (client_buffers_available(lock) && client_acquire_todo)
32+ if (client_buffers_available(lock) && !client_acquires_todo.empty())
33+ {
34 complete_client_acquire(std::move(lock));
35+ }
36 }
37 }
38
39@@ -435,7 +438,7 @@
40 void mc::SwitchingBundle::force_requests_to_complete()
41 {
42 std::unique_lock<std::mutex> lock(guard);
43- if (client_acquire_todo)
44+ if (!client_acquires_todo.empty())
45 {
46 drop_frames(nready);
47 force_drop = nbuffers + 1;
48
49=== modified file 'src/server/compositor/switching_bundle.h'
50--- src/server/compositor/switching_bundle.h 2014-03-26 05:48:59 +0000
51+++ src/server/compositor/switching_bundle.h 2014-05-05 04:09:18 +0000
52@@ -26,6 +26,7 @@
53 #include <memory>
54 #include <iosfwd>
55 #include <unordered_set>
56+#include <deque>
57
58 namespace mir
59 {
60@@ -41,6 +42,7 @@
61 {
62 public:
63 enum {min_buffers = 1, max_buffers = 5};
64+ typedef std::function<void(graphics::Buffer* buffer)> Callback;
65
66 SwitchingBundle(int nbuffers,
67 const std::shared_ptr<graphics::GraphicBufferAllocator> &,
68@@ -50,7 +52,7 @@
69
70 graphics::BufferProperties properties() const;
71
72- void client_acquire(std::function<void(graphics::Buffer* buffer)> complete) override;
73+ void client_acquire(Callback complete) override;
74 void client_release(graphics::Buffer* buffer);
75 std::shared_ptr<graphics::Buffer>
76 compositor_acquire(void const* user_id) override;
77@@ -111,7 +113,7 @@
78 bool framedropping;
79 int force_drop;
80
81- std::function<void(graphics::Buffer* buffer)> client_acquire_todo;
82+ std::deque<Callback> client_acquires_todo;
83
84 friend std::ostream& operator<<(std::ostream& os, const SwitchingBundle& bundle);
85 };
86
87=== modified file 'tests/unit-tests/compositor/test_switching_bundle.cpp'
88--- tests/unit-tests/compositor/test_switching_bundle.cpp 2014-04-15 05:31:19 +0000
89+++ tests/unit-tests/compositor/test_switching_bundle.cpp 2014-05-05 04:09:18 +0000
90@@ -254,6 +254,37 @@
91 }
92 }
93
94+TEST_F(SwitchingBundleTest, clients_can_acquire_multiple_buffers)
95+{ // Regression test for LP: #1315302
96+ int const nbuffers = 3;
97+ mc::SwitchingBundle bundle(nbuffers, allocator, basic_properties);
98+
99+ for (int i = 0; i < nbuffers; ++i)
100+ bundle.client_release(client_acquire_blocking(bundle));
101+
102+ mg::Buffer* acquired1 = nullptr;
103+ bundle.client_acquire([&](mg::Buffer* buffer)
104+ {
105+ acquired1 = buffer;
106+ });
107+
108+ mg::Buffer* acquired2 = nullptr;
109+ bundle.client_acquire([&](mg::Buffer* buffer)
110+ {
111+ acquired2 = buffer;
112+ });
113+
114+ for (int i = 0; i < nbuffers+2; ++i)
115+ bundle.compositor_release(bundle.compositor_acquire(this));
116+
117+ EXPECT_NE(acquired1, acquired2);
118+ ASSERT_NE(nullptr, acquired2);
119+ ASSERT_NE(nullptr, acquired1);
120+
121+ bundle.client_release(acquired1);
122+ bundle.client_release(acquired2);
123+}
124+
125 TEST_F(SwitchingBundleTest, compositor_acquire_basic)
126 {
127 for (int nbuffers = mc::SwitchingBundle::min_buffers;

Subscribers

People subscribed via source and target branches