I’m using composer in an app and in one of the scenes I read a fairly long list of items (birds actually). Each line is made up from an image an some text. Looks like this:
I have a function called guiClearList() that removes all the GUI elements from the list and one called guiBuildList() that adds them. I use SQLite to read items into an array and what ends up in this array is dependent on how I read from the database (I can do some basic sorting and filtering).
Almost all these operations works quite fast. From the moment I have selected a sort method until the correct list of items is displayed, it takes about half a second.
Filtering also works fast enough. If I select to only show items containing “ibis” in the name, this shows up in a blink.
But the strangest thing is that when I reset the filter (that is: doing a new DB query without any filtering), the result list takes several seconds to show. And it’s not the query that takes time!
My scene:show code looks more or less like this:
function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then WaitIcon(true) guiClearList() guiBuildList() -- MARKER A elseif ( phase == "did" ) then -- MARKER b WaitIcon(false) end end
By adding log markers in the code I have found that the part that takes time is between the end of the “will” phase and the start of the “did” phase. The GUI elements are all in place when the waiting-for-nothing starts.
My questions are these:
1. What actually happens between marker A and B?
Since I have no control over what is happening between A & B I’ve been forced to add a wait icon so that the user can see that something is happening. I’ve tried to use a sprite animation, but it freezes during this time! It is as if the device is locked up completely!
2. What can make the device freeze so utterly so that a sprite animation stops?
3. And, of course, is there a way to get to the bottom of this?