App freezing after POST call fails

Hello everyone,

I'm having a bunch of problems with my App. Its purpose is to take a photo from the back camera every time a timer goes off and upload it on Google Drive
Here it is the workflow:

  • reads a CSV file from a Google Drive folder which has some configuration infos, like timer duration, resolution, ecc. All the configurations are applied with a procedure.
  • The timer starts. When it finishes, a photo is taken, and it's supposed to be uploaded in a folder on Google Drive via Google Apps Script.
  • Every 15 minutes, it reads the configuration file again and updates a Google Sheets file that is useful to me to check the course of the App.

The second step contains the problem: I check the connection before start uploading the photo, but if the connection drops during the upload itself, the app freezes for some seconds and then crashes. I've tried to open another app, leaving it in the background for some tests, and it crashes too.

These are my main blocks:
Camera setup and CSV reading (WEB1)

Photo taking and uploading:

Google Sheets writing (WEB3/Clock 2 set to 15 minutes, timer always fires ON) variables and other components

These are some logs that I extracted with ADB Logcat:
logs.txt (743.3 KB)

Apparently the phone automatically decides to turn off the app after the failed call. I tried the app on another phone, and it behave in the same way. It's a problem, because it has to take photo in an enviroment with poor connection, and sometimes it goes off. This has to work fore some days.

Other informations that can be useful. I'm working on a Samsung Galaxy A50 with Android 11. The other phone is a Xiaomi Redmi Note 12C with the same OS.

If other informations are required, I'll stay online.
Thanks in advance for the help.

How did you set the timer interval for Clock1?
How large are the taken photos? It might help to reduce their size and/or quality...

Taifun

In the third image there is the function "setTimerTo", that sets the timer for Clock1. The value is defined in the file CSV. The setTimerTo() call is in the first image in Web1.gotText

The size of the images is around 5 MB. Reducing its size would just reduce the probability that the problem appears, since the upload would be faster. But it would not solve the problem itself

The quality should be the best, because these images are meant to be processed to extract some datas on plants

If you have an unreliable connection, then all you can do is to check the connection before sending. If the upload fails due to a connection drop out, then you should store the image on the device and try again later. If this failed upload is causing a crash, you will need to capture the point at which the connection fails.

I agree with Taifun, resize your images!

OK, i'll resize my images.

What do you mean by this? Capture as record with a screenrecorder, or capture the error in my app in some way?

Capture that the connection has failed/dropped out.

How can I capture a connection failure before the failure makes my app crash?

There are several extensions available that test your network connection. You could run a timer on one of these when you commence the upload.

How can I abort the POST call after the connection error has been revealed?
I'm also having trouble to figure out how can I reveal the error before the crash happens, since the check and the upload should be running in the same time

It is a problem if I ask for a block example of this solution?

You may be able to get it with the Screen1.ErrorOccurred event?

Are you using a data or wifi network connection ?

I tried to use the Screen1.ErrorOccurred event, but even with that the app behaved in the same way.

I'm doing the tests with a Wi-Fi network, but the actual scenario will use data connection

Testing this here is difficult, it means a long enough upload to give time to turn off wifi and data on the device to see what happens before the upload finishes!

I tried some tests eliminating the connection check before the start of the upload, and turning off wifi after the CSV file was read, but before the photo is taken.

I mean, nothing changes in the behaviour of the app if the connection turns off before the start of the upload or during it. The system closes the app in the moment it detects the error of no connection

How does your Screen.ErrorOccurred event look like? You should catch error 1103 there

So you are taking a photo each 15 minutes?

Taifun

10-15 15:57:03.665 25747 25747 E Form    : Form Screen1 ErrorOccurred, errorNumber = 1103, componentType = Web, functionName = PostText, messages = Unable to complete the given request with the text "filename=img_2023/10/15_15:57:02.jpg&mimetype=data:image/jpeg&folderid=1SdMLhHCswBDbI0g-QcK-XaJnm-Lhh16p&data=%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%2F4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdC%0AIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAA%0AAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlk%0AZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAA%0AAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAA%0AAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%0AAAAAAAAAAAAAAAAAAAA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ZCwV4JQOSMYB0qAZfvYwAFED%0AEOctwQx0qqpnyZzASE4QD4oznJfb3yZY4iQHO8jHCob1FaeuYizvDWlkQnfouY8KcqsDPozCSM4h%0ApPqQYcsouyHM
10-15 15:57:03.682 25747 30256 I .ProvaTirocini: Background young concurrent copying GC freed 392(42KB) AllocSpace objects, 4(44MB) LOS objects, 5% free, 68MB/72MB, paused 14.675ms total 88.559ms

I'm sorry if that is not clear. Every 15 minutes the app reads a CSV file that contains the value in milliseconds of the timer for the photos.

Please provide a screenshot of that event

Ok... (trying to find out slowly, what interval exactly you are using...) so how many milliseconds is it?

Taifun

The interval is variable: I can edit the value in the CSV file so the next reading by the app will change the timer. Commonly I use an interval of 180000 ms (3 minutes), 3600000(1 hour) or 14400000 ms(4 hours). For testing I used an interval of 60000(1 minute) to speed up the process.

How do I post a screenshoot of the event? You want a screenshoot of the text file when i saved the log or a screen of the phone when the event happens?

I presume you get the same problem when downloading the updated csv file ?

To read the CSV file, i perform a GET call with the component Web1.
When i read the CSV file it behave like it should. It returns an error code and simply does not do anything, and the app keeps running like it should.

I just found it

Taifun