Skip to content

Commit

Permalink
lower thread priority of native module and JS thread
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D4921012

fbshipit-source-id: 71df4ab0614f20f092b992c07e828eb5ad951159
  • Loading branch information
aaronechiu authored and facebook-github-bot committed Apr 20, 2017
1 parent 38f5b84 commit 97a8663
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -789,7 +791,6 @@ public void run() {
}
}
});
mCreateReactContextThread.setPriority(Thread.MAX_PRIORITY);
mCreateReactContextThread.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

3 comments on commit 97a8663

@brunolemos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaaChiuuu what's the motivation behind this?

@aaronechiu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@brunolemos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it might increase responsiveness?

Thanks.

Please sign in to comment.