application is not responding.Would you like to close it?

I am newbie and I am trying to download from a remote server a full database to my corona application. Database is in mysql and I have a php that wrap information using Json and them my app read information and put it in local database.

My application works just fine in simulator, it takes around 5 minutes to download and populate information. My webserver is the same machine that is running corona simulator. almost the full time used is insertind data in sqlite inside the application, php response is fast.

I am downloding 13 tables all in paralel and I am using timer.performwithdelay each 10 seconds to validate status of download and insert in database per table.

All testing went right in simulator but them when I deployed in my phone galaxy S2 the application shows all the time the message

“application is not responding.Would you like to close it?”

I have a progressBarWidget that show progress of inserts and each time that I run it the percentage when message appears change sometimes is in 30% others in 47% or 75%.

If I click in wait application never finish anyway.

any idea how handle this or get any error message that can help.

I am newbie and I am trying to download from a remote server a full database to my corona application. Database is in mysql and I have a php that wrap information using Json and them my app read information and put it in local database.

My application works just fine in simulator, it takes around 5 minutes to download and populate information. My webserver is the same machine that is running corona simulator. almost the full time used is insertind data in sqlite inside the application, php response is fast.

I am downloding 13 tables all in paralel and I am using timer.performwithdelay each 10 seconds to validate status of download and insert in database per table.

All testing went right in simulator but them when I deployed in my phone galaxy S2 the application shows all the time the message

“application is not responding.Would you like to close it?”

I have a progressBarWidget that show progress of inserts and each time that I run it the percentage when message appears change sometimes is in 30% others in 47% or 75%.

If I click in wait application never finish anyway.

any idea how handle this or get any error message that can help.

I have clicked the wait option when message appears like three times and application update finishes. I guess that android has a timeout when application remains running processes in background or something like that.

Is there a way to change that time or avoid that the message appears to user before 5 minutes?

The term for this dialog is “Application Not Responding” (ANR) dialog. There are ways to handle this is android SDK but appear that in corona is not possible.

I would suggest you find a way to make your downloads more serial.  We don’t have any controls that turn off that message, so its up to you to make sure your app is not running in a tight loop for an extended period of time. 

If most of your data is static, why not pre-populate JSON Files in your app and then instil them into the database on first run, then just do an update to fetch smaller amounts of data?

Thank you. I really appreciate your support.

I thought in doing parallel at beginning to get a faster update (thought I was smarter!), but now I will try to do it serial to check if I can avoid error message.

I thought also to download the entire database file as a file and avoid inserting records and it worked but only after hours of work because I had next issue:

I am using network.download to get the database file named <mydb> but only worked fine in simulator. I tried with file name <mydb.db> and also only worked in simulator but when I used <mydb.txt> it worked just fine either in simulator and in application.

is there a restriction or something related with extensions to download files using network.download?. As mentioned, I am using temporary for testing a my personal windows machine in windows 7 with apache, php and mysql installed.

As for the first problem, you have to keep in mind, bandwidth is like a water hose.  Only so much can flow through it at once.  When you queue up a bunch of requests, each one only gets a little bit of service and the CPU and memory is constantly having to try and service them.  Most web browsers only request a max of 4 files at a time.

As for the 2nd problem are you on Android or iOS?  You may have to set the right mime type header when you go to do download the file and it’s also possible that your web server is trying to gzip the file and Android isn’t willing to accept the gzipped files (where iOS seems to handle that more gracefully). This thread may be of use to you.

http://forums.coronalabs.com/topic/32967-networkrequest-failing-on-android-over-ssl/

I understand network bandwidth limitation and I am agree to download only a couple of files at a time.

But related with error message (application is not responding.Would you like to close it?), the main issue is that inserting a lot of information in sqlite is expensive in cpu, so, I decided to download the database as a file and then open it in application instead of perform inserts. also, for future updates I will only download new inserts if those are few.

For second problem:

I am using android and I am not setting any mime type header. Maybe is trying to zip files, but is estrange because other extensions as .png, .txt, .mp3, .mp4 can be downloaded without issue. I am gonna check your link suggestion. Thank you.

I am newbie and I am trying to download from a remote server a full database to my corona application. Database is in mysql and I have a php that wrap information using Json and them my app read information and put it in local database.

My application works just fine in simulator, it takes around 5 minutes to download and populate information. My webserver is the same machine that is running corona simulator. almost the full time used is insertind data in sqlite inside the application, php response is fast.

I am downloding 13 tables all in paralel and I am using timer.performwithdelay each 10 seconds to validate status of download and insert in database per table.

All testing went right in simulator but them when I deployed in my phone galaxy S2 the application shows all the time the message

“application is not responding.Would you like to close it?”

I have a progressBarWidget that show progress of inserts and each time that I run it the percentage when message appears change sometimes is in 30% others in 47% or 75%.

If I click in wait application never finish anyway.

any idea how handle this or get any error message that can help.

I have clicked the wait option when message appears like three times and application update finishes. I guess that android has a timeout when application remains running processes in background or something like that.

Is there a way to change that time or avoid that the message appears to user before 5 minutes?

The term for this dialog is “Application Not Responding” (ANR) dialog. There are ways to handle this is android SDK but appear that in corona is not possible.

I would suggest you find a way to make your downloads more serial.  We don’t have any controls that turn off that message, so its up to you to make sure your app is not running in a tight loop for an extended period of time. 

If most of your data is static, why not pre-populate JSON Files in your app and then instil them into the database on first run, then just do an update to fetch smaller amounts of data?

Thank you. I really appreciate your support.

I thought in doing parallel at beginning to get a faster update (thought I was smarter!), but now I will try to do it serial to check if I can avoid error message.

I thought also to download the entire database file as a file and avoid inserting records and it worked but only after hours of work because I had next issue:

I am using network.download to get the database file named <mydb> but only worked fine in simulator. I tried with file name <mydb.db> and also only worked in simulator but when I used <mydb.txt> it worked just fine either in simulator and in application.

is there a restriction or something related with extensions to download files using network.download?. As mentioned, I am using temporary for testing a my personal windows machine in windows 7 with apache, php and mysql installed.

As for the first problem, you have to keep in mind, bandwidth is like a water hose.  Only so much can flow through it at once.  When you queue up a bunch of requests, each one only gets a little bit of service and the CPU and memory is constantly having to try and service them.  Most web browsers only request a max of 4 files at a time.

As for the 2nd problem are you on Android or iOS?  You may have to set the right mime type header when you go to do download the file and it’s also possible that your web server is trying to gzip the file and Android isn’t willing to accept the gzipped files (where iOS seems to handle that more gracefully). This thread may be of use to you.

http://forums.coronalabs.com/topic/32967-networkrequest-failing-on-android-over-ssl/

I understand network bandwidth limitation and I am agree to download only a couple of files at a time.

But related with error message (application is not responding.Would you like to close it?), the main issue is that inserting a lot of information in sqlite is expensive in cpu, so, I decided to download the database as a file and then open it in application instead of perform inserts. also, for future updates I will only download new inserts if those are few.

For second problem:

I am using android and I am not setting any mime type header. Maybe is trying to zip files, but is estrange because other extensions as .png, .txt, .mp3, .mp4 can be downloaded without issue. I am gonna check your link suggestion. Thank you.