ericwlange / AndroidJSCore

AndroidJSCore allows Android developers to use JavaScript natively in their apps.
468 stars 78 forks source link

Create new JSContext makes application busy forever #27

Closed wkh237 closed 8 years ago

wkh237 commented 8 years ago

I'm using this library to make a React Native module, when I try to create a JSContext instance, the whole application just hanged.

I looks like the process stopped after executes the constructor

new JSContext();

I've tried to put the line into a thread, but it still happens. Is there any suggestion on this ?

Many thanks.

ericwlange commented 8 years ago

Are you using the latest release (3.0-pre1)?

How are you using this with React Native?

Any Dalvik logs that can give any hints?

wkh237 commented 8 years ago

Hi @ericwlange , I'm using 3.0-pre1, I just write a module which following the instructions of official document.

@ReactMethod
  public void createJSContext(
     JSContext ctx = new JSContext(); // <-- application stucks here
  }

I tried to find useful informations from log, but it doesn't log anything. I've create a sample react-native project that can reproduce this problem. If it is convenient your may clone the repository and try to run the project.

The implementation is in this file.

ericwlange commented 8 years ago

Thanks. I will take a look. I've never used it alongside React Native, so I fear there may be a native library conflict. Have you tried to use it without React Native? Can you confirm that it doesn't hang when the react SDK is not present?

On Monday, June 13, 2016, wkh237 notifications@github.com wrote:

Hi @ericwlange https://github.com/ericwlange , I'm using 3.0-pre1, I just write a module which following the instructions of official document https://facebook.github.io/react-native/docs/native-modules-android.html.

@ReactMethod public void createJSContext( JSContext ctx = new JSContext(); // <-- application stucks here }

I tried to find useful informations from log, but it doesn't log anything. I've create a sample react-native project https://github.com/wkh237/rn-android-jsc-issue that can reproduce this problem. If it is convenient your may clone the repository and try to run the project.

The implementation is in this file https://github.com/wkh237/rn-android-jsc-issue/blob/master/android/app/src/main/java/com/sample/AndroidJSCModule.java#L30-L34 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ericwlange/AndroidJSCore/issues/27#issuecomment-225477915, or mute the thread https://github.com/notifications/unsubscribe/ABIuZMyqfCzaZRBuuVSnMlp8t0ePAm6Jks5qLMEQgaJpZM4IzkDD .

ericwlange commented 8 years ago

This is confirmed as working in 3.0.1. BTW, you left .show() off the end of your Toast.makeText() lines. I am not sure if you were expecting them to display or not. In any case, I have verified that it plays nice with React Native.