-
Notifications
You must be signed in to change notification settings - Fork 9
Android: Run Node.js in a view model coroutine #982
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
base: master
Are you sure you want to change the base?
Conversation
benbucksch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot really review this code well, because it's too deep in Android, JNI, node.js. I looked as well as I could, but my review is necessarily only on the surface.
Looks OK to me. Just a few nits.
Only major question is: Do we need to shut down node.js?
|
|
||
| // Register your class' native methods. | ||
| static const JNINativeMethod methods[] = { | ||
| {"startNode", "([Ljava/lang/String;)I", reinterpret_cast<jint*>(startNode)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no shutdown needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to shutdown Node.js since job.cancel() does shutdown the process. Unfortunately, the node::Start() does not return an env variable required by the node::Stop() function. But I've not seen any issues so far even after restarting the app immediately.
mobile/android/app/src/main/java/im/mustang/capa/nodeprocess/FileOperations.kt
Outdated
Show resolved
Hide resolved
mobile/android/app/src/main/java/im/mustang/capa/nodeprocess/NodeProcess.kt
Outdated
Show resolved
Hide resolved
mobile/android/app/src/main/java/im/mustang/capa/nodeprocess/NodeProcess.kt
Outdated
Show resolved
Hide resolved
mobile/android/app/src/main/java/im/mustang/capa/nodeprocess/NodeProcess.kt
Outdated
Show resolved
Hide resolved
mobile/android/app/src/main/java/im/mustang/capa/nodeprocess/NodeProcess.kt
Outdated
Show resolved
Hide resolved
| implementation project(':capacitor-camera') | ||
| implementation project(':capacitor-filesystem') | ||
| implementation project(':capacitor-splash-screen') | ||
| implementation project(':capacitor-status-bar') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this come from?
If this is needed, it should be a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was from when we added the Capacitor Status Bar plugin and the changes in this file was not committed. I'll remove this. But this will be added anyways when you do cap sync.
| include ':capacitor-splash-screen' | ||
| project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android') | ||
|
|
||
| include ':capacitor-status-bar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also from cap sync. This is will still work even if it's not committed, do we still want to commit changes like this in the future? But I'm not sure if it'll still work if the file is not present in the git history but the changes don't need to be committed.
Co-authored-by: Ben Bucksch <[email protected]>
|
I've made some fixes:
Node.js Mobile doesn't seem to support |
.jsfiles