Experiencing very slow performance

I have a rather small object with up to 20 items:

SongPlatz object with 3 properties
Startnummer number
fields   object with 3 properties
             Interpret text
             Platztipp   number
             Song text
id text

I am ordering the Object using:

ORDER<item>(appVars.SongPlatz, item.fields.Platztipp, "asc")

Somehow the app is becoming very slow and even terminates after adding some 5 items to the object.

Any ideas how this could be improved?

Best regards and many thanks!

1 Like

I solved some of the performance problem by reorganising the data into a simple list and using the Sort function instead of ORDER. It still slows down noticeably after the 5th or 6th item.

The list gets initialized with 20 sets of values. (20 Songs)
I am then setting the Platztipp Property for each item.

After 16 times setting the Platztipp Property, the app abends and restarts with the initial screen.

Any ideas?

Crashing and the app restarting definitely does not sound normal. I’d double check the logic wherever you’re assigning your data to variables to make sure everything makes sense.

Current performance bottleneck is the time it takes to render all the components in the app. So if you repeat some container over a list of 20 items, and each of those containers contains 10 components, you’re rendering 200 items. If you add one item by reassign the variable with a new list of 21 items, it’ll do a full re-render that “costs” 210 items. So the time it takes to draw everything will slowly increase every time you re-assign the list with more items.

Where this becomes too slow will depend on your device and the specifics of the app you’re working on. Without a proper benchmark, I’d say you start really feeling the effects somewhere around 200-1000 total rendered components. This will be hugely improved in our next major runtime release with recyclable views and improved logic for re-rendering. But right now your best bet is to try and mitigate the issue by minimizing renders.

So make sure you only reassign the repeated variable when necessary. If you’re e.g. performing the sort and reassignment several times by accident, you’ll get the performance hit for every time it’s reassigned (sorting is cheap, rendering is costly).

You can also limit the amount of repeated items you’re showing at once (check out SLICE). Pagination and in-place searching are good patterns for that, though they’re certainly quite a bit more complex than just repeating the items.

1 Like

I would understand the explanation, but the whole thing is really small. I have a ten item list with two attributes. The list is preinitalized with 10x Song Name, 10x Performer Name, initially set to “no selectio made” and “please choose”.


When tapping a slot, the list with 20 Songs/Performers is shown and upon tapping the Song, the slot in my 10 item list is exchanged with the selected song:
grafik
So that the slot looks like this:
grafik

I do not see, where I would loose performance to a degree that the whole app terminates (e. g. on an iPhone 8 or a Samsung Galaxy S10). It becomes very slow on my Xiaomi Pocofone F1 with 8 GB RAM and Android 9 on an Snapdragon 845 but does not terminate.

I refactored everything into flat lists and avoided the sorts by introducing a second list with the different order - this helped and the application is now behaving reasonably well.

Glad to hear you got the app working!

That’s definitely nowhere near the amount of items that would cause any of the issues I had in mind. Maybe there was an assignment loop somewhere? In any case, great news that refactoring resolved it.