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

Engine release #340

Open
AsyncProxy opened this issue May 16, 2024 · 14 comments
Open

Engine release #340

AsyncProxy opened this issue May 16, 2024 · 14 comments

Comments

@AsyncProxy
Copy link

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.

@caoccao
Copy link
Owner

caoccao commented May 16, 2024

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.

@DeekeScript
Copy link

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循环啊

@AsyncProxy
Copy link
Author

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.

@caoccao
Copy link
Owner

caoccao commented May 17, 2024

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.

@AsyncProxy
Copy link
Author

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

@caoccao
Copy link
Owner

caoccao commented May 17, 2024

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.

@AsyncProxy
Copy link
Author

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!

@AsyncProxy
Copy link
Author

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.

@caoccao
Copy link
Owner

caoccao commented May 17, 2024

Please show me the code.

@AsyncProxy
Copy link
Author

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

@AsyncProxy
Copy link
Author

请给我看代码。

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.

@caoccao
Copy link
Owner

caoccao commented May 17, 2024

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

@AsyncProxy
Copy link
Author

没有 JS 代码,很难分辨。

let hello = 'hello world'

JS code has only one sentence at its most basic

@AsyncProxy
Copy link
Author

没有 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.

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

No branches or pull requests

3 participants