Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug index.worker.js #10

Open
apuyapuy opened this issue May 7, 2017 · 13 comments
Open

Debug index.worker.js #10

apuyapuy opened this issue May 7, 2017 · 13 comments

Comments

@apuyapuy
Copy link

apuyapuy commented May 7, 2017

big thanks, this is a nice componen... its really help me to create a background service...

every time i want to test my index.worker.js using this script :
node node_modules/react-native/local-cli/cli.js start --reset-cache
node node_modules/react-native/local-cli/cli.js start --port 8082 --reset-cache
concurrently --kill-others "npm run start-app" "npm run start-worker"
adb reverse tcp:8081 tcp:8081 && adb reverse tcp:8082 tcp:8082
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.android.js --platform android --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./sourcemap/android.main.map
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.worker.js --platform android --bundle-output ./android/app/src/main/assets/index.worker.bundle --sourcemap-output ./sourcemap/android.worker.map
npm run bundle-app-android && npm run bundle-worker-android
concurrently --kill-others "npm run bundle-ios" "run bundle-android\

but i can not debug...

can u give me the tutorial to debug my index.worker.js file?

thanks in advanced

@fabriciovergara
Copy link
Owner

Sorry for my absence, my work and freelances was making me crazy.
I'll start working in this project again this week.

Runnning on Android you should be able to debug by enabling the debug mode with a shake as usual.
Will show up 2 dialogs, one is for the main bundle and another for the worker, I don't remember the order.

On iOS since all modules are "singletons", if you enable debug mode for one, it will enable for the worker.

@apuyapuy
Copy link
Author

hi...
thanks for the reply

is it true if i want to change my code on worker then i must re-run this script:
node node_modules/react-native/local-cli/cli.js start --reset-cache
node node_modules/react-native/local-cli/cli.js start --port 8082 --reset-cache
concurrently --kill-others "npm run start-app" "npm run start-worker"
adb reverse tcp:8081 tcp:8081 && adb reverse tcp:8082 tcp:8082
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.android.js --platform android --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./sourcemap/android.main.map
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.worker.js --platform android --bundle-output ./android/app/src/main/assets/index.worker.bundle --sourcemap-output ./sourcemap/android.worker.map
npm run bundle-app-android && npm run bundle-worker-android
concurrently --kill-others "npm run bundle-ios" "run bundle-android\

@fabriciovergara
Copy link
Owner

fabriciovergara commented May 15, 2017

if it is in debug mode, you should be able to reload the code using "Reload" in the shake menu.
But the library is still a little unstable since running another "Application" in a environment where there is a lot of share instances between main bundle and worker bundle.

@apuyapuy
Copy link
Author

wow...great info for me...

my application have realm database...
how can i query to realm database from my index.worker.js

when i put this code
"import realm from 'realm'"
then red screen show up with this comment:
"missing realm constructor - please ensure RealmReact framework is included"

my goal with this worker is check to my realm database
if flag_uploadstatus 0 then i upload to my api using axios...

@fabriciovergara
Copy link
Owner

fabriciovergara commented May 15, 2017

I don't like to give bad news, but...
I already tried to use realm using workers and was veeeeeeeeery unstable, on iOS I could not even generate a release version.

On Android you need to add the RealmPackage using RNWorker.Builder and you should not load the realm package in your main bundle.

      final RNWorker worker = new RNWorker.Builder(this, false)
      .entryPoint(RNWorker.DEFAULT_JS_ENTRY_POINT)
      .bundleAsset(RNWorker.DEFAULT_JS_BUNDLE_ASSET)
      .port(8088) //Realm already use 8082 to load a nano server to connect to chrome debug
      .packages(
        new RealmReactPackage()
      ).build();

@apuyapuy
Copy link
Author

so the conclusion i can query from worker "ON ANDROID", but its unstable...
so sad to here it...

finally thanks for the information...
great component... i believe i would be better...
i will waiting for the stable one....
good job bro

you have any advice to run background service like case that i faced?

@fabriciovergara
Copy link
Owner

No, sorry :(

In my project I was even considering using native realm instead of realm-js because of the chrome debug performance.

@nbergen
Copy link

nbergen commented Jun 5, 2017

@fabriciovergal, is this caused by the realmjs requirement for the tx to be sourced from the main thread?

@fabriciovergara
Copy link
Owner

Actually I could not find exactly why its not work.
Running on development environment I managed to make it work (after a long time trying), but when I tried to generate a release, the application was crashing on start with meaningless logs.

On iOS was even more problematic, because I could not found a way to keep the main bundle with debug mode on and the worker with debug mode off, because this settings is managed by a singleton object. And with it, come the chrome debug performance issue.

@nbergen
Copy link

nbergen commented Jun 6, 2017

Yes, that chrome debugging perf makes it almost unusable.

@MaximusBaton
Copy link

Great library!
But really sad to know that it's not working with realm....

@apuyapuy
Copy link
Author

Hi Fabricio,
im still working with realm on native android...
but i cannot make it work...

would u share how i can query my react native DB with native realm on android and ios..
thanks

@nbergen
Copy link

nbergen commented Nov 16, 2017

@apuyapuy, before I switched earlier this year, realmdb didn't support cross-thread access in realmjs.

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

No branches or pull requests

4 participants