Android Question Uploading data to server causes app to hang

dieterp

Active Member
Licensed User
Longtime User
I have a cricket scoring app developed in B4A and B4i that is used extensively in South Africa as well other countries worldwide. One of the biggest features of the app is that it has a live-scoring option, whereby the app updates a MySQL DB on our server which in turns supplies match info to a website for the community to follow. You can score offline, and then at any point you can enable live scoring which will upload the latest scores in the game every 20 seconds.

One of the biggest issues I'm having though is that sometimes when live-scoring is enabled, the app will hang and then close the app. This has been happening for many years now, and everything points to the mobile connection of the device dropping for some reason which causes issues with the data upload. Often to resolve the issue, we tell the scorers to turn off mobile data on the device and use a WiFi hot-spot from another device, which generally does the trick. Some other things to note are:

1) There are no Do Events in the app so that's not the issue
2) We've broken the uploading of data into small chunks of data, and the app will wait for a success message from the previous upload before it attempts to upload the next batch
3) It's completely erratic. A user can score an entire game (7.5 hours of scoring) one weekend without any issue, then the following week the same user with the same device, using the same version of the app could encounter the issues mentioned above

What can I do to try ensure that if it is the mobile network that drops that causes the issue, that the app won't hang and close on the user? Or are we effectively at the mercy of the internet connection in these scenarios?
 

MarkusR

Well-Known Member
Licensed User
Longtime User
u need to locate the sub where your app crash.
use try catch.
log Application_Error
test your app by yourself in debug mode and trigger score upload by timer or something until it fails.
log as much as you can to see the app sequence.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
We do use Try Catch in the subs to catch errors, but I'm not sure that would be highlighting the issue as whatever it is that causes the app to crash, it's tying up the Android OS for 5 seconds which is where Android automatically closes the app, so we wouldn't even get to the point where errors would be caught.

We do also ask the users to restart their devices when they start having issues with live scoring, which also sorts the issue out more often than not. Not sure if that sheds any more light on the situation?
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
if you wrote a log you will now what happens last.
if your app is in playstore, did you look in the dev console for crash issue?
maybe post the code for uploading your hi score.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
We use a web service api to connect to the remote database, so the app passes in JSON through an end point to the api which handles all the inserts/updates, and the api then returns a success message once that is completed. Once the app receives the success message it uploads the next chunk of data. Only once all the chunks of data have been uploaded does the timer start for the next 20 seconds to repeat the upload process
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
unprobable but
if you have a sub routine without wait for that take a long time (seconds) you can insert sleep(0) (similar doevents)
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
OK cool. Thanks for the suggestions everyone. I will try out some of the above recommendations and see if manages to resolve the issue
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…