04-18-2010 11:46 PM
Hi,
I have a simple query that shows 20-30 rows of results but when its executed, it seems to take alot longer than I would expect - it takes 5 - 7 seconds some times. Does anybody know if this is a limitation with google gears and/or the blackberries? I have been testing this on both the blackberry 8900 and 9000 physical devices.
FYI - I am closing each 'execute' statement so no memory leaks are occuring. The table it is calling from has a total of 200 items and I have indexed it as well. I am also using explicit transactions when executing and retrieving my result sets (ie. 'Begin' and 'Commit')
Thanks ahead of time for the help.
-Dg
04-19-2010 07:41 AM
Hi Dg,
Have you put in some JavaScript Timers to see if it is the SQLite queries or the time it is taking to render the DOM change? From my experience the time it takes to execute the SQLite queries is quite fast, but DOM manipulation can be a bit slower to render especially if there are lots of changes in the DOM.
04-19-2010 10:13 AM
Hi Tim,
You're right. I put in some timers and the SQL query does run faster - the manipulation of the DOM is what's slowing the app down. I know this is a seperate topic from what I have started, do you know any ways of making the DOM work faster?
Thanks,
Dg
04-19-2010 01:10 PM
One thing you can try is to incrementally update the DOM.. For example, you can create a loop that when you are done processing the first X number of rows you exit the function by using a setTimeout() to then call a function to show the remaining rows. Kind of like a recursive function that exits calls itself by using setTimeout() to ensure the current thread is exited.
Does that make sense?
Essentially the goal is to make smaller incremental DOM updates and then use setTimeout() to exit the current JavaScript thread so that those DOM updates are displayed.
04-20-2010 12:06 AM
Not really. Would you be able to provide me with a small code example so I can better understand?
Thank you
04-21-2010 06:01 AM - edited 04-21-2010 06:02 AM
It would look something like:
var _myArray;
var _index;
function displayDetails() {
for (var i = _index; i < _index + 10; i++) {
if (i == _myArray.length - 1) return;
// .... Perform DOM manipulation
}
_index = _index + 10;
setTimeout("displayDetails()", 300);
}
Also check the speed class rating for your SD Card. It will have a direct impact on SQLite read/write speeds.
http://en.wikipedia.org/wiki/Secure_Digital#Speed_
04-23-2010 09:49 AM
That seems to have improved the performance! I'm going to continue testing to ensure that this method is a viable solution. Thank you!
04-23-2010 10:10 AM
Check out the following post where there's a valuable tip on how to increase write speed to the SQLite DB as well
05-05-2010 11:36 PM
Hi Tim,
I seem to have discovered a problem. While adding the code setTimeout(doSomething(),10), it seems that if any action (ie. click on a button) is done while this thread is running in the background will cause the app AND blackberry to crash. I am unable to do anything at this point and the battery needs to be pulled to bring it back.
Do you know if there is a way to prevent this from happening?
Thanks
05-06-2010 07:44 AM
Hi drjg22,
We have uncovered a thread deadlock issue when using the focus based navigation mode and having the DOM update in a different thread.
We are very close to a solution. I would suggest subscribing to the following thread to keep up to date with the latest news on this topic.