Skip to content

Conversation

darind
Copy link
Collaborator

@darind darind commented Feb 14, 2020

In this PR we are introducing the enableMultithreadedJavascript feature flag which allows to execute javascript code from arbitrary threads.

Consider the following example:

new java.lang.Thread(new java.lang.Runnable({
    run() {
        const mainLooper = android.os.Looper.getMainLooper();
        const currentLooper = android.os.Looper.myLooper();
        const isMainThread = currentLooper === mainLooper;
        console.log(isMainThread); // should print false
    }
})).start();

We have identified 3 tasks to implement the feature:

  • Introduce v8::Locker objects to ensure re-entrancy of the V8 isolates
  • Thread-safe JNI
  • Runtime.currentRuntime should not rely on ThreadLocal storage only. When running on a background thread it should retrieve the runtime from the currently entered V8 isolate.

@cla-bot cla-bot bot added the cla: yes label Feb 14, 2020
@darind darind mentioned this pull request Feb 14, 2020
- JNI calls are now thread safe
- Ability to retrieve the runtime from the currently entered isolate
@saschaarthur
Copy link
Contributor

whats the progress on this here?
Looks like a nice Feature..

@darind
Copy link
Collaborator Author

darind commented May 27, 2020

This PR was created as a POC to demonstrate the technical feasibility of this concept. Enabling it would break existing plugins and we are not planning on doing that at the moment. You may try it out in your application and report if you are experiencing any issues or performance improvements.

@farfromrefug
Copy link
Contributor

@darind @NathanaelA Seeing this is not enabled by default. Could we merge it ? A user would have to know what he is doing as it would mean enabling in the package.json.

@NathanaelA

This comment was marked as abuse.

@farfromrefug
Copy link
Contributor

@NathanaelA agree about tests! About enabled by default in 7.0 i would be careful, we would need to test it in multiple and different production apps . As Darin said plugins would need to handle that correctly.

@triniwiz
Copy link
Member

It can be on by default for 8.x that should give plugin authors some time to update their plugins

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

Successfully merging this pull request may close these issues.

5 participants