Help ... data field crashing when jumping between watchface and activity

Former Member
Former Member
I'm wondering if someone can help me isolate a problem for my Snapshot data field (https://forums.garmin.com/showthread.php?353131-Data-field-Snapshot). The crash is very reproducible (on both the 235 and 735XT) but i can't seem to figure out why it's happening.

The crash occurs with the following steps:

  • start an activity and press through to the field itself (press start twice, doesn't matter if you have a GPS lock or not),
  • quickly go back to the watch face (press back twice),
  • straight away go back to the data field (pressing start twice).


The code can be found here: https://github.com/darrencroton/Snapshot.

It seems that because i'm defining a bunch of initial values in initialize() for the various settings and formatting, when moving quickly between field and watch face they get forgotten and not reloaded on the second return to the field. The rest of the code then doesn't know what to do with what i'm guessing are now nulls.

That's what i think at least. But i don't want to hardwire numbers that only need to be defined once into sections of the code that get processed every second.

Can anyone help? Many thanks in advance.
  • Former Member
    Former Member over 8 years ago
    Could i move this request back to the top and ask any CIQ coding gurus, if you have a spare 10 minutes, to have a quick look at my code and highlight anything that stands out?

    I'm at a bit of a loss as to why i'm getting this crash.

    Much appreciated in advance!
  • I never access github (and never will!) and not looked at your code, but my WAG (wild azz guess!) is that in complex data field, something between onLayout() and onUpdate() is odd... onLayout() is called at times you may not expect (like returning from the watchface) and it may be doing something with data that throws onUpdate() into a tizzie...

    Try using Sys.println() in your code (with a log-debug file) to catch whats happening on the watch, in onLayout(), onpdate() and compute(), for example...
  • Former Member
    Former Member over 8 years ago
    Thanks Jim.

    I know it's crashing because something isn't defined that normally is (that's the log error i get anyway, although it's pretty nondescript). Dumping some of the values at specific places will help; i'll have a look.

    Here's the code structure: basically everything that only needs to be defined once is in initialize(). onLayout(dc) is empty. onUpdate(dc) handles the layout and all the value updating on the screen (no calculations). compute(info) is where i calculate the stuff that's shown in onUpdate(dc).

    I use global variables to connect all the initialise() values and compute(info) values to onUpdate (i don't pass them as they're used in multiple places; easier just to make them global).

    I'm a C and Python programmer, not C++, is my OO skills are pretty poor. I've gone the more conventional route with the code logic. Perhaps this is the problem...