简体   繁体   中英

Why is Android JSInterface so slow?

I have a javascript calling a javascript interface many times (around 500 times sometimes), updating the page's UI from it. It sends a couple strings, and casts String result to string: ""+window.INTERFACENAME.function(...) .

Without calling the function, it takes 43ms, but takes 6 or 7 seconds with the JSInterface call. Why is the JSInterface so slow?

My solution was to implement the same function in Javascript as the Java code. Messy, but it's much faster than calling Java. I suppose if it were required to make many calls to Java, it would be better to make one call with a list of inputs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM