Browse files

re #15915 HeadlessJsTaskService is expected to run on UI thread

Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here:

Happy contributing!


Headless tasks are required to run in the main thread, however due to the nature of the React context creation flow, the handler may be returned outside of the main thread, causing the HeadlessJsTaskContext to throw an exception.

Swipe out the app. send push notification from a server that starts a HeadlessJsTaskService
Closes #15940

Differential Revision: D5852448

Pulled By: foghina

fbshipit-source-id: 54c58a1eb7434dd5de5c39c28f6e068ed15ead9d
  • Loading branch information...
oriharel authored and facebook-github-bot committed Sep 18, 2017
1 parent df8d0d1 commit 795370789bc950202bce4550dce8b42dbd21d361
Showing with 12 additions and 4 deletions.
  1. +12 −4 ReactAndroid/src/main/java/com/facebook/react/
@@ -116,11 +116,19 @@ public void onReactContextInitialized(ReactContext reactContext) {

private void invokeStartTask(ReactContext reactContext, HeadlessJsTaskConfig taskConfig) {
HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
private void invokeStartTask(ReactContext reactContext, final HeadlessJsTaskConfig taskConfig) {
final HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
int taskId = headlessJsTaskContext.startTask(taskConfig);

new Runnable() {
public void run() {
int taskId = headlessJsTaskContext.startTask(taskConfig);


0 comments on commit 7953707

Please sign in to comment.