Merge lp:~gerboland/qtmir/url-dispatcher-respawns-so-appMan-should-not into lp:qtmir

Proposed by Gerry Boland
Status: Rejected
Rejected by: Gerry Boland
Proposed branch: lp:~gerboland/qtmir/url-dispatcher-respawns-so-appMan-should-not
Merge into: lp:qtmir
Diff against target: 73 lines (+36/-4)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+13/-4)
tests/modules/ApplicationManager/application_manager_test.cpp (+23/-0)
To merge this branch: bzr merge lp:~gerboland/qtmir/url-dispatcher-respawns-so-appMan-should-not
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+238319@code.launchpad.net

Commit message

AppMan: url-dispatcher launches focusRequested apps itself, so ensure AppMan sets the app state appropriately

Let app1 be lifecycle killed, but still in the app list. app2 uses url-dispatcher to focus app1. This causes url-dispatcher to launch a new instance of app1, and then notify AppMan to request focus for app1.

However it is possible if shell acted upon the requestFocus signal, and called focusApplication(app1) - before the onProcessStarting(app1) notification from upstart was received, AppMan would respawn app1 itself. So 2 instances of app1 would be executing, and later AppMan would then reject one of them.

Description of the change

AppMan: url-dispatcher launches focusRequested apps itself, so ensure AppMan sets the app state appropriately

Let app1 be lifecycle killed, but still in the app list. app2 uses url-dispatcher to focus app1. This causes url-dispatcher to launch a new instance of app1, and then notify AppMan to request focus for app1.

However it is possible if shell acted upon the requestFocus signal, and called focusApplication(app1) - before the onProcessStarting(app1) notification from upstart was received, AppMan would respawn app1 itself. So 2 instances of app1 would be executing, and later AppMan would then reject one of them.

To post a comment you must log in.
275. By Gerry Boland

Update comments to explain new situation

276. By Gerry Boland

Merge trunk

277. By Gerry Boland

Remove unnecessary include

Unmerged revisions

277. By Gerry Boland

Remove unnecessary include

276. By Gerry Boland

Merge trunk

275. By Gerry Boland

Update comments to explain new situation

274. By Gerry Boland

AppMan: url-dispatcher launches focusRequested apps itself, so ensure AppMan sets the app state appropriately

Let app1 be lifecycle killed, but still in the app list. app2 uses url-dispatcher to focus app1. This causes url-dispatcher to launch a new instance of app1, and then notify AppMan to request focus for app1.

However it is possible if shell acted upon the requestFocus signal, and called focusApplication(app1) - before the onProcessStarting(app1) notification from upstart was received, AppMan would respawn app1 itself. So 2 instances of app1 would be executing, and later AppMan would then reject one of them.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2014-10-30 11:55:15 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2014-12-10 12:46:03 +0000
@@ -280,6 +280,13 @@
280 return false;280 return false;
281 }281 }
282282
283 // url-dispatcher can relaunch apps which have been OOM-killed - AppMan must accept the newly spawned
284 // application and focus it immediately (as user expects app to still be running).
285 if (application->state() == Application::Stopped) {
286 qCDebug(QTMIR_APPLICATIONS) << "Stopped application appId=" << appId << "was resumed by url-dispatcher";
287 application->setState(Application::Starting);
288 }
289
283 Q_EMIT focusRequested(appId);290 Q_EMIT focusRequested(appId);
284 return true;291 return true;
285}292}
@@ -531,15 +538,17 @@
531 Q_EMIT focusRequested(appId);538 Q_EMIT focusRequested(appId);
532 }539 }
533 else {540 else {
534 // url-dispatcher can relaunch apps which have been OOM-killed - AppMan must accept the newly spawned541 // It is highly unlikely an app whose process was killed (usually by OOM) could be respawned by means other
535 // application and focus it immediately (as user expects app to still be running).542 // than url-dispatcher or AppMan itself - maybe an app developer is testing lifecycle stuff?? In any case,
543 // let's just be agreeable, accept the newly spawned process and focus it immediately.
536 if (application->state() == Application::Stopped) {544 if (application->state() == Application::Stopped) {
537 qCDebug(QTMIR_APPLICATIONS) << "Stopped application appId=" << appId << "is being resumed externally";545 qCDebug(QTMIR_APPLICATIONS) << "Stopped application appId=" << appId
546 << "has been resumed in an unexpected way";
538 application->setState(Application::Starting);547 application->setState(Application::Starting);
539 Q_EMIT focusRequested(appId);548 Q_EMIT focusRequested(appId);
540 } else {549 } else {
541 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onProcessStarting application already found with appId"550 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onProcessStarting application already found with appId"
542 << appId;551 << appId << "- is probably ok";
543 }552 }
544 }553 }
545}554}
546555
=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-11-13 16:26:03 +0000
+++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-12-10 12:46:03 +0000
@@ -2036,6 +2036,29 @@
2036}2036}
20372037
2038/*2038/*
2039 * Test if url-dispatcher requests focus for an app which was lifecycle killed, then
2040 * AppMan assumes that url-dispatcher respawned the app (and AppMan doesn't try to respawn
2041 * the app itself)
2042 */
2043TEST_F(ApplicationManagerTests,urlDispatcherRespawnsStoppedAppsSoWeDoNotHaveTo)
2044{
2045 using namespace ::testing;
2046 quint64 procId1 = 5551;
2047 const QString appId("testAppId");
2048
2049 auto app = startApplication(procId1, appId);
2050 app->setState(Application::Stopped);
2051
2052 EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(appId, _))
2053 .Times(0)
2054 .WillOnce(Return(true));
2055
2056 applicationManager.requestFocusApplication(appId);
2057
2058 EXPECT_EQ(app->state(), Application::Starting);
2059}
2060
2061/*
2039 * Test that screenshotting callback works cross thread.2062 * Test that screenshotting callback works cross thread.
2040 */2063 */
2041TEST_F(ApplicationManagerTests, threadedScreenshot)2064TEST_F(ApplicationManagerTests, threadedScreenshot)

Subscribers

People subscribed via source and target branches