Workingn with web requests

Hi guys,

I am currently working on an Watch App that retrieves data from a webservice in json format. This works pretty fine, but I have questions/issues where I need some clarification:

HTTPS: the webservice I am using for development does not provide https. To make it work in the simulator I have to deactivate the option ""Use device HTTPS requirements". I am not really sure what that means. Does it mean that when pushing the app to a device it won't work until and unless a HTTPS service url is provided? What if I want to support also HTTP? Is there a setting on the device like in simulator to deactivate this limitation?

JSON: responses from my rest service are always providing data in JSON format. Sometimes, when I have a lot of objects to load, the simulator shows error code "-403", which means that something ran out of memory. The strange thing is that this does not happen always but only sometimes with the same request. The response at this time has a size of about 2,7 KB, which seems not much to me, so the question is why am I seeing this error? What is the particular limit of a JSON response that can be handled? Does this depend on the device memory or is there a general limit?

I am currently using a Fenix 5, here is a dump of the memory logger of the simulator:

memory before request: memory1.png
memory after request: memory2.png

Thanks for the help!

Bye

P.S. I have issues uploading images/attachments to the post. Is there anything I need to know? Tried to upload 2 png files and one zip as attachment. I get error "Invalid file" in all cases.

P.P.S I have uploaded the file here: https://www.file-upload.net/download-13049367/memory.zip.html
  • As far as HTTPS vs HTTP, see this blog post. You may want to check if the service you're using will add https, or look at doing a proxy that does.

    As far as memory, how much data are you getting back? If the data varies, and you're close, even the same request can have a different sized response, causing the error at times. It could be not the actual size of the response, but the amount of memory available to handle it. The response is being converted from Json data to a dictionary in the process.
  • Hi Jim,

    thanks for your answer!

    i do not really understand, why Garmin is making it that difficult to use also http. At least there should be a difference between local servers (in the same network) and remote ones. Because for local servers enforcing https makes no sense in my opinion. My app might work over the internet for some users but most of them will try to use it with a local service, where https will not be available, at least not with a valid certificate. This makes usage very difficult...

    about the memory consuption. As stated in my first post the size of the response is about 3 KB, which is not much. I totally understand why processing the data on the watch need additional memory, but as the memory screenshots show, I am far away from eating up all the memory that is available on a fenix 5. The response itself has always the same size, so it is very confusing for me.

    Bye
  • It's not Garmin with http. Send your thank you notes to Apple! :)
  • Apple added this limitation, yes, but Garmin Connect support 2 more operating systems. Why was it necessary to add it in all of them?
  • It's the phone, and not where you run the SDK. So without it, no iPhone. That's why the checkbox if for "Device HTTPS Requirements"
  • I completely understand that this is an issue with the phone, but Garmin Connect App could handle this based on the operating system it is running on. Means on iPhone only secure connection is allwoed (https) whereas on Android and Windows Phone also the "insecure" connection is possible. Drawback of this would be of course that different os behaves differently, but I think in such a case this is acceptable.

    By the way, I digged a little bit into the memory issue, and it is very interesting, because I have tried to make it reproducible, and it seems that when the app requests the data the third time, the memory issue is occurring. What I am doing is I load the data and push the view, then return back to the previous view and again load the data and push the view. The third time I am doing this the memory is not sufficient any more. Does that mean that I have a memory leak somewhere? Or is it correct that when I push a view and move back to the previous one a small part of the memory remains occupied?

    Thanks!

    Bye
  • Have you used the memory view in the sim to see what's going on memory and object wise as the different points? Peak usage could come into play here.
  • One more question:

    To reduce the memory load I will make more requests to the server to get only the necessary portion of data. As I do not have much experience with requests from Garmin watches, how long does it take for the request to return back to the watch when ignoring the server dependent parts (request duration to/from server and server load time)? Is this acceptable if a user navigates and gets the next results presented after those have been loaded from the server?

    Thanks!
  • Yes, I have checked the memory view. The peak memory was always about 85-90KB, which is much less then the available memory. So somehow the watch refuses to process requests even if memory is available.

    Bye
  • What happens on the actual watch?