Skip to content

Commit

Permalink
arc: Implement instant response for app window open
Browse files Browse the repository at this point in the history
Feature 1-pager: go/arc-instant-response

In some slow devices, ARC app window still need wait several second
to be popped up and draw. This feature will always popup ghost window
and sent launch request at the same time to reduce the window shown
delay.

BUG=b:256983992
TEST=build

Change-Id: I33e3df9f3fe2705a45aa8254df11cebf53796435
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3996410
Reviewed-by: Nancy Wang <nancylingwang@chromium.org>
Commit-Queue: Shengsong Tan <sstan@chromium.org>
Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1068930}
  • Loading branch information
Shengsong Tan authored and Chromium LUCI CQ committed Nov 9, 2022
1 parent 749026c commit 6cb8859
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ash/components/arc/arc_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ const base::FeatureParam<int> kGuestZramSize{&kGuestZram, "size", 0};
const base::FeatureParam<int> kGuestZramSwappiness{&kGuestZram, "swappiness",
0};

// Enables/disables ghost when user launch ARC app from shelf/launcher when
// App already ready for launch.
BASE_FEATURE(kInstantResponseWindowOpen,
"ArcInstantResponseWindowOpen",
base::FEATURE_DISABLED_BY_DEFAULT);

// Enables/disables mlock() of guest memory for ARCVM.
// Often used in combination with kGuestZram.
BASE_FEATURE(kLockGuestMemory,
Expand Down
1 change: 1 addition & 0 deletions ash/components/arc/arc_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BASE_DECLARE_FEATURE(kGmsCoreLowMemoryKillerProtection);
BASE_DECLARE_FEATURE(kGuestZram);
extern const base::FeatureParam<int> kGuestZramSize;
extern const base::FeatureParam<int> kGuestZramSwappiness;
BASE_DECLARE_FEATURE(kInstantResponseWindowOpen);
BASE_DECLARE_FEATURE(kLockGuestMemory);
BASE_DECLARE_FEATURE(kLogdConfig);
extern const base::FeatureParam<int> kLogdConfigSize;
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5314,6 +5314,10 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kArcGhostWindowNewStyleName,
flag_descriptions::kArcGhostWindowNewStyleDescription, kOsCrOS,
FEATURE_VALUE_TYPE(arc::kGhostWindowNewStyle)},
{"arc-instant-response-window-open",
flag_descriptions::kArcInstantResponseWindowOpenName,
flag_descriptions::kArcInstantResponseWindowOpenDescription, kOsCrOS,
FEATURE_VALUE_TYPE(arc::kInstantResponseWindowOpen)},
{"arc-keyboard-shortcut-helper-integration",
flag_descriptions::kArcKeyboardShortcutHelperIntegrationName,
flag_descriptions::kArcKeyboardShortcutHelperIntegrationDescription,
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/ash/arc/window_predictor/window_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,12 @@ arc::mojom::WindowInfoPtr WindowPredictor::PredictAppWindowInfo(
return window_info;
}

bool WindowPredictor::IsAppPendingLaunch(Profile* profile,
const std::string& app_id) {
auto* arc_task_handler =
ash::app_restore::AppRestoreArcTaskHandler::GetForProfile(profile);

return arc_task_handler && arc_task_handler->IsAppPendingRestore(app_id);
}

} // namespace arc
2 changes: 2 additions & 0 deletions chrome/browser/ash/arc/window_predictor/window_predictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class WindowPredictor {
const ArcAppListPrefs::AppInfo& app_info,
arc::mojom::WindowInfoPtr window_info);

bool IsAppPendingLaunch(Profile* profile, const std::string& app_id);

private:
friend class base::NoDestructor<WindowPredictor>;
WindowPredictor();
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/flag-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@
"owners": [ "cuicuiruan@google.com", "arc-gaming@google.com" ],
"expiry_milestone": 120
},
{ "name": "arc-instant-response-window-open",
"owners": [ "sstan", "mduggan" ],
"expiry_milestone": 120
},
{
"name": "arc-keyboard-shortcut-helper-integration",
"owners": [ "yhanada", "mduggan" ],
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4747,6 +4747,12 @@ const char kArcGameModeDescription[] =
"ARC Fullscreen Games will request accomodation from ChromeOS for "
"sustained performance.";

extern const char kArcInstantResponseWindowOpenName[] =
"Enable Instance Response for ARC app window open";
extern const char kArcInstantResponseWindowOpenDescription[] =
"In some devices the placeholder window will popup immediately after the "
"user attempts to launch apps.";

const char kArcKeyboardShortcutHelperIntegrationName[] =
"Enable keyboard shortcut helper integration for ARC";
const char kArcKeyboardShortcutHelperIntegrationDescription[] =
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,9 @@ extern const char kArcGhostWindowNewStyleDescription[];
extern const char kArcGameModeName[];
extern const char kArcGameModeDescription[];

extern const char kArcInstantResponseWindowOpenName[];
extern const char kArcInstantResponseWindowOpenDescription[];

extern const char kArcKeyboardShortcutHelperIntegrationName[];
extern const char kArcKeyboardShortcutHelperIntegrationDescription[];

Expand Down
14 changes: 14 additions & 0 deletions chrome/browser/ui/app_list/arc/arc_app_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ bool IsFixupWindowEnabled() {
return base::FeatureList::IsEnabled(arc::kFixupWindowFeature);
}

bool IsInstantResponseOpenEnabled() {
return base::FeatureList::IsEnabled(arc::kInstantResponseWindowOpen);
}

} // namespace

// Package names, kept in sorted order.
Expand Down Expand Up @@ -423,6 +427,16 @@ bool LaunchAppWithIntent(content::BrowserContext* context,
launch_intent_to_send =
AppendLaunchIntent(launch_intent_to_send.value(), extra);
}
} else if (IsInstantResponseOpenEnabled() &&
!WindowPredictor::GetInstance()->IsAppPendingLaunch(profile,
app_id)) {
// For some devices, launch ghost window and app at the same time.
if (WindowPredictor::GetInstance()->LaunchArcAppWithGhostWindow(
profile, app_id, *app_info, event_flags,
GhostWindowType::kAppLaunch, window_info)) {
return true;
}
VLOG(2) << "Failed to launch ghost window, fallback to launch directly.";
}

arc::ArcBootPhaseMonitorBridge::RecordFirstAppLaunchDelayUMA(context);
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59902,6 +59902,7 @@ from previous Chrome versions.
<int value="-803206774" label="TabbedAppOverflowMenuActionBar:disabled"/>
<int value="-802348444" label="disable-site-engagement-service"/>
<int value="-802309777" label="ChromeTipsInMainMenu:disabled"/>
<int value="-800565336" label="ArcInstantResponseWindowOpen:disabled"/>
<int value="-800464360" label="ContextualPageActions:enabled"/>
<int value="-800127303" label="OmniboxPedalsTranslationConsole:disabled"/>
<int value="-799931058" label="UseMultiloginEndpoint:disabled"/>
Expand Down Expand Up @@ -60754,6 +60755,7 @@ from previous Chrome versions.
<int value="-284470280" label="ShelfPalmRejectionTouchArea:enabled"/>
<int value="-284328071" label="LocalWebApprovals:enabled"/>
<int value="-284279318" label="LacrosMoveProfileMigration:enabled"/>
<int value="-283706169" label="ArcInstantResponseWindowOpen:enabled"/>
<int value="-283388027" label="ManualFallbacksFilling:disabled"/>
<int value="-283079109" label="TouchToFillPasswordSubmission:enabled"/>
<int value="-283024110" label="WebXRPlaneDetection:disabled"/>
Expand Down

0 comments on commit 6cb8859

Please sign in to comment.