passing a 200 kb array in a cordova plugin is slow

37 views
Skip to first unread message

Mika S

unread,
Oct 5, 2016, 10:05:25 PM10/5/16
to phonegap
I have written a cordova plugin for ios that passes a 200 kb array from javascript to ios side. Since i was measuring performance, I do not do anything but just return a constant string. To my surprise, it takes 8 seconds in javascript from the time the plugin is called to the callback being executed.


Does anybody have experience passing arrays of similar size to native code. Surely 200kb is not a big size in todays day and age

Rob Willett

unread,
Oct 6, 2016, 2:32:58 AM10/6/16
to phonegap
We used to pass 500KB json structures round with negligible performance impact. We don't any more for other reasons.

Have you timed simply passing it around in javascript?

You don't say how you created the json. Is that the delay? Is it coming from a network connection or server? What environment are you using?

You need to.provide a lot more information if you want help. My immediate thought is your plugin is coded incorrectly or you are timing the wrong thing.

At the end of the day, javascript is pretty fast. it shouldn't break a sweat with 500KB.

Rob
On Thu, 6 Oct 2016 at 03:04, Mika S <siddh...@gmail.com> wrote:
I have written a cordova plugin for ios that passes a 200 kb array from javascript to ios side. Since i was measuring performance, I do not do anything but just return a constant string. To my surprise, it takes 8 seconds in javascript from the time the plugin is called to the callback being executed.


Does anybody have experience passing arrays of similar size to native code. Surely 200kb is not a big size in todays day and age

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mika S

unread,
Oct 6, 2016, 3:35:27 AM10/6/16
to phonegap
I am measuring time by measuring timestamp just before the call (at this point the 200kb array exists in the memory) and then measuring timestamp at the callback. The time spent is the difference in time taken. I have tried passing a small string instead of the big array and the time taken is merely 300 milliseconds.

I have worked on higher sized arrays with javascript too with no such big dips in performance. It is the plugin interface that is behaving terribly slow for me.

Rob Willett

unread,
Oct 6, 2016, 4:45:14 PM10/6/16
to phon...@googlegroups.com
I have no knowledge of plugin development. However there are thousands of plugins that use the interface. If the performance was that bad I'd expect people to be screaming from the rooftops. 

You need to speak to the plugin interface people, they may read this list but I suspect you have done something wrong. Without any code its impossible to guess. 

Rob


For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+unsubscribe@googlegroups.com.

Simon MacDonald

unread,
Oct 6, 2016, 5:23:12 PM10/6/16
to phonegap
Publish the code you have that can reproduce the issue and people will
be able to help.
Simon Mac Donald
http://simonmacdonald.com

Mika S

unread,
Oct 6, 2016, 6:06:57 PM10/6/16
to phonegap
So from my experiements, here is what I found out. If I pass the array as a json string acorss the boundary - it is very fast.

Passing it as a big array is what makes it slow. So I am going to stick with passing it as a stirng.

Simon MacDonald

unread,
Oct 7, 2016, 12:23:43 PM10/7/16
to phonegap
Please publish you test case.
Simon Mac Donald
http://simonmacdonald.com


Reply all
Reply to author
Forward
0 new messages