Open kaneelyster opened 4 years ago
Thanks for reporting. There was a pretty massive change between 5.0 and 5.1 under the covers, so I am not surprised there were some unintended artefacts. I am only surprised this hasn't been found before now. I will take a look.
I'm using LiquidCore Android 0.5.0 as a native JS engine. I load a JS file and then call into/from JS without issues.
The JS functions make use of callbacks
Which is handled Kotlin-side
When updating to 0.5.1 or later however, I get NPEs when a boolean result is getting converted back to a Java object right before the callback is triggered.
Specifically, in
JSFunction.functionCallback()
on the lineJSValue value = function(thiz,args,invokeObject);
.With these values:
In 0.5.0
value
gets calculated as null but in 0.5.1 a NPE is thrown insidefunction()
for the same input, seemingly due to the value ofargs[0]
which is aJSValue
with a boolean value, i.e.new JSValue(context, true)
. If I debug and changeargs[0]
tonew JSValue(context, "true")
then the callback triggers successfully with no NPE. Same result if I instead change the JS to return"true"
instead oftrue
. Other JS functions returning complex results in the same manner work without issue. On iOS with JavaScriptCore the exact same JS code runs without issue.The NPE stack trace:
My expectation is for callbacks returning boolean results to be handled the same as before and the same as complex objects. Or is there another explanation for why this stopped working?