Unable to serialize app data - Watch App

I recently started to get the following error in the Debug Console in Visual Studio Code, "Unable to serialize app data".

The error occurs when I run the simulator and then File->Edit Persistent Storage->Edit Application.Properties Data, to change the settings.

When the error occurs I am unable to change the watch settings, I have to delete the App, reset everything for the simulator and then everything is okay.

When I deploy the Watch App, my Garmin Epix Pro 2 and Venu watches seem to function okay and without error.

My concern is that this just started to happen and I cannot work out why, and may be symptomatic of an issue that may cause problems.

I'm using SDK 8.1.1, and between the time when the error didn't occur and started to occur I did not change the SDK.

Does anyone know what causes this, or has also experienced this issue?

  • EDIT: sorry, I see you're on Mac and not Windows :/. I edited my answer to add the path for Mac, although you obviously already have it.

    Where can I find the compiler.json fie?

    Short answer: 

    Windows:

    %APPDATA%\Garmin\ConnectIQ\devices\[device id]\compiler.json

    Mac:

    /Library/Application Support/Garmin/ConnectIQ/[device id]/compiler.json

    --

    Longer answer:

    You need to find the ConnectIQ folder on your PC. The folder structure under ConnectIQ looks like this:

    ...\ConnectIQ\
    |
    --- Sdks\
    |       |
    |       [sdk versions] (one folder for every SDK version, such as 8.1.1)
    |
    --- Devices\
            |
            [device configs] (one folder for every device config, such as epix2pro47mm) (each device config folder contains compiler.json, among other files)

    The easiest way to find the ConnectIQ folder (without memorization, making a note, or searching) is to open the samples folder for the current sdk:

    - In VS code, open command palette (CTRL-SHIFT-P)

    - Search for "Monkey C: Open Samples Folder"

    - This will open ConnectQ\Sdks\[current sdk]\samples\

    - Go up 3 folders so you're in ConnectIQ\

    Having said that, the ConnectIQ folder is at:

    Windows: %APPDATA%\Garmin\ConnectIQ

    Mac: /Library/Application Support/Garmin/ConnectIQ/

    You can also find the paths for windows, os x and linux here:

    https://developer.garmin.com/connect-iq/reference-guides/monkey-c-command-line-setup/

  • You can see in the simulator memory window

  • Okay that worked, the error has now gone, but I must admit I don't really understand why??  And also, won't this give me an unrealistic view of what will happen on an actual watch?  

    It is interesting now, it works how it use to, I don't get the error and also I don't need to reset the simulator.

    Below is what I changed, I added 9 to all of the below in the complier.json

    {
    "alphaBlendingSupport": true,
    "appTypes": [
    {
    "memoryLimit": 9524288,
    "type": "audioContentProvider"
    },
    {
    "memoryLimit": 965536,
    "type": "background"
    },
    {
    "memoryLimit": 9262144,
    "type": "datafield"
    },
    {
    "memoryLimit": 965536,
    "type": "glance"
    },
    {
    "memoryLimit": 9786432,
    "type": "watchApp"
    },
    {
    "memoryLimit": 9131072,
    "type": "watchFace"
    }

  • What you did will not change anything to fix running on the real device.  It just shows your problem is due to not having enough memory in your app for your settings,

  • . But strange thing is that you have only 123.8 memory in watch app.

    I think it's actually a watchface (clean analog premium), which explains the ~128KB memory limit.

  • What you did will not change anything to fix running on the real device.  It just shows your problem is due to not having enough memory in your app for your settings,

    ^ Seconded.

    And it should allow you to see how much memory you need to free up, by looking at the peak memory in the memory viewer.

    In other words, previously the app was crashing presumably because when you change settings, the app used more memory than the real 123.8 KB limit, but you had no way of knowing exactly how much memory it used.

    Now that you have artificially increased the memory limit in the simulator to ~9131072 bytes (~8917 KB) and the app continues to run when you change settings, you can look at the sim memory viewer to see the peak memory and figure out how much memory you need to save for the app to run properly on a real device (and in the simulator, with an unmodified device config).

    As an example, if the peak memory after changing settings is 143.8 KB, you need to free up at least 20 KB somehow (143.8 - 123.8 = 20). (Ofc it would be best to free up even more, so you have a bit of headroom.)

  • Recall, what you see in the json may be 128kb, but's what's available to the app is about 4kb less starting with CIQ 2.  That 4kb is used by the VM, so 123.8kb is right on the edge

  • Thank you, I think I covered that already

    when you change settings, the app used more memory than the real 123.8 KB limit,
    As an example, if the peak memory after changing settings is 143.8 KB, you need to free up at least 20 KB somehow (143.8 - 123.8 = 20). (Ofc it would be best to free up even more, so you have a bit of headroom.)
  • Run app and look into memory monitor in different moment (refresh memory status if not auto) and find the moment when memory peak extends 123,8kb. Probably it is before showing properties window or after pressing save properties - when application settings disappears or zeroes from memory. But the previous screenshot says you try to allocate over 50kb...

  • So, I started by looking at all my settings.xml, properties.xml, strings.xml and resources.xml, and changed all the Id's to short Id's using a python script.  This reduced the size of the files significantly, but had no impact on the memory utilisation or the error of "Unable to serialize app data".  For those who are interested here is the Python code that will change all the Id's and update your code as well.

    1drv.ms/.../EdH0dXU22FdEsC3V-WVU4gUB458pja2ah5G6eDL94oM0Tw