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
=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
--- src/server/compositor/multi_threaded_compositor.cpp 2015-06-17 05:20:42 +0000
+++ src/server/compositor/multi_threaded_compositor.cpp 2015-08-04 17:13:45 +0000
@@ -300,12 +300,12 @@
300 destroy_compositing_threads(lk);300 destroy_compositing_threads(lk);
301 }};301 }};
302302
303 create_compositing_threads();
304
303 lk.unlock();305 lk.unlock();
304 scene->add_observer(observer);306 scene->add_observer(observer);
305 lk.lock();307 lk.lock();
306308
307 create_compositing_threads();
308
309 /* Optional first render */309 /* Optional first render */
310 if (compose_on_start)310 if (compose_on_start)
311 {311 {
312312
=== modified file 'tests/unit-tests/compositor/test_multi_threaded_compositor.cpp'
--- tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2015-06-17 05:20:42 +0000
+++ tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2015-08-04 17:13:45 +0000
@@ -847,3 +847,40 @@
847847
848 compositor.start();848 compositor.start();
849}849}
850
851//LP: 1481418
852TEST(MultiThreadedCompositor, can_schedule_from_display_observer_when_adding_display)
853{
854 using namespace testing;
855 unsigned int const nbuffers{3};
856 auto display = std::make_shared<StubDisplayWithMockBuffers>(nbuffers);
857 auto stub_scene = std::make_shared<NiceMock<StubScene>>();
858 auto mock_display_listener = std::make_shared<NiceMock<MockDisplayListener>>();
859 auto db_compositor_factory = std::make_shared<mtd::NullDisplayBufferCompositorFactory>();
860 auto mock_report = std::make_shared<testing::NiceMock<mtd::MockCompositorReport>>();
861
862 ON_CALL(*mock_display_listener, add_display(_))
863 .WillByDefault(InvokeWithoutArgs([&]{ stub_scene->emit_change_event(); }));
864
865 mc::MultiThreadedCompositor compositor{
866 display, stub_scene, db_compositor_factory, mock_display_listener, mock_report, true};
867 compositor.start();
868}
869
870TEST(MultiThreadedCompositor, can_schedule_from_display_observer_when_removing_display)
871{
872 using namespace testing;
873 unsigned int const nbuffers{3};
874 auto display = std::make_shared<StubDisplayWithMockBuffers>(nbuffers);
875 auto stub_scene = std::make_shared<NiceMock<StubScene>>();
876 auto mock_display_listener = std::make_shared<NiceMock<MockDisplayListener>>();
877 auto db_compositor_factory = std::make_shared<mtd::NullDisplayBufferCompositorFactory>();
878 auto mock_report = std::make_shared<testing::NiceMock<mtd::MockCompositorReport>>();
879
880 ON_CALL(*mock_display_listener, remove_display(_))
881 .WillByDefault(InvokeWithoutArgs([&]{ stub_scene->emit_change_event(); }));
882
883 mc::MultiThreadedCompositor compositor{
884 display, stub_scene, db_compositor_factory, mock_display_listener, mock_report, true};
885 compositor.start();
886}

Subscribers

People subscribed via source and target branches