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
=== modified file 'src/platforms/mirserver/mirserverhooks.cpp'
--- src/platforms/mirserver/mirserverhooks.cpp 2017-03-13 16:49:49 +0000
+++ src/platforms/mirserver/mirserverhooks.cpp 2017-03-30 09:15:23 +0000
@@ -70,11 +70,11 @@
7070
71struct qtmir::MirServerHooks::Self71struct qtmir::MirServerHooks::Self
72{72{
73 std::weak_ptr<PromptSessionListener> m_promptSessionListener;73 std::shared_ptr<PromptSessionListener> m_promptSessionListener;
74 std::weak_ptr<mir::graphics::Display> m_mirDisplay;74 std::shared_ptr<mir::graphics::Display> m_mirDisplay;
75 std::weak_ptr<mir::shell::DisplayConfigurationController> m_mirDisplayConfigurationController;75 std::shared_ptr<mir::shell::DisplayConfigurationController> m_mirDisplayConfigurationController;
76 std::weak_ptr<mir::scene::PromptSessionManager> m_mirPromptSessionManager;76 std::shared_ptr<mir::scene::PromptSessionManager> m_mirPromptSessionManager;
77 std::weak_ptr<mir::input::InputDeviceHub> m_inputDeviceHub;77 std::shared_ptr<mir::input::InputDeviceHub> m_inputDeviceHub;
78};78};
7979
80qtmir::MirServerHooks::MirServerHooks() :80qtmir::MirServerHooks::MirServerHooks() :
@@ -104,36 +104,44 @@
104 self->m_mirPromptSessionManager = server.the_prompt_session_manager();104 self->m_mirPromptSessionManager = server.the_prompt_session_manager();
105 self->m_inputDeviceHub = server.the_input_device_hub();105 self->m_inputDeviceHub = server.the_input_device_hub();
106 });106 });
107
108 server.add_stop_callback([this]
109 {
110 self->m_mirDisplay.reset();
111 self->m_mirDisplayConfigurationController.reset();
112 self->m_mirPromptSessionManager.reset();
113 self->m_inputDeviceHub.reset();
114 });
107}115}
108116
109PromptSessionListener *qtmir::MirServerHooks::promptSessionListener() const117PromptSessionListener *qtmir::MirServerHooks::promptSessionListener() const
110{118{
111 if (auto result = self->m_promptSessionListener.lock())119 if (self->m_promptSessionListener)
112 return result.get();120 return self->m_promptSessionListener.get();
113121
114 throw std::logic_error("No prompt session listener available. Server not running?");122 throw std::logic_error("No prompt session listener available. Server not running?");
115}123}
116124
117std::shared_ptr<mir::scene::PromptSessionManager> qtmir::MirServerHooks::thePromptSessionManager() const125std::shared_ptr<mir::scene::PromptSessionManager> qtmir::MirServerHooks::thePromptSessionManager() const
118{126{
119 if (auto result = self->m_mirPromptSessionManager.lock())127 if (self->m_mirPromptSessionManager)
120 return result;128 return self->m_mirPromptSessionManager;
121129
122 throw std::logic_error("No prompt session manager available. Server not running?");130 throw std::logic_error("No prompt session manager available. Server not running?");
123}131}
124132
125std::shared_ptr<mir::graphics::Display> qtmir::MirServerHooks::theMirDisplay() const133std::shared_ptr<mir::graphics::Display> qtmir::MirServerHooks::theMirDisplay() const
126{134{
127 if (auto result = self->m_mirDisplay.lock())135 if (self->m_mirDisplay)
128 return result;136 return self->m_mirDisplay;
129137
130 throw std::logic_error("No display available. Server not running?");138 throw std::logic_error("No display available. Server not running?");
131}139}
132140
133std::shared_ptr<mir::input::InputDeviceHub> qtmir::MirServerHooks::theInputDeviceHub() const141std::shared_ptr<mir::input::InputDeviceHub> qtmir::MirServerHooks::theInputDeviceHub() const
134{142{
135 if (auto result = self->m_inputDeviceHub.lock())143 if (self->m_inputDeviceHub)
136 return result;144 return self->m_inputDeviceHub;
137145
138 throw std::logic_error("No input device hub available. Server not running?");146 throw std::logic_error("No input device hub available. Server not running?");
139}147}
@@ -141,7 +149,7 @@
141QSharedPointer<ScreensController> qtmir::MirServerHooks::createScreensController(QSharedPointer<ScreensModel> const &screensModel) const149QSharedPointer<ScreensController> qtmir::MirServerHooks::createScreensController(QSharedPointer<ScreensModel> const &screensModel) const
142{150{
143 return QSharedPointer<ScreensController>(151 return QSharedPointer<ScreensController>(
144 new ScreensController(screensModel, theMirDisplay(), self->m_mirDisplayConfigurationController.lock()));152 new ScreensController(screensModel, theMirDisplay(), self->m_mirDisplayConfigurationController));
145}153}
146154
147void qtmir::MirServerHooks::createInputDeviceObserver()155void qtmir::MirServerHooks::createInputDeviceObserver()

Subscribers

People subscribed via source and target branches