I find that there is a problem upon loading largish JSON resources over time in a widget causing the watch to reboot and the simulator to exit. This is easily reproducible on both the watch and the simulator (in the case of the simulator the simulator just hangs and crashes). In the simulator or the actual watch (fenix 7 sapphire solar) no debug messages are produced. On the watch the error log is provided at the end.
Investigation is pointing towards some garbage collector/caching/overflow issue on the VM. The widget that reproduces this issue nominally uses json resources and loads and unloads them as the user conducts searches as the total data to search in json is too large to be loaded once (so the json data is split in about 200 json resources to stay below the 255 maximum json ids). The json resource data is a simple dictionary with strings and arrays but of largish size. The watch memory monitor on the simulator shows that the Application.loadResource and then setting the variable holding the loaded dictionary to null works as expected (meaning the memory increases after the load and then decreases upon setting to null) and there does not seem to be memory leaks (the memory after release goes back in the simulator to the same value). However, after loading and unloading multiple times the watch crashes on the call to Application.loadResource even though the memory and peak memory reported is well below the maximum (peak memory is 562kByte for the worst load on fenix 7). It seems that the crash is linked to the amount of data being loaded over time regardless of the holding variable being set to null or which set of json resource have been loaded and unloaded. The number of loads before crashing varies depending on the total number of bytes loaded which seems to be around 640kbytes on fenix 7. This means for example that loading and unloading 10 time a JSON resource of 64kBytes will crash on the 10th time and loading/unloading 60 times a 12kBytes will crash on the 60th time.
This limits how long a user can interact with the widget, not factoring the inconvenience of having the watch reboot if they interact too many times.
If the json resource remains small (below kByte) there does not seem to be a limit.
The code stub for the function that does the load/unload is as follows:
typedef JsonResourceType as Numeric or String or Array<JsonResourceType> or Dictionary<String, JsonResourceType>;
//select json resource symbol to load upon user entry
DictionarySymbol = null;
if (UserEntry == 0) {
DictionarySymbol = :MyJsonResource_0;
}
else if (UserEntry == 1) {
DictionarySymbol = :MyJsonResource_1;
}
else if (UserEntry == 2) {
DictionarySymbol = :MyJsonResource_2;
}
...
//free memory from prior loaded data
Dictionary = null;
if (DictionarySymbol != null) {
//Load new data
Dictionary = Application.loadResource($.Rez.JsonData[(DictionarySymbol]) as Dictionary<String, JsonResourceType>;
}
error load on a physical device
3906 (fenix 7) SW ver: 1128 Build Type: RELEASE Commit:27860a2152c7c765e210851d41cdcfa20dccd54b ESN: 3435646052 04/14/23 12:42:50 RTL errnum: 0x034 r0: 0x303cc7bb r1: 0x00000000 r2: 0x00000054 r3: 0x303cc7bb r4: 0x00000005 r5: 0x00000000 r6: 0x3819aaa8 r7: 0x00000000 r8: 0x303cc840 r9: 0x00000007 r10: 0x0000000b r11: 0x00000074 r12: 0x00000004 r13: 0x303cc790 r14: 0x18b04fe5 r15: 0x18b05006 r16: 0x61100000 r17: 0x40000000 r18: 0x01000000 r19: 0xe000ed38 r20: 0xe000ed34 r21: 0x00000000 r22: 0x303cc728 Stack frame PC, SP: 0x100015f1, 0x3043b570 Call Stack - SP at 0x3043b570: 0x10000805 0x10000593 0x18b04fe5 0x100252a1 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x1000000f 0x10000007 0x1000000f 0x1000000f Uptime: 12412798