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:
parent
bcb7cc4956
commit
cf7b4e74f0
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue