Use DISPLAY thread priority for main thread in React Native

Summary: In older versions of android, the main thread is given the same priority as all other threads (default). Instead, it should have a higher priority (DISPLAY) which will make sure it's scheduled instead of the background JS/native modules threads.

Reviewed By: majak

Differential Revision: D3497244

fbshipit-source-id: 15ab09f4ebcad2692ae1261f15aa2c6c39f72ee9
This commit is contained in:
Andy Street 2016-06-29 13:59:43 -07:00 committed by Facebook Github Bot 8
parent bcb7cc4956
commit cf7b4e74f0
1 changed files with 3 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import android.os.Looper;
import android.os.Process;
import com.facebook.common.logging.FLog;
import com.facebook.proguard.annotations.DoNotStrip;
@ -148,12 +149,14 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
new MessageQueueThreadImpl(name, mainLooper, exceptionHandler);
if (UiThreadUtil.isOnUiThread()) {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
MessageQueueThreadRegistry.register(mqt);
} else {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
MessageQueueThreadRegistry.register(mqt);
}
});