Merge lp:~andreas-pokorny/qtmir/keep-mir-types-alive into lp:qtmir

Proposed by Andreas Pokorny
Status: Needs review
Proposed branch: lp:~andreas-pokorny/qtmir/keep-mir-types-alive
Merge into: lp:qtmir
Diff against target: 82 lines (+22/-14)
1 file modified
src/platforms/mirserver/mirserverhooks.cpp (+22/-14)
To merge this branch: bzr merge lp:~andreas-pokorny/qtmir/keep-mir-types-alive
Reviewer Review Type Date Requested Status
Alan Griffiths Disapprove
Unity8 CI Bot (community) continuous-integration Approve
Review via email: mp+321427@code.launchpad.net

Commit message

Store the relevant mir server parts as shared_ptr and reset before shutdown

This adjustment is required for mir 0.27 and newer.

Description of the change

This is needed for mir-0.27 or mir-1.0 and is currently part of the dnd integration silo.

Backstory: To resolve a race between main thread to session communication and input thread to window/session communication, the internal InputDeviceObserver are executed inside the input thread, but to keep thread usage intact for 3rd party users a wrapper was added that would ensure that all external InputDeviceObservers are executed in the main thread just like before. Since there are not external users inside mir server and since there is only a weak_ptr in qtmir, the wrapper is not kept alive. So no InputDeviceHub for qtmir.

This change will also work with mir-0.26

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:626
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/644/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4774
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4802
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4625/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4625/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4625/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4625/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4625/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4625
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4625/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/644/rebuild

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

I don't understand the explanation.

Why do *all* these objects need preserving after Mir is done with them but need releasing before Mir releases them.

review: Needs Information
Revision history for this message
Gerry Boland (gerboland) wrote :

I expect this branch would be a better solution for this issue:
https://code.launchpad.net/~gerboland/qtmir/small-hooks-change/+merge/321743
Andreas - can you have a look?

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> I expect this branch would be a better solution for this issue:
> https://code.launchpad.net/~gerboland/qtmir/small-hooks-change/+merge/321743
> Andreas - can you have a look?

This MP will show the same problem because nothing will keep the input device hub alive..

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

Objects that need to be kept alive are typically owned in libmirserver not by downstream projects.

It seems to me that the right fix is in Mir. Mir should own the ExternalInputDeviceHub by attaching it to mir::DisplayServer::Private, or something that this owns.

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

> Objects that need to be kept alive are typically owned in libmirserver not by
> downstream projects.
>
> It seems to me that the right fix is in Mir. Mir should own the
> ExternalInputDeviceHub by attaching it to mir::DisplayServer::Private, or
> something that this owns.

For example: lp:~alan-griffiths/mir/preserve-ExternalInputDeviceHub/+merge/321845

Unmerged revisions

626. By Andreas Pokorny

Store the relevant mir server parts as shared_ptr and reset before shutdown

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/mirserverhooks.cpp'
2--- src/platforms/mirserver/mirserverhooks.cpp 2017-03-13 16:49:49 +0000
3+++ src/platforms/mirserver/mirserverhooks.cpp 2017-03-30 09:15:23 +0000
4@@ -70,11 +70,11 @@
5
6 struct qtmir::MirServerHooks::Self
7 {
8- std::weak_ptr<PromptSessionListener> m_promptSessionListener;
9- std::weak_ptr<mir::graphics::Display> m_mirDisplay;
10- std::weak_ptr<mir::shell::DisplayConfigurationController> m_mirDisplayConfigurationController;
11- std::weak_ptr<mir::scene::PromptSessionManager> m_mirPromptSessionManager;
12- std::weak_ptr<mir::input::InputDeviceHub> m_inputDeviceHub;
13+ std::shared_ptr<PromptSessionListener> m_promptSessionListener;
14+ std::shared_ptr<mir::graphics::Display> m_mirDisplay;
15+ std::shared_ptr<mir::shell::DisplayConfigurationController> m_mirDisplayConfigurationController;
16+ std::shared_ptr<mir::scene::PromptSessionManager> m_mirPromptSessionManager;
17+ std::shared_ptr<mir::input::InputDeviceHub> m_inputDeviceHub;
18 };
19
20 qtmir::MirServerHooks::MirServerHooks() :
21@@ -104,36 +104,44 @@
22 self->m_mirPromptSessionManager = server.the_prompt_session_manager();
23 self->m_inputDeviceHub = server.the_input_device_hub();
24 });
25+
26+ server.add_stop_callback([this]
27+ {
28+ self->m_mirDisplay.reset();
29+ self->m_mirDisplayConfigurationController.reset();
30+ self->m_mirPromptSessionManager.reset();
31+ self->m_inputDeviceHub.reset();
32+ });
33 }
34
35 PromptSessionListener *qtmir::MirServerHooks::promptSessionListener() const
36 {
37- if (auto result = self->m_promptSessionListener.lock())
38- return result.get();
39+ if (self->m_promptSessionListener)
40+ return self->m_promptSessionListener.get();
41
42 throw std::logic_error("No prompt session listener available. Server not running?");
43 }
44
45 std::shared_ptr<mir::scene::PromptSessionManager> qtmir::MirServerHooks::thePromptSessionManager() const
46 {
47- if (auto result = self->m_mirPromptSessionManager.lock())
48- return result;
49+ if (self->m_mirPromptSessionManager)
50+ return self->m_mirPromptSessionManager;
51
52 throw std::logic_error("No prompt session manager available. Server not running?");
53 }
54
55 std::shared_ptr<mir::graphics::Display> qtmir::MirServerHooks::theMirDisplay() const
56 {
57- if (auto result = self->m_mirDisplay.lock())
58- return result;
59+ if (self->m_mirDisplay)
60+ return self->m_mirDisplay;
61
62 throw std::logic_error("No display available. Server not running?");
63 }
64
65 std::shared_ptr<mir::input::InputDeviceHub> qtmir::MirServerHooks::theInputDeviceHub() const
66 {
67- if (auto result = self->m_inputDeviceHub.lock())
68- return result;
69+ if (self->m_inputDeviceHub)
70+ return self->m_inputDeviceHub;
71
72 throw std::logic_error("No input device hub available. Server not running?");
73 }
74@@ -141,7 +149,7 @@
75 QSharedPointer<ScreensController> qtmir::MirServerHooks::createScreensController(QSharedPointer<ScreensModel> const &screensModel) const
76 {
77 return QSharedPointer<ScreensController>(
78- new ScreensController(screensModel, theMirDisplay(), self->m_mirDisplayConfigurationController.lock()));
79+ new ScreensController(screensModel, theMirDisplay(), self->m_mirDisplayConfigurationController));
80 }
81
82 void qtmir::MirServerHooks::createInputDeviceObserver()

Subscribers

People subscribed via source and target branches