Commit 805ae757 authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

Adjust logic for UI thread priority

This patch adjusts the logic for UI thread priority:

1) The priority is only increased to DISPLAY unless it was lower to
   begin with. Recent versions of Android (O+) automatically set the top
   activity's UI thread's niceness to TOP_APP_PRIORITY_BOOST (-10), so
   by setting the priority to DISPLAY (-4) we were in fact lowering the
   priority.

2) The priority is increased earlier in the start-up flow to minimize
   the chances of descheduling.

We also add a field trial for the first change to evaluate its impact.

BUG=841804
TEST=Manual inspection

Change-Id: I3ec70042be86f2b88bb1ae3a2dd8cba7d87eb807
Reviewed-on: https://chromium-review.googlesource.com/1136648
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576079}
parent fa0e1405
......@@ -638,6 +638,17 @@ int BrowserMainLoop::EarlyInitialization() {
command_line->GetSwitchValueASCII(switches::kDisableFeatures));
}
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
// Up the priority of the UI thread unless it was already high (since recent
// versions of Android (O+) do this automatically).
if (base::PlatformThread::GetCurrentThreadPriority() <
base::ThreadPriority::DISPLAY ||
base::FeatureList::IsEnabled(features::kOverrideUIThreadPriority)) {
base::PlatformThread::SetCurrentThreadPriority(
base::ThreadPriority::DISPLAY);
}
#endif // defined(OS_ANDROID) || defined(OS_CHROMEOS)
#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
defined(OS_ANDROID)
// We use quite a few file descriptors for our IPC as well as disk the disk
......@@ -1238,10 +1249,6 @@ int BrowserMainLoop::BrowserThreadsStarted() {
#endif
HistogramSynchronizer::GetInstance();
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
// Up the priority of the UI thread.
base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY);
#endif
// cc assumes a single client name for metrics in a process, which is
// is inconsistent with single process mode where both the renderer and
......
......@@ -649,6 +649,12 @@ const base::Feature kMacV2Sandbox{"MacV2Sandbox",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_MACOSX)
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
// Always set the UI thread's priority to DISPLAY.
const base::Feature kOverrideUIThreadPriority{
"OverrideUIThreadPriority", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_ANDROID) || defined(OS_CHROMEOS)
bool IsVideoCaptureServiceEnabledForOutOfProcess() {
#if defined(OS_ANDROID)
return false;
......
......@@ -153,6 +153,10 @@ CONTENT_EXPORT extern const char kWebXrRenderPathParamValueSharedBuffer[];
CONTENT_EXPORT extern const base::Feature kWebUIPolymer2;
#endif // !defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
CONTENT_EXPORT extern const base::Feature kOverrideUIThreadPriority;
#endif // defined(OS_ANDROID) || defined(OS_CHROMEOS)
#if defined(OS_MACOSX)
CONTENT_EXPORT extern const base::Feature kDeviceMonitorMac;
CONTENT_EXPORT extern const base::Feature kIOSurfaceCapturer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment