Complex Data Field flashing for a fraction of a second only

I'm developing my first Complex Data Field and I can't get the view to display; it flashes for a fraction of a second when switching pages only - on the watch - then shows the IQ launch icon. On the simulator it works just fine.

I've successfully developed a few Simple Data Fields and sideloaded those to the watch.

I'm using the latest SDK on Mac and Visual Studio Code. I went through the "Build Complex Data Field" prompt so all files are generated with some dummy data in it.

I'm not using any Layout functionality as far as I can tell, just direct dc.write. I've cleaned up other .mc files with reference to Layout calls.

Visual Studio Code generated:

- <name>App.mc

- <name>View.mc

- <name>Background.mc

I allowed each initialize() call to do just that and kept the other functions empty.

View contains all my straightforward logic and drawing:

- initialize() is just initialize

- onLayout(dc) checks width and pretty much nothing else

- compute(info) gets some GPS measures

- onUpdate(dc) contains all of the logic and direct drawing. I'm calling a dc.clear() at the begining. No layout calls. This functions ends without any special calls to self or whatnot.

After a week of reading up and trying to clean up as much as I can, I can't figure out why it's flashing once like it does. Nor do I find relevant Complex Data Fields that do NOT use dc.drawText / dc.drawLine to display their output. Most seem to use a layout approach. Most older examples also have a lot less files and calls in there, making it hard to transfer into today's SDK, further confusing a newbie here.

It's a longshot, but does any of this rings a bell with anyone? Or could anyone share a simple "Complex" Data Field that I could test and sideload onto the watch?

Thank you for pointing me in the right direction...

  • Check the apps/logs/ciq_log files on your device as it sounds like you're having a crash

  • And... you're right, there is a crash log... if the line it points to is accurate, then it's likely a variable that's wrongly typecasted (doing some math with info.currentSpeed). Amazing how the simulator never threw an error or warning. I'm one step further... after days of reading up on the usual layout / clear / draw trap!

  • Typechecking is a compile time thing.  What you may want to do is check that currentSpeed isn't null.  Depending on the error you are seeing, you also may want to check for 0.

  • Thank you Jim, I've read so many posts of yours these last few days. I'm honored you're assisting here. I'm indeed testing for null or 0 now. Is there a directive I can use to make typechecking explicit or something? But at least I have something to go by now.
    Follow-up question, if I sideload my .prg, it turns from <name>.prg into a number. Can I assume it automatically reloads in the app as if it were a proper update? Or should I modify datafield first, uninstall sideloaded datafield, reinstall new one, etc?

  • To close the loop, there was indeed a crash due to loosely typed variables. Defining everything as explicit as possible and calculating their values and testing under compute fixed each issue. And to answer my own question; you can dump a new .prg over the old one without thinking twice, the device will update it instantly.