diff --git a/shell/platform/android/android_shell_holder.cc b/shell/platform/android/android_shell_holder.cc index d58ad703f695a89291cc1ede2b78f77a68465c8e..8e1448c13d89c6027b20627f9432bbba2a9cb73e 100644 --- a/shell/platform/android/android_shell_holder.cc +++ b/shell/platform/android/android_shell_holder.cc @@ -107,6 +107,23 @@ AndroidShellHolder::AndroidShellHolder( ui_runner, // ui io_runner // io ); + task_runners.GetRasterTaskRunner()->PostTask([]() { + // Android describes -8 as "most important display threads, for + // compositing the screen and retrieving input events". Conservatively + // set the raster thread to slightly lower priority than it. + if (::setpriority(PRIO_PROCESS, gettid(), -5) != 0) { + // Defensive fallback. Depending on the OEM, it may not be possible + // to set priority to -5. + if (::setpriority(PRIO_PROCESS, gettid(), -2) != 0) { + FML_LOG(ERROR) << "Failed to set GPU task runner priority"; + } + } + }); + task_runners.GetUITaskRunner()->PostTask([]() { + if (::setpriority(PRIO_PROCESS, gettid(), -1) != 0) { + FML_LOG(ERROR) << "Failed to set UI task runner priority"; + } + }); shell_ = Shell::Create(task_runners, // task runners @@ -118,28 +135,7 @@ AndroidShellHolder::AndroidShellHolder( platform_view_ = weak_platform_view; FML_DCHECK(platform_view_); - is_valid_ = shell_ != nullptr; - - if (is_valid_) { - shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask([]() { - // Android describes -8 as "most important display threads, for - // compositing the screen and retrieving input events". Conservatively - // set the raster thread to slightly lower priority than it. - if (::setpriority(PRIO_PROCESS, gettid(), -5) != 0) { - // Defensive fallback. Depending on the OEM, it may not be possible - // to set priority to -5. - if (::setpriority(PRIO_PROCESS, gettid(), -2) != 0) { - FML_LOG(ERROR) << "Failed to set GPU task runner priority"; - } - } - }); - shell_->GetTaskRunners().GetUITaskRunner()->PostTask([]() { - if (::setpriority(PRIO_PROCESS, gettid(), -1) != 0) { - FML_LOG(ERROR) << "Failed to set UI task runner priority"; - } - }); - } } AndroidShellHolder::~AndroidShellHolder() {