Clearing listboxes, very slow.

Discussion and feedback on Construct 2

Post » Thu Apr 23, 2015 9:02 pm

I've been using a few listboxes on my new project and was struggling with performance. At first I thought the problem was either filling the listbox with too many items, or the way I was filling them (from objects). For example, if I had 1000 objects and tried to put an attribute from each object into several listboxes, it seemed to take several seconds to fill.

However, I tried a new, very simple project and I noticed that the performance is actually very good except when clearing the listbox. If I clear 10 listboxes (with 100 items), it takes about 2.5 seconds to complete (the more items to clear, the slower it gets, it's not noticeable with the 3 initial items). Filling the listboxes with 100 items only takes about 0.025 seconds. Even doing a fairly complex fill is very fast, it's just clearing the boxes which is so slow.

Is this to be expected and is there anything that I can do to speed things up a bit?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Thu Apr 23, 2015 10:59 pm

I tried it out - it's way slower in Chrome then Firefox. Looking at the code it removes each element one at a time so it's not surprising. Clearing the lists in one go with JavaScript is faster. It's instant in Chrome with 10 lists of 1000 items each. Still a bit slow in Firefox but faster than the clear action.

clearLists.capx (r200)
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Fri Apr 24, 2015 12:27 am

Wow, thanks dude. I was thinking I might have to abandon the listboxes and use something else but perhaps this is doable after all :)

Perhaps something for Ashley and co to look at? I know listboxes aren't crucial to most games but it shouldn't be a huge job. Or does the browser do all the work, so it's not a C2 issue?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Fri Apr 24, 2015 2:45 pm

One thing I've noticed on my mobile is that when I select an item in a listbox, and then select another listbox, both boxes remain highlighted with a blue background. In fact, if I select an item in all 10 boxes, they all remain highlighted. I don't know how to turn this highlighting off. Unfocusing the box doesn't work, nor setting the selected item to an odd number (e.g -1). I thought it might be just on IE since my mobile uses IE but it doesn't do that in IE on my PC. Any ideas how to unhighlight the listbox text?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Fri Apr 24, 2015 3:00 pm

You're right, it is slow. I've fixed it to use the faster workaround for the next beta. (I was going by @ramones's .capx, it is always a good idea to provide your own .capx if you think something is slow to prove your point.)
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Fri Apr 24, 2015 4:25 pm

Thanks Ashley. I did have my own capx to demonstrate it, but Ramones beat me to it while I was trying to work out how to upload it - besides, his is better :)
B
25
S
5
G
3
Posts: 446
Reputation: 5,633


Return to Construct 2 General

Who is online

Users browsing this forum: blackhornet and 5 guests