Increase the GPU thread priority and add error logging (flutter/engine#5117)

This commit is contained in:
xster
2018-04-30 17:18:33 -07:00
committed by GitHub
parent d9405b3004
commit fa659500dd

View File

@@ -84,9 +84,24 @@ AndroidShellHolder::AndroidShellHolder(
if (is_valid_) {
task_runners.GetGPUTaskRunner()->PostTask(
[]() { ::setpriority(PRIO_PROCESS, gettid(), -2); });
[]() {
// Android describes -8 as "most important display threads, for
// compositing the screen and retrieving input events". Conservatively
// set the GPU 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) {
FXL_LOG(ERROR) << "Failed to set GPU task runner priority";
}
}
});
task_runners.GetUITaskRunner()->PostTask(
[]() { ::setpriority(PRIO_PROCESS, gettid(), -1); });
[]() {
if (::setpriority(PRIO_PROCESS, gettid(), -1) != 0) {
FXL_LOG(ERROR) << "Failed to set UI task runner priority";
}
});
}
}