joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
754 stars 140 forks source link

Exception calling object as function: Module RCTDeviceEventEmitter is not a registered callable module #40

Open kevex91 opened 6 years ago

kevex91 commented 6 years ago

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?

Traviskn commented 6 years ago

We've yet to test this package with react-native 56, it could be we need to update our java/android code to be compatible with the new release. Do you see this error on iOS as well?

kevex91 commented 6 years ago

Yeah I updated a bit too soon. Unfortunately, I have only tested this on Android since my project is Android only. I ended up finding a solution with a bridge and native code in the end.

react-native 56 uses Android API 26 for builds, this could be the issue?

I'll be waiting for that react-native 56 support though =).