From 00d2e0194bdc4c6e58378f1be34540300e94991d Mon Sep 17 00:00:00 2001 From: "roger.yi" Date: Mon, 25 Jan 2021 16:58:32 +0800 Subject: [PATCH] Fix Android IO and Worker threads priority issue --- shell/platform/android/android_shell_holder.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/platform/android/android_shell_holder.cc b/shell/platform/android/android_shell_holder.cc index e83980f4bf4f5..fdc912773e9c2 100644 --- a/shell/platform/android/android_shell_holder.cc +++ b/shell/platform/android/android_shell_holder.cc @@ -122,6 +122,11 @@ AndroidShellHolder::AndroidShellHolder( FML_LOG(ERROR) << "Failed to set UI task runner priority"; } }); + task_runners.GetIOTaskRunner()->PostTask([]() { + if (::setpriority(PRIO_PROCESS, gettid(), 1) != 0) { + FML_LOG(ERROR) << "Failed to set IO task runner priority"; + } + }); shell_ = Shell::Create(task_runners, // task runners @@ -131,6 +136,14 @@ AndroidShellHolder::AndroidShellHolder( on_create_rasterizer // rasterizer create callback ); + if (shell_) { + shell_->GetDartVM()->GetConcurrentMessageLoop()->PostTaskToAllWorkers([]() { + if (::setpriority(PRIO_PROCESS, gettid(), 1) != 0) { + FML_LOG(ERROR) << "Failed to set Workers task runner priority"; + } + }); + } + platform_view_ = weak_platform_view; FML_DCHECK(platform_view_); is_valid_ = shell_ != nullptr;