Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Documentation for running in release/production? #7

Open
seantempesta opened this issue Aug 3, 2016 · 8 comments
Open

Documentation for running in release/production? #7

seantempesta opened this issue Aug 3, 2016 · 8 comments

Comments

@seantempesta
Copy link

I tried running a production version (Scheme -> Build Configuration = Release), the main bundle loads and attempts to start the worker, but this just repeats in my logs:

2016-08-03 13:50:35.543 FutureApp[9291:273962] starting Worker file:///Users/sean/Library/Developer/CoreSimulator/Devices/EC847FD2-23EB-4CAA-B10A-87D8F21F55D7/data/Containers/Bundle/Application/A0442033-AC22-4336-9364-1B2F628ADA6F/FutureApp.app/main.jsbundle
2016-08-03 13:50:35.727 FutureApp[9291:274381] starting Worker file:///Users/sean/Library/Developer/CoreSimulator/Devices/EC847FD2-23EB-4CAA-B10A-87D8F21F55D7/data/Containers/Bundle/Application/A0442033-AC22-4336-9364-1B2F628ADA6F/FutureApp.app/main.jsbundle
2016-08-03 13:50:35.887 FutureApp[9291:273962] starting Worker file:///Users/sean/Library/Developer/CoreSimulator/Devices/EC847FD2-23EB-4CAA-B10A-87D8F21F55D7/data/Containers/Bundle/Application/A0442033-AC22-4336-9364-
......

I added the worker.js file to my project folder and can confirm it's being copied to the same folder. But it looks like the worker is trying to load the wrong file? The main.jsbundle file is the output of the react native packager, right?

@seantempesta
Copy link
Author

So, my Objective-C skills are nonexistent, but it seems to work if I hardcode the path to the worker bundle:

Steps to get it working:

  1. Build an offline bundle of the worker file:
    react-native bundle --platform ios --dev false --entry-file worker.js --bundle-output iOS/worker.jsbundle
  2. Add the worker.jsbundle file to the XCode project. (In the Project Navigator click on the app name, then right click and select Add Files to ...)
  3. In WorkerManager.m change the *workerURL line to point to the file:
    NSURL *workerURL = [[NSBundle mainBundle] URLForResource:@"worker" withExtension:@"jsbundle"];

@fampinheiro
Copy link

fampinheiro commented Aug 3, 2016

Having the same issue in android

D/WorkerManager( 7970): Starting web worker - src/workers/printers/worker
D/WorkerManager( 7970): createReleaseBundleLoader - reading file from assets
E/        ( 7970): Unable to load script from assets: workers/src_workers_printers_worker.bundle
W/System.err( 7970): java.lang.RuntimeException: Could not connect to development server.

Listing the assets I can't see the workers asset

fampinheiro ~/android node v6.3.1 npm v3.10.3 $ ls app/build/intermediates/assets/development/release/
fonts                     index.android.bundle      index.android.bundle.meta

@fampinheiro
Copy link

fampinheiro commented Aug 3, 2016

A possible way to overcome this is to create the workers manually

react-native bundle --entry-file ./src/workers/printers/worker.js --platform android --bundle-output android/app/src/main/assets/workers/src_workers_printers_worker.bundle

@devfd
Copy link
Owner

devfd commented Aug 3, 2016

yes it is on the todo list. but basically it is just a matter of calling the RN packager and writing the worker bundle file at the correct location.

@RichardBoyewa
Copy link

When are you adding this please @devfd

@RichardBoyewa
Copy link

Ok. I have done this. Its working now.

@oroce
Copy link

oroce commented Oct 30, 2016

Anyone else seeing issues with RN 0.35?

I have a src/worker.js and in my code I'm doing: new Worker('src/worker');.

For the android bundle I'm running:

react-native bundle \
  --dev false\
  --entry-file ./src/worker.js\
  --platform android\
  --bundle-output android/app/src/main/assets/workers/src_worker.bundle \
  --sourcemap-output android/app/src/main/assets/workers/src_worker.map \
  --assets-dest android/app/src/main/res/
10-30 17:02:08.119 25730 25754 W System.err: java.lang.RuntimeException: Could not get BatchedBridge, make sure your bundle is packaged correctly
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.cxxbridge.CatalystInstanceImpl.loadScriptFromAssets(Native Method)
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.cxxbridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33)
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.cxxbridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:177)
10-30 17:02:08.120 25730 25754 W System.err:    at co.apptailor.Worker.core.ReactContextBuilder$1.call(ReactContextBuilder.java:90)
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$1.run(MessageQueueThreadImpl.java:74)
10-30 17:02:08.120 25730 25754 W System.err:    at android.os.Handler.handleCallback(Handler.java:751)
10-30 17:02:08.120 25730 25754 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:95)
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
10-30 17:02:08.120 25730 25754 W System.err:    at android.os.Looper.loop(Looper.java:154)
10-30 17:02:08.120 25730 25754 W System.err:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
10-30 17:02:08.120 25730 25754 W System.err:    at java.lang.Thread.run(Thread.java:761)
10-30 17:02:08.124 25730 25749 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
10-30 17:02:08.124 25730 25749 E AndroidRuntime: Process: com.polarh7rr, PID: 25730
10-30 17:02:08.124 25730 25749 E AndroidRuntime: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Could not get BatchedBridge, make sure your bundle is packaged correctly
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:144)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at co.apptailor.Worker.WorkerModule.startWorker(WorkerModule.java:81)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:751)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:95)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:154)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:761)
10-30 17:02:08.124 25730 25749 E AndroidRuntime: Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Could not get BatchedBridge, make sure your bundle is packaged correctly
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.common.futures.SimpleSettableFuture.get(SimpleSettableFuture.java:68)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at co.apptailor.Worker.core.ReactContextBuilder.build(ReactContextBuilder.java:99)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at co.apptailor.Worker.JSWorker.runFromContext(JSWorker.java:35)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at co.apptailor.Worker.WorkerModule.startWorker(WorkerModule.java:72)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    ... 10 more
10-30 17:02:08.124 25730 25749 E AndroidRuntime: Caused by: java.lang.RuntimeException: Could not get BatchedBridge, make sure your bundle is packaged correctly
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.cxxbridge.CatalystInstanceImpl.loadScriptFromAssets(Native Method)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.cxxbridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.cxxbridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:177)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at co.apptailor.Worker.core.ReactContextBuilder$1.call(ReactContextBuilder.java:90)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$1.run(MessageQueueThreadImpl.java:74)
10-30 17:02:08.124 25730 25749 E AndroidRuntime:    ... 6 more
10-30 17:02:08.126 27236  3347 W ActivityManager:   Force finishing activity com.polarh7rr/.MainActivity

(my app's name is com.polarh7rr)

Even though the src/worker.js is empty, I keep receiving the exception above.

@therealgilles
Copy link

I'm having the same issue. WorkerManager.m looks like this:

NSURL *workerURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:name fallbackResource:nil];

How do I find out where I am supposed to write bundle for iOS?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants