V5.38 - Feedback

MacroDroidDev

Administrator
Staff member
For obvious bugs, please use report a bug in troubleshooting section with a clear description.

For other issue and discussions (related only to this beta), please leave all feedback here.
 

sampleuserhere

Active member
Fatal error occurs when switching from app A, to app B, back to app A. Related to accessibility service.

Here's the logcat in MIUI13.

Code:
FATAL EXCEPTION: main
Process: com.arlosoft.macrodroid, PID: 4646
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.view.accessibility.AccessibilityNodeInfo.getPackageName()' on a null object reference
 at com.arlosoft.macrodroid.triggers.services.MacroDroidAccessibilityService.onAccessibilityEvent(MacroDroidAccessibilityService.java:40)
 at android.accessibilityservice.AccessibilityService$2.onAccessibilityEvent(Unknown Source:2)
 at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.executeMessage(Unknown Source:276)
 at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(Unknown Source:4)
 at android.os.Handler.dispatchMessage(Unknown Source:19)
 at android.os.Looper.loopOnce(Unknown Source:176)
 at android.os.Looper.loop(Unknown Source:77)
 at android.app.ActivityThread.main(Unknown Source:138)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
 at com.android.internal.os.ZygoteInit.main(Unknown Source:306)

This error killed Macrodroid, when I checked through dumpsys activity exitinfo, MD has reason with 1 as the value, and subreason goes with 0.

Here's the screenrecord when it happened.


Anyway, a game changer has just arrived! native Javascript action! Thankyou!
 

Quidn

Passionate Member
Added JavaScript action (Beta).
When I found it on the translations, I was so excited and very curious about how the JavaScript Code action will be implemented and which engine will be used.
I really couldn't expected the request would immediately applied to the 5.38. 😆

Hermes seems viable to be an alternative. It's open source(MIT license) too and made by the Meta(Facebook) so it's likely not to be discontinued near future. Android-Hermes shows how Hermes can be used as a JavaScript interpreter in Android.
Is it the Hermes? I'm not sure that it is, but it's not LiquidCore and doesn't seem like WebView.
I want to propose related features and improvements which were compatible and suitable to the engine used!

There's one more thing, Privacy Policy seems fixed now.
 

MacroDroidDev

Administrator
Staff member
Hermes seems viable to be an alternative. It's open source(MIT license) too and made by the Meta(Facebook) so it's likely not to be discontinued near future. Android-Hermes shows how Hermes can be used as a JavaScript interpreter in Android.
Unfortunately that Android-Hermes project is nothing more than a blank template Android project created by Android Studio. There is no content whatsoever in that.
 

Quidn

Passionate Member
The JavaScript engine is currently using this: https://developer.android.com/jetpack/androidx/releases/javascriptengine

I have labelled it as beta for now as I'm open to feedback and possibly changing the engine if better options are available.
Honestly I didn't thought that the Jetpack's new one is also a very core "engine", because of its codebase and history. But now I realized that it was really an "engine".

One of my concern was whethet it's too early stage to be used widely. But after doing few tests, currently I don't see any reason to change it to another. I'll test more and see it works stable.

It will needs a few polyfill APIs but this will be same to Hermes. Now I think there's possibility that this one would be the best choice especially for long-term aspect.
 

MacroDroidDev

Administrator
Staff member
Honestly I didn't thought that the Jetpack's new one is also a very core "engine", because of its codebase and history. But now I realized that it was really an "engine".

One of my concern was whethet it's too early stage to be used widely. But after doing few tests, currently I don't see any reason to change it to another. I'll test more and see it works stable.

It will needs a few polyfill APIs but this will be same to Hermes. Now I think there's possibility that this one would be the best choice especially for long-term aspect.
I'm not sure at this stage. The good thing is that it doesn't add massive amounts of bulk to the APK size as I think it just exposes functionality already on the device. I have seen crashes from devices that don't support running javascript through it so I may have to provide an alternative engine. I'm looking into it further as I don't know much about this area right now.

I just tried adding Liquid Core library and it adds about 8MB to the APK size. I'd rather avoid this level of bloat if I can.
 

sampleuserhere

Active member
5.38.2 fixes the crash, thankyou!

Definitely game changer.
Maybe if you could access the internet though.. Unless I'm supposed to use another method ?
View attachment 7221

You're on track.

It seems that fetch is not available in the engine, I couldn't find DOMParser too. I haven't checked the others though.


I just tried adding Liquid Core library and it adds about 8MB to the APK size. I'd rather avoid this level of bloat if I can

What about the functionalities though? Does it offer more stuff than the current one?
 

Quidn

Passionate Member
I think it just exposes functionality already on the device. I have seen crashes from devices that don't support running javascript through it
Hmm... That's weird and unexpected. I too will check about that. I knew it shares some code with Webview, but I didn't expect it would work like using a Webview instance.

I just tried adding Liquid Core library and it adds about 8MB to the APK size. I'd rather avoid this level of bloat if I can.
Now I found out that you are considering replacing the engine and already have tried it, so I will seriously do more research. 🧐
 

Quidn

Passionate Member
It seems that fetch is not available in the engine, I couldn't find DOMParser too.
That's not because of the engine.

Does it offer more stuff than the current one?
Not at all likely. However that couldn't be a criterion to choose an engine. Maybe you will not catch any differences between engines. Engines are just engines. You will find the reason when you read the JavaScript specs and what I said above.
 

sampleuserhere

Active member
The console output (Javascript action) seems to have different value with the assigned variable, especially when it involves "\n" and "\\n".

Console output.
Screenshot_2023-10-19-20-18-12-098_com.arlosoft.macrodroid.png

Assigned variable.
Screenshot_2023-10-19-20-18-23-254_com.arlosoft.macrodroid.png

"\n" was missing in the first line. "\\n" was missing in the third line, "\n" was returned though.

The code.
Code:
const inputText = `1,one\\n2,two
three`;

var json = {};
json["inputText"] = inputText;
console.log(inputText+`
`);
console.log(JSON.stringify(json));
 

Attachments

  • ##test.macro
    1.4 KB · Views: 7

Quidn

Passionate Member
The console output (Javascript action) seems to have different value with the assigned variable, especially when it involves "\n" and "\\n".
I don't think this is specifically relevant to this beta and the new JavaScript Code action.
Issue about handling "\n" is a common characteristic of MacroDroid which you will found in everywhere related to input/output or manipulation. It's mixed up with a few different issues. I planned to post a feature request about this.
 

MacroDroidDev

Administrator
Staff member
I have a question that I have been wanting to confirm and give you feedback on. After Android 13 and above, WIFI permissions and location permissions have been separated. That is, obtaining WiFi information does not require obtaining positioning permission. Could you please adapt this permission feature of Android 13? In order to reduce power consumption. I use the WIFI SSID range trigger extensively in my macros, it works great, and since I live in a neighborhood I have a lot of SSIDs to use as reference locations, I use it as another kind of geofence, which is really great!
I will look into this in the future, not for this beta I'm afraid.
 

MacroDroidDev

Administrator
Staff member
I've just posted a new beta update. It offers some other JavaScript 'engine' options which are really just wrappers around webview / existing platform functionalty. They are mainly provided because the JetPack library is known not to work on all devices.

I am going to be away for most of next week, so I will continue stabilizing this beta when I am back.
 

sampleuserhere

Active member
The new options has unexpected behaviour v5.38.3 in MIUI13.

  1. QuickJS, MD crashes with fatal error.
  2. JSEvaluator, always returns undefined.

This is the log message for #1.
Code:
FATAL EXCEPTION: main
Process: com.arlosoft.macrodroid, PID: 16529
java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/~~-cTy7UTLDOGjq0caIZq5tQ==/com.arlosoft.macrodroid-E1GrRVK5ZWDNOXuHLwcivg==/lib/arm64/libquickjs-android.so"
    at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
    at java.lang.Runtime.loadLibrary0(Runtime.java:998)
    at java.lang.System.loadLibrary(System.java:1656)
    at com.hippo.quickjs.android.QuickJS.<clinit>(QuickJS.java:31)
    at com.hippo.quickjs.android.QuickJS$Builder.build(QuickJS.java:1)
    at com.arlosoft.macrodroid.javascript.JavaScriptExecutorQuickJs.executeJavaScript(JavaScriptExecutorQuickJs.kt:26)
    at com.arlosoft.macrodroid.javascript.JavaScriptExecutor.executeJavaScript(JavaScriptExecutor.kt:149)
    at com.arlosoft.macrodroid.action.activities.JavaScriptEditActivity.F(JavaScriptEditActivity.kt:72)
    at com.arlosoft.macrodroid.action.activities.JavaScriptEditActivity.onOptionsItemSelected(JavaScriptEditActivity.kt:105)
    at android.app.Activity.onMenuItemSelected(Unknown Source:66)
    at androidx.activity.ComponentActivity.onMenuItemSelected(ComponentActivity.java:1)
    at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:1)
    at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:1)
    at androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:3)
    at androidx.appcompat.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:6)
    at androidx.appcompat.widget.Toolbar$1.onMenuItemClick(Toolbar.java:19)
    at androidx.appcompat.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:7)
    at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:5)
    at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:15)
    at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:4)
    at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:1)
    at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:4)
    at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:7)
    at android.view.View.performClick(Unknown Source:17)
    at android.view.View.performClickInternal(Unknown Source:3)
    at android.view.View.access$3700(Unknown Source:0)
    at android.view.View$PerformClick.run(Unknown Source:8)
    at android.os.Handler.handleCallback(Unknown Source:2)
    at android.os.Handler.dispatchMessage(Unknown Source:4)
    at android.os.Looper.loopOnce(Unknown Source:176)
    at android.os.Looper.loop(Unknown Source:77)
    at android.app.ActivityThread.main(Unknown Source:138)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
    at com.android.internal.os.ZygoteInit.main(Unknown Source:306)
 

MacroDroidDev

Administrator
Staff member
@sampleuserhere Thanks for trying them out. The 'undefined' behavior may just be a limitation of JSEvaluator (It seemed to work for some scripts but maybe is much more limited). I guess QuickJS is relying on something not present on the device, but it should not crash in any case so I will investigate this when I can.
 

MacroDroidDev

Administrator
Staff member
@sampleuserhere Can you please submit a bug report that causes these issues. I've done very basic testing on a Xiaomi device and I don't see the crash, so perhaps its related to your script.
 

sampleuserhere

Active member
@sampleuserhere Thanks for trying them out. The 'undefined' behavior may just be a limitation of JSEvaluator (It seemed to work for some scripts but maybe is much more limited). I guess QuickJS is relying on something not present on the device, but it should not crash in any case so I will investigate this when I can.

I've just noticed that there isn't any console output for the new options. If I were to have a misspelled syntax then I could see the output.

I wonder how am I supposed to output certain data and pass them to Macrodroid with the new option?


@sampleuserhere Can you please submit a bug report that causes these issues. I've done very basic testing on a Xiaomi device and I don't see the crash, so perhaps its related to your script.

Done.
 
Top