I have a watch face that seems to work fine on a 64kb style devices however I have had some FR735XT/ Vivoactive HR users running latest firmware reporting problems with trying to save values to the objectstore.
If the following 3 lines of code are commented out the watchface seems to work fine.
var app = App.getApp(); app.setProperty("lastLat", lastLat); app.setProperty("lastLon", lastLon);
If these lines of code are executed then when I exit the application in the simulator after the onStop() function is called I get an error:
"Unable to serialize app data"
This error can also occur at random intervals if I am changing settings via the simulator running 2.3.x and VAHR.
If I run a FR935 with 2.3.x in the sim (or FR235 with 1.x) I cannot recreate the problem. My properties file is less than 1kb and the free memory available when I exit onUpdate is always around 4kb for VAHR and 37kb on a FR935.
Any ideas ? Is this a peak memory usage exceeding 58kb problem ? How do I confirm this and check what peak usage really is ? There used to be something show up on the status bar for the simulator but this is gone in the latest release ?
Without the property reference, what is your peak memory on the 735? (the 1.x devices have more memory, and devices like the f5/935 have MUCH more memory.).
On 2.3.1, in the sim, Use file>view memory, and what is in the top 4 lines? (the memory and object data) It sounds like you were a bit borderline on available memory before.
Thanks Jim. That is where the peak memory field has gone! Testing on FR735XT shows peak memory at 56.2kb yet I still get the "Unable to serialize app data" error. Does the sim need some extra memory to write out to the object store ? If I turn off that feature that saves lat/lon to support sunrise/ sunset calc I peak at 55.7kb and watch face seems to work in the sim.
Why Garmin limits 58 K on a watch face for watches with only 16 colors (735XT) (not 64K like CIQ1 watch ) whereas it is possible to go up to 122 k for an application. I think it's only a control in SDK not a technical constraint in the watch.
in devices.xml for 735XT the limits are in 2.3.1 <app id="watchface" memory_limit="65536" /> <app id="watch-app" memory_limit="131072" /> <app id="widget" memory_limit="65536" /> <app id="datafield" memory_limit="32768" />
and for Vivoactive HR <app id="watchface" memory_limit="65536" /> <app id="watch-app" memory_limit="131072" /> <app id="widget" memory_limit="65536" /> <app id="datafield" memory_limit="32768" />
It's a limit on the watch itself, and the SDK just enforces that limit. An interesting thing is that it's really 58k+6k (64k), but on 2.x devices, 6k is used by the VM. Same with 26K for data fields (26K+6k=32K), and the 122K for apps (122K+6k=128K).. Some 2.x watches (the f5 for example) allow 90K for a WF (again 90K+6K=96K)
So a watchface on a 735 you only have 58K for your app, but including the 6k for the vm, at most 64K. And when you use properties, that does take some of your apps memory.
The error you get is that there's an error when writing the properties to mass store, and you'll have to find a way to reduce the size of your app. That could be just some code cleanup, or you can look at things like build excludes to leave out parts in devices with only 58K max available
Just a thought on this. When you added lat/lon, are you writing that to the .set or the .str? If it's the .set, when a write occurs, all your settings are also written. If it's the .str, only the things you have in the .str are written. The .str is the actual object store (local storage for your app), and the .set, is used for settings (what the user can change with app settings). If you don't define the key as a property in the .xml, it will go in the .str. In the sim you can see what's in the .str from within the sim itself with File>Edit Object Store, while the .set, you change with the App Settings Editor in Eclipse.
In my own apps, it's quite rare that I write anything to the .set, but quite common that I read and write the .str.
The Object Store sample in the SDK started as just the .str file, but when app-settings was added in 1.2.x, a second screen was added for that. They both use the same property calls, but you can see the differences, where the 1st screen is the .str, and the second, the .set. If you're just wanting to save the lat/lon, I'd put it in the .str, so the amount that needs to be written is smaller. That alone amy fix your problem.
Thanks Jim, I use the .str file since there are only a few values I need to store and I wanted to keep them hidden from the user. I removed a couple of fonts and reduce peak memory to 55.6kb which makes the watch face far more stable. It still seems to crash at random times in the sim if I use the object store with the "unable to serialize data" message. In the sim this message usually appears when I am exiting the app rather than at the time of setting the values in the objectstore. Although on the devices themselves this seems to cause an error and the app crashes taking users back to the default Garmin watch face.
The Objects Store is only read when the app starts, and only written when the app exits in most cases, I beleive. I think it's a bit different if background processes are used, as the .set and .str is how info can be passed info into the background process.
That's why you only see the error when the app exits.
It's not super clear if there is a bug here or not. If you want to send your source in to [email][email protected][/email] we could take a look and see if it's on our side.
Thanks, -Coleman
P.S. Make sure to link to this forum post so we can keep track of it all.
OK Thanks! I have managed to get my hands on a VAHR so will do some testing on the device myself this weekend before I call in the special forces!
One quick question.... The VAHR supports SDK 2.3 but does it support partial updates ? The following line seems to always return false in the sim for VAHR with SDK 2.3
partialUpdatesAllowed = ( Toybox.WatchUi.WatchFace has :onPartialUpdate );