joltup / react-native-threads Goto Github PK
View Code? Open in Web Editor NEWCreate new JS processes for CPU intensive work
License: MIT License
Create new JS processes for CPU intensive work
License: MIT License
I can't make it work in my projects. I tried with the latest RN, tried with older versions and always get the same error. What's interesting is that the sample project works fine.
Steps to reproduce:
react-native init TestApp
npm install
npm install react-native-threads
react-native link react-native-threads
Create new file index.thread.js
in the root.
Add
import { Thread } from 'react-native-threads';
and
componentDidMount () {
const thread = new Thread('./index.thread.js');
}
to App.js
react-native run-ios
You need to manually generate the bundle and add it to your app's assets. Example script for ios:
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./ios --entry-file index.thread.js --platform ios --bundle-output ./ios/index.worker.js
and android
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.thread.js --platform android --bundle-output ./android/app/src/main/ assets/index.thread.js
Hi,
Getting build error when running react-native run-android
/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/RNThreadModule.java:178: error: method createAssetLoader in class JSBundleLoader cannot be applied to given types;
return JSBundleLoader.createAssetLoader(reactApplicationContext, "assets://threads/" + jsFileSlug + ".bundle");
^
required: Context,String,boolean
found: ReactApplicationContext,String
reason: actual and formal argument lists differ in length
1 error
:react-native-threads:compileReleaseJavaWithJavac FAILED
"react": "16.0.0-alpha.12",
"react-native": "0.47.2",
"react-native-threads": "0.0.6",
Thanks
Hello,
Using this lib with the latest stable RN version 0.51.0 I have encoutered the following issue when trying to run an Android project
myproject/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ReactContextBuilder.java:57: error: constructor JSCJavaScriptExecutorFactory in class JSCJavaScriptExecutorFactory cannot be applied to given types;
JavaScriptExecutor jsExecutor = new JSCJavaScriptExecutorFactory().create();
^
required: String,String
found: no arguments
reason: actual and formal argument lists differ in length
1 error
:react-native-threads:compileReleaseJavaWithJavac FAILED
I have scoured the list of breaking changes since 0.49 but haven't managed to pinpoint the culprit.
I also haven't had the chance to try this on an IOS device.
Could I trouble you for a quick fix?
Thank you very much.
Hello,
Not an issue, mostly a question:
What I would like to know is if I start a thread in componentA
like so:
const thread = new Thread('worker.thread.js');
Then in componentB
run the same file:
const thread = new Thread('worker.thread.js');
Do I now have two threads running or a single one? Meaning do I have to terminate threads when unmouting my components or do all other components use the same thread, and so can I safely leave them?
Thank you.
First of all, thanks for reviving this, as indeed the other two modules do not seem to be maintained anymore!
But I've just tried to use this (on mac and ios), but haven't yet got it working. More annoying, there seems to be something stopping the packager from seeing updates I make.
Have you had any issues with the underlying watchman not picking edits?
Hi!
I'm trying a project with haul but I get 404s from haul dev server when it tries to fetch thread code.
Apparently in this issue @Traviskn made it work ( halp plz )
Any tips?
Thanks ๐
Platform: Android 8.0.0
Device: Samsung Galaxy S9+
React Native Version: 0.55.4
Thanks for this library. I am using realm with this. Is there anyway to know when a thread stops working? I am experimenting realm database writes through a thread. I Json.stringify(data) to send the thread message with data it should store in realm. They work at first but then the onmessage handler stops working after a while. No error messages. If there is a way to know when it stops working, I could possibly check and recreate the thread before I postMessage. Or at the very least fix whatever is causing the thread to stop working.
The specified project directory '\node_modules\react-native-threads\examples\SimpleExample\android' does not exist. Need to remove stuff in build that wants stuff like /Users/tnuttall/Dev/react-native-threads/examples/SimpleExample/node_modules/react-native-threads/android/src/main/res
I am not sure who tnuttall is or why my build folder has files that need SimpleExample anyway. There are a lot of build files in \node_modules\react-native-threads\android\build\intermediates\blame\res\release\multi , \node_modules\react-native-threads\android\build\intermediates\incremental\mergeReleaseJniLibFolders, and \node_modules\react-native-threads\android\build\intermediates\incremental\packageReleaseResources that reference tnutall and SimpleExample
Hi, this project seems to be what I need.
I'm relying on native events from a native modules coming through the bridge at a high rate. In my application right now, processing those events is slowing down the UI.
So I guess that offloading this to another JS engine instance makes sense.
Is this module working with RN 0.57.4?
Are we limited to strings exchanged in messages both ways? If so I guess I would have to stringify my objects.
Thanks in advance.
I'm trying to use this module together with andpor/react-native-sqlite-storage, but something's preventing it from initializing correctly.
The error I could extract from the thread is:
TypeError: undefined is not an object (evaluating 'NativeModules["SQLite"][method]')
Seems to be related to line 84 on lib/sqlite.core.js
that depends on the NativeModule
bind for that module.
Is there a limitation on this kind of operation? I couldn't find any reference to NativeModules
in the documentation.
I also found that NativeModules
is an empty object inside a thread.
Module | Version |
---|---|
React Native | 0.55.4 |
react-native-threads | 0.0.12 |
react-native-sqlite-storage | 3.3.6 |
The README asks you to re-create the filepath under the android assets folder, so replacing the "/" can cause errors in some cases where you want to keep it
Hi,
I am testing this library with a simple functionality where this thread would connect to a websocket server and send a message every 6 seconds through a timer, or relay whatever string is sent through worker.postmessage call.
However, the threads stop pinging to websockets if i lock the screen or navigate away from the RN app.
This is my primary requirement - to be able to use a few of these worker threads to do some background work irrespective of RN app being on focus or not
EXCEPTION Encountered after running in release mode!
12-09 03:02:47.959 8890-9842/? E/UncaughtException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to load script from assets 'threads/._index.thread.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.thread.js --platform android --bundle-output ./android/app/src/main/assets/threads/index.thread.bundle
/android/app/src/main/assets/threads
what could be the reason??
using 0.49.5 - RN version
Hi,
i call a native module in my thread but the callback doesn't response
All works perfectly, also if i call other functions of this module, but with this the callback was never emitted.
net.query('SELECT LinkedEntityId, ContentDocument.LatestPublishedVersion.VersionData FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM SM_News__c WHERE Active__c = true)', (resultQuery: any) => console.log(resultQuery));
In logcat i saw this.
W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketFailed",{"message":"connect timed out","id":5}])
"react": "^16.4.1",
"react-native": "^0.55.4",
"react-native-threads": "0.0.13",
In main thread works.
What can it be?
Thanks
Android seems to work, but when I run iOS, I see:
2017-10-06 15:21:28.391 [fatal][tid:com.facebook.react.WebSocketExecutor] Runtime is not ready for debugging. Make sure Packager server is running.
I'm not manually running a second packager, do I need to?
My react file:
import { Thread } from 'react-native-threads';
const thread = new Thread('threadfile.js');
thread.postMessage('Hello world');
thread.onmessage = (msg) => {
console.log(msg);
}
thread.terminate();
export default class Main extends Component {...
My threadfile.js
file:
import { self } from 'react-native-threads';
// listen for messages
self.onmessage = (message) => {
}
// send a message, strings only
self.postMessage('hello');
export default self;
I added the export default self;
when I got an error about only being able to import js files.
I am now getting the following error:
Error downloading thread script - Response(protocol=http/1.1, code=404, message-Not Found, url=http://localhost:5714/threadfile.bundle?platform=android&dev=true&hot=false&minify=false
The path to the threadfile (./threadfile.js
) is accessible from my React file for the building.
Hello
I'm trying to run my build in release mode for Android but the app keeps crashing, my plan is to run native code that I have made in C++ which works fine when I call it in debug mode.
In release mode I get:
--------- beginning of crash
2018-11-21 14:00:30.768 15410-15451/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.kulascope, PID: 15410
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to load script from assets 'threads/..worker.thread.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
This comes even though if I take out the native call and only do a simple post message inside the worker.thread.js which is the name of my worker.
I followed the simpleExample structure but it seems to be an issue there as well.
I have my worker.thread.bundle inside project/android/app/src/main/assets/threads/ and worker.thread.js in my project folder.
I ran the command
sudo node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file worker.thread.js --platform android --bundle-output ./android/app/src/main/assets/threads/worker.thread.bundle
I'm running
react-native: 0.55.2
react-native-threads: 0.0.13 I use this version in relation to this bug
What am I doing wrong ?
"react-native": "0.57.7"
"react-native-threads": "0.0.16"
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// Add jitpack repository (added by react-native-spinkit)
mavenLocal()
google()
maven {
url 'https://maven.google.com/'
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io" }
}
// buildDir = "C:/tmp/ArchisketchBuild"
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 26
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task wrapper(type: Wrapper) {
gradleVersion = '4.6'
distributionUrl = distributionUrl.replace("bin", "all")
}
15:10:23.826 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/debug/java', not found
15:10:23.827 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out', not found
15:10:23.829 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -source 1.7 -target 1.7 -d /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes -encoding UTF-8 -bootclasspath /Users/archidraw/Library/Android/sdk/platforms/android-28/android.jar:/Users/archidraw/Library/Android/sdk/build-tools/28.0.3/core-lambda-stubs.jar -s /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/build/generated/source/apt/debug -g -sourcepath -proc:none -XDuseUnsharedTable=true -classpath /Users/archidraw/.gradle/caches/transforms-1/files-1.1/react-native-0.57.7.aar/ff0c9480018d60b6759b31632becba47/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.facebook.infer.annotation/infer-annotation/0.11.2/f514ff4ca022a579d9cf7524846988b646ae4491/infer-annotation-0.11.2.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/8aca6f0074b449ecec0403d13f72f1fb/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/fresco-1.10.0.aar/ed141ba8f98be5fafdc9bce6810abd87/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/imagepipeline-okhttp3-1.10.0.aar/d04882a3a48a7c3492a2fa39da50ce36/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/drawee-1.10.0.aar/2e299005b0e6e7d9065390b7409897d7/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/imagepipeline-1.10.0.aar/a4c4121b114a66047b887d5c9b986c33/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/imagepipeline-base-1.10.0.aar/2bb7b7867d3b988a918b1e902b5d7e39/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/soloader-0.5.1.aar/94701a66bff78e211e8f978633836600/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp-urlconnection/3.11.0/54ec442e9c0fac51265110cf0cb44dfe5ad1ea05/okhttp-urlconnection-3.11.0.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.11.0/75966e05a49046ca2ae734e5626f28837a8d1e82/okhttp-3.11.0.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.14.0/102d7be47241d781ef95f1581d414b0943053130/okio-1.14.0.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/android-jsc-r174650.aar/b4f9ae872e96d0b7c4cec9cdb72b5176/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/support-fragment-27.1.1.aar/9fc01dd3e8ee08c938bd8db5ac34de17/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-27.1.1.aar/28d47cc12ba1a7dd3a1b7a26d72e350e/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/support-core-ui-27.1.1.aar/eeb67400df86cf28a12bc67a992c12dd/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/support-core-utils-27.1.1.aar/d3c28f096855a9213c9da89f61c29825/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-27.1.1.aar/74cee5e0fa3ba1ba1d0c906104f355d6/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/support-compat-27.1.1.aar/e617e190d9f8fdede723a32420abec36/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.android.support/support-annotations/27.1.1/39ded76b5e1ce1c5b2688e1d25cdc20ecee32007/support-annotations-27.1.1.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/fbcore-1.10.0.aar/1f9bbd7060af04db34be56c7fceea7f8/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/livedata-core-1.1.0.aar/de88dd6880386bd043d28eee84acf824/jars/classes.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/viewmodel-1.1.0.aar/798b31e38200623b6189480d8c3b897b/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-tasks/1.4.0/d85884acf6810a3bbbecb587f239005cbc846dc4/bolts-tasks-1.4.0.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/runtime-1.1.0.aar/3bce3c08856ba23feb11c8104d75fc4b/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/android.arch.lifecycle/common/1.1.0/edf3f7bfb84a7521d0599efa3b0113a0ee90f85/common-1.1.0.jar:/Users/archidraw/.gradle/caches/transforms-1/files-1.1/runtime-1.1.0.aar/4764e14eb413a7c91aef74df519dd142/jars/classes.jar:/Users/archidraw/.gradle/caches/modules-2/files-2.1/android.arch.core/common/1.1.0/8007981f7d7540d89cd18471b8e5dcd2b4f99167/common-1.1.0.jar:/Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/generateDebugRFile/R.jar /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/RNThreadPackage.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/RNThreadModule.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadSelfModule.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/UIManagerStubModule.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/JSThread.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ReactContextBuilder.java /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/build/generated/source/buildConfig/debug/com/reactlibrary/BuildConfig.java
15:10:23.829 [INFO] [org.gradle.api.internal.tasks.compile.JdkJavaCompiler] Compiling with JDK Java compiler API.
15:10:24.181 [ERROR] [system.err] /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ReactContextBuilder.java:11: error: package com.facebook.react.jscexecutor does not exist
15:10:24.181 [ERROR] [system.err] import com.facebook.react.jscexecutor.JSCExecutorFactory;
15:10:24.181 [ERROR] [system.err] ^
15:10:24.268 [ERROR] [system.err] /Users/archidraw/Documents/workspace/Jerry/APP-archisketch/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ReactContextBuilder.java:61: error: cannot find symbol
15:10:24.268 [ERROR] [system.err] JavaScriptExecutor jsExecutor = new JSCExecutorFactory(appName, deviceName)
15:10:24.268 [ERROR] [system.err] ^
15:10:24.268 [ERROR] [system.err] symbol: class JSCExecutorFactory
15:10:24.268 [ERROR] [system.err] location: class ReactContextBuilder
15:10:24.284 [ERROR] [system.err] 2 errors
15:10:24.285 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute compile for :react-native-threads:compileDebugJavaWithJavac'
15:10:24.288 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute compile for :react-native-threads:compileDebugJavaWithJavac' completed
15:10:24.288 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Fingerprinting property destinationDir (Output) for task ':react-native-threads:compileDebugJavaWithJavac'
15:10:24.289 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Fingerprinting property options.annotationProcessorGeneratedSourcesDirectory (Output) for task ':react-native-threads:compileDebugJavaWithJavac'
15:10:24.289 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
15:10:24.289 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':react-native-threads:compileDebugJavaWithJavac'
15:10:24.289 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Task :react-native-threads:compileDebugJavaWithJavac'
15:10:24.290 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 42: dispatching class org.gradle.launcher.daemon.protocol.BuildEvent
15:10:24.291 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :react-native-threads:compileDebugJavaWithJavac' completed
15:10:24.291 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :react-native-threads:compileDebugJavaWithJavac (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.514 secs.
15:10:24.291 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 5: released lock on :
15:10:24.292 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.83 completed (1 worker(s) in use)
15:10:24.292 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 5: released lock on root.1.83
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 5,5,main]] finished, busy: 0.716 secs, idle: 7.006 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 4,5,main]] finished, busy: 0.154 secs, idle: 7.568 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Daemon worker,5,main]] finished, busy: 1.49 secs, idle: 6.232 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 6,5,main]] finished, busy: 0.129 secs, idle: 7.593 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 3,5,main]] finished, busy: 3.939 secs, idle: 3.784 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':',5,main]] finished, busy: 0.547 secs, idle: 7.176 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 2,5,main]] finished, busy: 0.815 secs, idle: 6.908 secs
15:10:24.292 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 7,5,main]] finished, busy: 0.054 secs, idle: 7.667 secs
15:10:24.294 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskExecutionGraph] Timing: Executing the DAG took 7.733 secs
15:10:24.295 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Run tasks'
15:10:24.296 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 17: dispatching class org.gradle.launcher.daemon.protocol.BuildEvent
15:10:24.296 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Run tasks' completed
15:10:24.307 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:10:24.307 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:10:24.307 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:10:24.307 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':react-native-threads:compileDebugJavaWithJavac'.
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Compilation failed; see the compiler error output for details.
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
15:10:24.308 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
15:10:24.309 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 18s
com.facebook.react.jscexecutor does not exit
I think this is the last error I should solve before successfully upgrading to react-native 0.57.
Has anybody had this error? Please help me.
Thank you.
I'm using Typescript and a worker thread using a lot of modules.
I guess I should take the release route even for development to produce a correct javascript file to be used by this library. Am I wrong?
Hello,
I'm trying to use react-native-device-info lib with react-native-threads
on Android. In iOS works perfectly.
So I put on the MainApplication.java
the dependency for RNThreadPackage
new RNThreadPackage(
mReactNativeHost,
new RNDeviceInfo() <-- here
)
But throws this error:
When i try to use react-native-device-info
on main regular thread of the react-native, works perfectly, so i think that the installation of this native module it's ok and has any issue or conflict with react-native-threads
.
Somebody has any workaround or tip to help-me to investigate this issue?
Hi, In my app i have a side-menu as well which works perfectly fine for the android app, but in iOS the side-menu fails to render anything as soon as I start the thread by calling
this.thread = new Thread('Thread.js')
Now i cannot even debug from React-native-debugger/remote debugging as using it will cause thread itself to throw error package manager is not running which is already an open issue.
Is there something I am missing to initialise the app properly for iOS app.
Its not a RN 0.56 problem, rather actually putting the threads file in any Directory other than app root causes this.
const thread = new Thread('./services/contacts.js');
thread.onmessage = (message) => console.log(message);
Exception in native call
java.lang.RuntimeException: Exception downloading thread script to file
at com.reactlibrary.RNThreadModule.downloadScriptToFileSync(RNThreadModule.java:220)
at com.reactlibrary.RNThreadModule.createDevBundleLoader(RNThreadModule.java:175)
at com.reactlibrary.RNThreadModule.startThread(RNThreadModule.java:68)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.io.FileNotFoundException: /data/user/0/com.testproject/files/services/contacts (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
at okio.Okio.sink(Okio.java:181)
at com.reactlibrary.RNThreadModule.downloadScriptToFileSync(RNThreadModule.java:217)
at com.reactlibrary.RNThreadModule.createDevBundleLoader(RNThreadModule.java:175)ย
at com.reactlibrary.RNThreadModule.startThread(RNThreadModule.java:68)ย
at java.lang.reflect.Method.invoke(Native Method)ย
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)ย
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)ย
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)ย
at android.os.Handler.handleCallback(Handler.java:751)ย
at android.os.Handler.dispatchMessage(Handler.java:95)ย
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)ย
at android.os.Looper.loop(Looper.java:154)ย
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)ย
at java.lang.Thread.run(Thread.java:761)ย ```
I am experiencing an issue with threads in production/release.
2018-01-31 16:27:03.209993+0000 TestApp[72678:38924584] starting Thread (null)
2018-01-31 16:27:03.217 [fatal][tid:main] No bundle URL present.
Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
My Threads don't live in the root of the project, they live in ./App/Workers/*.thread.js
. I have also followed the documentation for building .jsbundle
files and adding them to ./ios
.
In development, everything works as expected:
2018-01-31 17:14:34.192937+0000 TestApp[75866:39010763] starting Thread http://localhost:8081/./App/Workers/Test.Generate.thread.bundle?platform=ios&dev=true&minify=false
2018-01-31 17:14:34.193 [info][tid:com.facebook.react.ThreadManagerQueue][RCTCxxBridge.mm:187] Initializing <RCTCxxBridge: 0x6080001b42e0> (parent: <RCTBridge: 0x60c0002a57c0>, executor: (null))
2018-01-31 17:14:34.193265+0000 TestApp[75866:39010763] Initializing <RCTCxxBridge: 0x6080001b42e0> (parent: <RCTBridge: 0x60c0002a57c0>, executor: (null))
Am I experiencing this issue because my thread files don't live in the root of the project?
I can see the the method below from ThreadSElfModule.java being called but the message does not reach the onmessage of main application:
@ReactMethod
public void postMessage(String data) {
if (parentContext == null) { return; }
parentContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("Thread" + String.valueOf(threadId), data);
}
Not sure where to go from here!!
@Traviskn Having created the bundle of the worker using your Building for Release instructions, with the default name index.thread.js
, I still see it being pulled down from the dev server and not using the offline bundle, whereas index.js
is not showing up and it is using the offline bundle main.jsbundle
.
Does anything need to modified in AppDelegate.m
to make mention of the thread webworker - index.thread.jsbundle
?
// jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"..."
initialProperties:nil
launchOptions:launchOptions];
I see that is what causes the offline bundle to be used for the main index.js
, but how does it know to use the offline bundle for the webworker index.thread.js
?
I tried a few solutions from google but nothing helps. The moment I add const thread = new Thread('./thread.js')
I get this error.
Since I'm running an ejected Expo error I tried getting the example running but that failed for completely different reason.
My dependencies:
"expo": "^30.0.0",
"expo-graphics": "1.0.0-alpha.1",
"expo-three": "3.0.0-alpha.1",
"expokit": "^1.7.1",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
"react-native-elements": "0.18.5",
"react-native-threads": "0.0.16",
Update: I made the examples work. I'll see if I can get it running using that.
Hi, I am having some trouble getting this plugin up and running with my project. I have basically copied the worker.thread.js
and then instantiate the worker much like in the example in the readme:
import { Thread } from 'react-native-threads'
console.log('hello')
export const hintWorker = () => {
// start a new react native JS process
const thread = new Thread('worker.thread.js')
// send a message, strings only
thread.postMessage('hello')
// listen for messages
thread.onmessage = (message: any) => console.log(message)
// stop the JS process
thread.terminate()
}
However, when I run hintWorker()
, I get an error-message, that it cannot find the NativeModules, which, as far as I know, is from React-Native. I guess it cannot find it inside the worker.thread.js
-file.
"react-native": "^0.51.0",
"react-native-threads": "^0.0.10",
Steps to reproduce:
:react-native-threads:processReleaseResources UP-TO-DATE
:react-native-threads:generateReleaseSources UP-TO-DATE
:react-native-threads:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:react-native-threads:compileReleaseJavaWithJavac
:react-native-threads:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/Rawsix/Documents/_Arbeit/Apps/react-native/wee-mobile/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java:38: error: constructor AndroidInfoModule in class AndroidInfoModule cannot be applied to given types;
new AndroidInfoModule(catalystApplicationContext),
^
required: no arguments
found: ReactApplicationContext
reason: actual and formal argument lists differ in length
1 error
:react-native-threads:compileReleaseJavaWithJavac FAILEDFAILURE: Build failed with an exception.
Did I miss something? Thanks for your help.
Hi,
I am creating a react native app, and I want to download some pdf files (Around 10, 2MB each) in the background. Do you think "react-native-threads" is a good solution for my use case?
I know this is not an Issue, but I did not know where to ask. I am sorry about that.
I am trying to build my application after adding your threads module when I build I am getting the following error.
:react-native-threads:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:react-native-threads:compileReleaseJavaWithJavac
:react-native-threads:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/sjain/Documents/Native_App/node_modules/react-native-threads/android/src/main/java/com/reactlibrary/ThreadBaseReactPackage.java:38: error: constructor AndroidInfoModule in class AndroidInfoModule cannot be applied to given types;
new AndroidInfoModule(),
^
required: ReactApplicationContext
found: no arguments
reason: actual and formal argument lists differ in length
1 error
:react-native-threads:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
I tried to do react-native link but thing is I am also using react-native-navigation
which has bit different implementation of MainApplication.java
file and thus its unable to get the context of ReactApplication.
Below is the implementation of my MainApplication.java file
`
public class MainApplication extends NavigationApplication {
@Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new RNThreadPackage()
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
@Override
public String getJSMainModuleName() {
return "index";
}
}
`
Hi, thank you for making this module. I've encountered an issue after compiling and launching my app. Here are some additional details.
"react": "^16.4.1",
"react-native": "^0.56.0",
"react-native-threads": "0.0.13"
worker.thread.js is in my root folder
I bundle it with the provided commands to assets/threads
The file is found and I am able to get a console log out of it. I have removed all code from the worker file, this is it:
import { self } from 'react-native-threads';
console.log('hello from worker');
console.log(self)
However, after the two console log lines, the app crashes and produces this error:
07-20 14:47:15.090 29399-29494/? I/ReactNativeJS: hello from worker
07-20 14:47:15.098 29399-29494/? I/ReactNativeJS: { onmessage: null, postMessage: [Function] }
07-20 14:47:15.107 29399-29494/? E/ReactNativeJNI: Got JS Exception: Exception calling object as function: Module RCTDeviceEventEmitter is not a registered callable module (calling emit) (:16)
Got JS Stack: exports@threads/worker.thread.bundle:16:463
value@threads/worker.thread.bundle:20:4039
threads/worker.thread.bundle:20:1019
value@threads/worker.thread.bundle:20:3440
value@threads/worker.thread.bundle:20:991
[native code]
--------- beginning of crash
07-20 14:47:15.108 29399-29494/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.fingersign, PID: 29399
java.lang.RuntimeException: Error calling RCTDeviceEventEmitter.emit
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.jni.CppException: Exception calling object as function: Module RCTDeviceEventEmitter is not a registered callable module (calling emit) (:16)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)ย
at android.os.Handler.handleCallback(Handler.java:739)ย
at android.os.Handler.dispatchMessage(Handler.java:95)ย
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)ย
at android.os.Looper.loop(Looper.java:148)ย
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)ย
at java.lang.Thread.run(Thread.java:818)ย
07-20 14:47:15.110 1607-5161/? W/ActivityManager: Force finishing activity com.fingersign/.MainActivity
I am not using postMessage or onmessage at all in the rest of my code, only registering the worker.
Everything works fine in dev mode, only release gets messed up after launching the app.
Would it be possible to point me in the right direction?
Hello, i'm trying to install this package and run on Android .
I'm getting the following error now :
:react-native-threads:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
mypath\node_modules\react-native-threads\android\src\main\java\com\reactlibrary\ReactContextBuilder.java:72: error: constructor NativeModuleRegistryBuilder in class NativeModuleRegistryBuilder cannot be applied to given types;
NativeModuleRegistryBuilder nativeRegistryBuilder = new NativeModuleRegistryBuilder(reactContext, this.instanceManager);
^
required: ReactApplicationContext,ReactInstanceManager,boolean
found: ReactApplicationContext,ReactInstanceManager
reason: actual and formal argument lists differ in length
1 error
:react-native-threads:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-threads:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Package
"react": "^16.5.2",
"react-native": "^0.55.4",
"react-native-threads": "0.0.15",
settings.gradle
include ':react-native-threads'
project(':react-native-threads').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-threads/android')
build.gradle
// in dependencies add :
compile project(':react-native-threads')
MainApplication.java
import com.reactlibrary.RNThreadPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new KDSocialShare(),
new RNThreadPackage(mReactNativeHost),
new ImageResizerPackage(),
new RNSensitiveInfoPackage(),
new RNFetchBlobPackage(),
new RNFSPackage(),
new SnackbarPackage(),
new MapsPackage(),
new PhotoViewPackage(),
new PickerPackage(),
new RNI18nPackage(),
new VectorIconsPackage(),
new RCTExifPackage(),
new OpenSettingsPackage(),
new GoogleAnalyticsBridgePackage());
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
any idea please ? thanks
i had this following issue when i run my app:
import com.facebook.react.bridge.JSCJavaScriptExecutor;
^
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:19: error: cannot find symbol
import com.facebook.react.devsupport.DevSupportManager;
^
symbol: class DevSupportManager
location: package com.facebook.react.devsupport
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:29: error: cannot find symbol
private DevSupportManager devSupportManager;
^
symbol: class DevSupportManager
location: class ReactContextBuilder
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:42: error: cannot find symbol
public ReactContextBuilder setDevSupportManager(DevSupportManager devSupportManager) {
^
symbol: class DevSupportManager
location: class ReactContextBuilder
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:128: error: cannot find symbol
private void addJSModules(JavaScriptModuleRegistry.Builder jsModulesBuilder) {
^
symbol: class Builder
location: class JavaScriptModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:137: error: cannot find symbol
private void addNativeModules(ReactApplicationContext reactContext, NativeModuleRegistry.Builder nativeRegistryBuilder) {
^
symbol: class Builder
location: class NativeModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/WorkerModule.java:16: error: cannot find symbol
import com.facebook.react.devsupport.DevSupportManager;
^
symbol: class DevSupportManager
location: package com.facebook.react.devsupport
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/WorkerModule.java:188: error: cannot find symbol
private DevSupportManager getDevSupportManager() {
^
symbol: class DevSupportManager
location: class WorkerModule
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/BaseReactPackage.java:11: error: cannot find symbol
import com.facebook.react.modules.core.JSTimersExecution;
^
symbol: class JSTimersExecution
location: package com.facebook.react.modules.core
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:53: error: package JSCJavaScriptExecutor does not exist
JavaScriptExecutor jsExecutor = new JSCJavaScriptExecutor.Factory().create(new WritableNativeMap());
^
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:62: error: cannot find symbol
NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder();
^
symbol: class Builder
location: class NativeModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:62: error: cannot find symbol
NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder();
^
symbol: class Builder
location: class NativeModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:66: error: cannot find symbol
JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder();
^
symbol: class Builder
location: class JavaScriptModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:66: error: cannot find symbol
JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder();
^
symbol: class Builder
location: class JavaScriptModuleRegistry
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/ReactContextBuilder.java:131: error: cannot find symbol
for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
^
symbol: method createJSModules()
location: variable reactPackage of type ReactPackage
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/WorkerPackage.java:21: error: method does not override or implement a method from a supertype
@Override
^
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/WorkerModule.java:180: error: no suitable method found for createFileLoader(ReactApplicationContext,String)
return JSBundleLoader.createFileLoader(getReactApplicationContext(), "assets://workers/" + jsFileSlug + ".bundle");
^
method JSBundleLoader.createFileLoader(String) is not applicable
(actual and formal argument lists differ in length)
method JSBundleLoader.createFileLoader(String,String,boolean) is not applicable
(actual and formal argument lists differ in length)
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/BaseReactPackage.java:42: error: constructor AndroidInfoModule in class AndroidInfoModule cannot be applied to given types;
new AndroidInfoModule(),
^
required: ReactApplicationContext
found: no arguments
reason: actual and formal argument lists differ in length
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/BaseReactPackage.java:46: error: cannot find symbol
new SourceCodeModule(reactInstanceManager.getSourceUrl()),
^
symbol: method getSourceUrl()
location: variable reactInstanceManager of type ReactInstanceManager
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/BaseReactPackage.java:61: error: method does not override or implement a method from a supertype
@Override
^
/home/mohamed/Desktop/izisystem/izicheck/node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/core/BaseReactPackage.java:65: error: cannot find symbol
JSTimersExecution.class,
^
symbol: class JSTimersExecution
location: class BaseReactPackage
21 errors
Hello again,
Is it possible to require a module in the thread? Something like:
import _ from 'lodash'
self.onmessage = message => {
//
}
Thank you.
With the latest version of react native, the module import of Thread returns undefined. Any advise?
Hello again,
I trying to check the release version of my app after using Thread module in one of the pages and I have followed the steps to compile my thread.js
and support.js
file as per the command give accordingly and it generates the file as well, now when I open the page which is associated with this Thread module my app closes and tried removing it form the page and it works fine.
So probably I there might be some issue while building the bundle file.
PS: I have 2 thread worker files and I have compiled both the files.
Is there anything else I have to do for multiple files ?
And just FYI: in your simpleexample folder in package.json
the command for build-thread-android has spacing in folder names hence does not work.
This is the line
I can't build my project after having added this library:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 29 more
Caused by: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:127)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 41 more
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: com.reactlibrary.BuildConfig
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87)
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:114)
... 44 more
Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: com.reactlibrary.BuildConfig
at com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64)
at com.android.tools.r8.utils.ProgramClassCollection.lambda$create$0(ProgramClassCollection.java:25)
at com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24)
at com.android.tools.r8.graph.LazyLoadedDexApplication$Builder.build(LazyLoadedDexApplication.java:121)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:122)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110)
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83)
... 45 more
* Get more help at https://help.gradle.org
It seems that unlike the main js thread, the console.log
statements (from the new thread) output is not printed in the logcat logs...
Is there a simple way to solve that?
Hello.
My react native app is integrated with a pre-existing android native application.
So, I've followed the steps explained in this link.
http://facebook.github.io/react-native/docs/integration-with-existing-apps
The problem is that
When I try to link react-native-threads package upon this basis, I don't have a certain argument to feed.
The bridging activity starts like this.
public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
// The string here (e.g. "MyReactNativeApp") has to match
// the string in AppRegistry.registerComponent() in index.js
mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null);
setContentView(mReactRootView);
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
}
As explained in the Readme file of this package,
Also note that only the official react native modules are available from your threads (vibration, fetch, etc...). To include additional native modules in your threads, pass them into the RNThreadPackage constructor after the mReactNativeHost like this: new RNThreadPackage(mReactNativeHost, new ExampleNativePackage(), new SQLitePackage())
I tried to feed "mReactNativeHost".
At first, I tried this code
private ReactRootView mReactRootView;
...
mReactNativeHost = ((ReactApplication) getApplication()).getReactNativeHost();
...
new RNThreadPackage(mReactNativeHost, new BlePackage())
However, this gives me the log like this:
android.app.Application cannot be cast to com.facebook.react.ReactApplication
I know this is more about the general knowledge on android.
But I'm trying to run bluetooth communication on another process using this package.
So, please help me if any of you guys had an experience like this.
Thank you.
If I import native modules in worker.thread.js
(from SimpleExample)
import { self } from 'react-native-threads';
import { UIManager } from 'react-native'; // <------ this line
import './config';
let count = 0;
console.tron.log(`MANAGER ${UIManager}`); // <------ and another one
self.onmessage = message => {
console.tron.log(`THREAD: got message ${message}`);
count++;
self.postMessage(`Message #${count} from worker thread!`);
}
thread fails with UIManager is undefined. The native module config is probably incorrect.
.
I was under impression that UIManagerStubModule (and other modules declarations here) should have fixed this, but error still appears.
i'm trying to install lib with Mostly automatic installation
just running react-native link react-native-threads
. I've cleaned up my app and rebuild, and:
So i can confirm that the lib has attached on Libraries folder:
But libRNThread.a
is missing on Link Binary With Libraries
.
So.. the command react-native link react-native-threads
is missing to attach libRNThread.a
on Link Binary With Libraries
?
Hi, Im using this thread lib on the react facebook example app.
When I press the back button from the main screen of my app the app goes to background (terminates kind-of). Thats the default behavior as far as i know.
The problem is, when this happens, the onHostDestroy
method gets called. So the threads are terminated.
When I re-enter the app, nothing gets created, as the app is in a intermediate state, so the threads arent re-created. Instead a onHostResume
gets called.
For now i have fixed this by changing the onHostDestroy
method just to call onHostPause
. But i dont know if this is a good long term solution.
Oneplus 6 Android 8.1.0
NativeModuleRegistryBuilder remove addNativeModule method
I am having issues getting Threads running on a device either in Development or in Release mode.
I have three files within App/Workers/*.thread.js
. I am alerting within the Thread also for debugging purposes and it never appears when I run any three of these threads on a device.
Any ideas to where I am going wrong?
I have everything working as long as the package manager is running. But as soon as I try to build for production, or indeed even just bundle the thread with --dev true, it fails to load the bundled thread code.
Looking through the logs, I noticed this:
starting Thread file:///var/containers/Bundle/Application/0C3714D5-035B-480F-A9A7-4D2455ECF6BA/MyApp.app/main.jsbundle
My thread entry point is navigator.js (and output as well)... Which would imply that the fallback incorrectly falls back to the name "main" causing it to load the wrong JS bundle?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.