Mir

Merge lp:~kdub/mir/fix-silo0-1480418 into lp:~mir-team/mir/silo0

Proposed by Kevin DuBois
Status: Merged
Merged at revision: 2702
Proposed branch: lp:~kdub/mir/fix-silo0-1480418
Merge into: lp:~mir-team/mir/silo0
Diff against target: 63 lines (+39/-2)
2 files modified
src/server/compositor/multi_threaded_compositor.cpp (+2/-2)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+37/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-silo0-1480418
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+266926@code.launchpad.net

Commit message

When creating compositing threads, add the observer only after we're ready to service scheduling requests. Silo0's USC was resizing surfaces as a result of DisplayListerner::add_display, which would deadlock on schedule_frames. (essentially, a callback-with-held lock problem)

fixes: lp: #1481418

Description of the change

When creating compositing threads, add the observer only after we're ready to service scheduling requests. Silo0's USC was resizing surfaces as a result of DisplayListerner::add_display, which would deadlock on schedule_frames. (essentially, a callback-with-held lock problem)

fixes: lp: #1481418

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
2--- src/server/compositor/multi_threaded_compositor.cpp 2015-06-17 05:20:42 +0000
3+++ src/server/compositor/multi_threaded_compositor.cpp 2015-08-04 17:13:45 +0000
4@@ -300,12 +300,12 @@
5 destroy_compositing_threads(lk);
6 }};
7
8+ create_compositing_threads();
9+
10 lk.unlock();
11 scene->add_observer(observer);
12 lk.lock();
13
14- create_compositing_threads();
15-
16 /* Optional first render */
17 if (compose_on_start)
18 {
19
20=== modified file 'tests/unit-tests/compositor/test_multi_threaded_compositor.cpp'
21--- tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2015-06-17 05:20:42 +0000
22+++ tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2015-08-04 17:13:45 +0000
23@@ -847,3 +847,40 @@
24
25 compositor.start();
26 }
27+
28+//LP: 1481418
29+TEST(MultiThreadedCompositor, can_schedule_from_display_observer_when_adding_display)
30+{
31+ using namespace testing;
32+ unsigned int const nbuffers{3};
33+ auto display = std::make_shared<StubDisplayWithMockBuffers>(nbuffers);
34+ auto stub_scene = std::make_shared<NiceMock<StubScene>>();
35+ auto mock_display_listener = std::make_shared<NiceMock<MockDisplayListener>>();
36+ auto db_compositor_factory = std::make_shared<mtd::NullDisplayBufferCompositorFactory>();
37+ auto mock_report = std::make_shared<testing::NiceMock<mtd::MockCompositorReport>>();
38+
39+ ON_CALL(*mock_display_listener, add_display(_))
40+ .WillByDefault(InvokeWithoutArgs([&]{ stub_scene->emit_change_event(); }));
41+
42+ mc::MultiThreadedCompositor compositor{
43+ display, stub_scene, db_compositor_factory, mock_display_listener, mock_report, true};
44+ compositor.start();
45+}
46+
47+TEST(MultiThreadedCompositor, can_schedule_from_display_observer_when_removing_display)
48+{
49+ using namespace testing;
50+ unsigned int const nbuffers{3};
51+ auto display = std::make_shared<StubDisplayWithMockBuffers>(nbuffers);
52+ auto stub_scene = std::make_shared<NiceMock<StubScene>>();
53+ auto mock_display_listener = std::make_shared<NiceMock<MockDisplayListener>>();
54+ auto db_compositor_factory = std::make_shared<mtd::NullDisplayBufferCompositorFactory>();
55+ auto mock_report = std::make_shared<testing::NiceMock<mtd::MockCompositorReport>>();
56+
57+ ON_CALL(*mock_display_listener, remove_display(_))
58+ .WillByDefault(InvokeWithoutArgs([&]{ stub_scene->emit_change_event(); }));
59+
60+ mc::MultiThreadedCompositor compositor{
61+ display, stub_scene, db_compositor_factory, mock_display_listener, mock_report, true};
62+ compositor.start();
63+}

Subscribers

People subscribed via source and target branches