Permalink
Browse files

lower thread priority of native module and JS thread

Reviewed By: achen1

Differential Revision: D4921012

fbshipit-source-id: 71df4ab0614f20f092b992c07e828eb5ad951159
  • Loading branch information...
AaaChiuuu authored and facebook-github-bot committed Apr 20, 2017
1 parent 38f5b84 commit 97a86634f7b9debb45748c45cae1641edd734c79
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Process;
import android.view.View;
import com.facebook.common.logging.FLog;
@@ -742,6 +743,7 @@ private void runCreateReactContextOnNewThread(final ReactContextInitParams initP
@Override
public void run() {
try {
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
final ReactApplicationContext reactApplicationContext = createReactContext(
initParams.getJsExecutorFactory().create(),
initParams.getJsBundleLoader());
@@ -789,7 +791,6 @@ public void run() {
}
}
});
mCreateReactContextThread.setPriority(Thread.MAX_PRIORITY);
mCreateReactContextThread.start();
}
@@ -200,6 +200,7 @@ public static MessageQueueThreadImpl startNewBackgroundThread(
new Runnable() {
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
Looper.prepare();
looperFuture.set(Looper.myLooper());

3 comments on commit 97a8663

@brunolemos

This comment has been minimized.

Show comment
Hide comment
@brunolemos

brunolemos Jun 7, 2017

Contributor

@AaaChiuuu what's the motivation behind this?

Contributor

brunolemos replied Jun 7, 2017

@AaaChiuuu what's the motivation behind this?

@AaaChiuuu

This comment has been minimized.

Show comment
Hide comment
@AaaChiuuu

AaaChiuuu Jun 7, 2017

Contributor

To ensure our background threads don't have higher priority than the UI thread.

Contributor

AaaChiuuu replied Jun 7, 2017

To ensure our background threads don't have higher priority than the UI thread.

@brunolemos

This comment has been minimized.

Show comment
Hide comment
@brunolemos

brunolemos Jun 7, 2017

Contributor

So it might increase responsiveness?

Thanks.

Contributor

brunolemos replied Jun 7, 2017

So it might increase responsiveness?

Thanks.

Please sign in to comment.