evgenyneu / js-evaluator-for-android

A library for running JavaScript in Android apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsevaluator seems not to run if script is over a certain size

reality opened this issue · comments

commented

Thanks for the cool library - I have been using it to utitlise cryptojs to encrypt images, but it seems the jsevaluator doesn't initialise properly if the file is large enough (though it is hard to tell exactly what the issue is).

Here is how I'm using it: https://github.com/reality/alsuti/blob/master/android/app/src/main/java/rehab/reality/alsuti/Encrypter.java - First it grabs the base64 of an image, and builds a JS script with this, cryptojs and a short encryption function.

It works fine if the image is small, but if it's large (I've been testing with 0.9MB), it just doesn't return, and there are no errors. I have tried passing the data to the script in a few ways - currently it builds a 'plain' variable with the base64, but I have also tried passing the base64 directly to the encrypt function as a parameter, which causes the same behaviour.

I do not think it is a fault of the script itself, since if I replace the encrypt function with 'return "apples";' the behaviour is the same, which indicates that the function is not actually being called. Please let me know if I can provide more information!

Hi @reality, I think your code is correct. As you suspected, the problem is probably the size of the JavaScript text you are evaluating. I had one person reporting similar issue before when he could not evaluate very long strings but was able to evaluate shorter ones. As you probably know, this library uses the web view to evaluate the JavaScript. I suspect that web view is choking on the large data (sorry for the horror analogy).

It looks like this library is not suitable for evaluating big things. I am putting a message on the readme about that.

commented

Thank you! You may want to note that this library seems to work for more intensive applications: https://github.com/ericwlange/AndroidJSCore

Thanks for the reference, added it to the readme as well.