caoccao/Javet

Engine release

Opened this issue · 14 comments

When the V8Node uses the close method to release and shut down the engine, it takes effect on the timer, but it cannot take effect for while loops, and it will continue to execute and cannot forcibly kill the engine.

The JS app is supposed to clear all timers. If you don't clear timers, you'll hang Node.js too. It's not a Javet feature.

When the V8Node uses the close method to release and shut down the engine, it takes effect on the timer, but it cannot take effect for while loops, and it will continue to execute and cannot forcibly kill the engine.

@AsyncProxy 你要的是v8Runtime.terminateExecution();么? 这个我看可以中断while循环啊

When the V8Node uses the close method to release and shut down the engine, it takes effect on the timer, but it cannot take effect for while loops, and it will continue to execute and cannot forcibly kill the engine.

@AsyncProxy 你要的是v8Runtime.terminateExecution();么? 这个我看可以中断while循环啊

This can be stopped, thank you, but I need an API that can force stop the engine directly, and it seems that after I started the http service, it didn't work.

You may notify that http server to exit by sending an event from another thread. Modern http servers should have such API to exit elegantly. Please do your research.

You may notify that http server to exit by sending an event from another thread. Modern http servers should have such API to exit elegantly. Please do your research.

I've tried sending signals, but the script code is uncontrollable, I've tried using Process.kill and Android methods before to force the kill, but in doing so, the android accessibility service will also be killed in the same process as this script binding, I can't think of any other way

I plan to add a new API to send a signal to the Node.js event loop to break that endless wait. Please be patient.

I plan to add a new API to send a signal to the Node.js event loop to break that endless wait. Please be patient.

Okay, I'm looking forward to it!

I plan to add a new API to send a signal to the Node.js event loop to break that endless wait. Please be patient.

Your updated version 3.1.2 my engine doesn't work anymore and nothing responds.

Please show me the code.

Please show me the code.

public static NodeRuntime V8Node;
public static JavetProxyConverter javetProxyConverter;

V8Node = V8Host.getNodeInstance().createV8Runtime();
javetProxyConverter = new JavetProxyConverter();
javetProxyConverter.getConfig().setReflectionObjectFactory(new IJavetReflectionObjectFactory() {
        @Override
         public Object toObject(Class<?> type, V8Value v8Value) {
               return null;
        }
 });

 V8Node.setConverter(javetProxyConverter);
 JavetJVMInterceptor javetJVMInterceptor = new JavetJVMInterceptor(V8Node);
 javetJVMInterceptor.register(V8Node.getGlobalObject());
 V8Node.allowEval(true);

V8ValuePromise promise = V8Node.getExecutor(data).setResourceName(com.editor.async.files.file.getName(file)).setModule(true).execute();

     
 V8Node.await();

  javetJVMInterceptor.unregister(V8Node.getGlobalObject());

  System.gc();
  System.runFinalization();

  V8Node.lowMemoryNotification();

In 3.1.1 it still works

请给我看代码。

Now since Node.js can't force it to be terminated, I have to separate the AccessibilityService and Activity from the process, otherwise once they are bound together, Process.killProcess will all be killed, but it will be difficult to communicate separately.

Without the JS code, it's hard to tell.

没有 JS 代码,很难分辨。

let hello = 'hello world'

JS code has only one sentence at its most basic

没有 JS 代码,很难分辨。

I started the Node.js in the Service and injected the AccessibilityService object into the engine, but the android:process must be bound together, but stopping the engine became a problem, if I used Process.kill it all killed, I don't have a clue.