Clearing listboxes, very slow.

0 favourites
  • 6 posts
  • 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?

  • 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)

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.)

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)