★ wanayoo — archive 1999 https://github.com/NativeScript/android-runtime/pull/1587Nouvelle recherche | Portail wanayoo
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

DO NOT MERGE: Multithreaded javascript #1587

Merged
merged 2 commits into from Aug 29, 2020
Merged

DO NOT MERGE: Multithreaded javascript #1587

merged 2 commits into from Aug 29, 2020

Conversation

@darind
Copy link
Member

@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.
- JNI calls are now thread safe
- Ability to retrieve the runtime from the currently entered isolate
@saschaarthur
Copy link
Contributor

@saschaarthur saschaarthur commented May 27, 2020

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

@darind
Copy link
Member Author

@darind 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

@farfromrefug farfromrefug commented Jul 26, 2020

@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
Copy link
Member

@NathanaelA NathanaelA commented Jul 27, 2020

@farfromrefug - It looks like it is enabled by default; but we could merge it and then set the flag to disabled by default.

However, before I merge it I need to get the automated tests all working again so that I can make sure that even with this flag disabled that everything still works.

Getting the testing all working properly is high on my list to try and get working, but I do have a couple other android issues that also need to be tracked down, so it depends on how quickly I can get these issues tracked down and fixed will decide how quickly this gets merged. 😀

I personally want to see this in NS 7, and enabled by default -- but we might have to settle for merged in NS7, but disabled by default...

@NathanaelA NathanaelA self-requested a review Jul 27, 2020
@NathanaelA NathanaelA self-assigned this Jul 27, 2020
@farfromrefug
Copy link

@farfromrefug farfromrefug commented Jul 27, 2020

@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

@triniwiz triniwiz commented Jul 28, 2020

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

@NathanaelA NathanaelA merged commit 64cad4c into master Aug 29, 2020
3 checks passed
3 checks passed
ci/jenkins/android-runtime PASSed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
verification/cla-signed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.