Explain This... Weird

I don’t know if this works.... uploaded a brief video. I was going to test global and module based variable persistence when my Edge device goes to sleep and wakes back up. Then this happened!? What the heck. Now I wonder if a DF actually runs properly when you swipe to another screen. Ugh.

  • Looks like you're doing the increments in onUpdate()

    Try moving them to compute()  For one thing, onUpdate() doesn't run unless the screen is visible, and it looks from the video, is called a number of times when the DF first becomes visible.

  • Yep - good call. I do call my "build screen" function from onUpdate(). So I'll move my little test incrementor into compute() where it should have been. But still... when I swipe the screen to become visible, I get (now) that the counter isn't being incremented while it was off screen. But why would onUpdate() be run dozens of times when it when I restart an activity? That is still a mystery to me. I did just move the variables to compute, to increment, and it no longer displays that strange issue where it triggers dozens of times upon a restart.

  • It doesn't really surprise me that onUpdate() might be called multiple times when a DF is first displayed, but that's the reason that some things should be done in compute (which is called every second if the DF is visible or not) vs onUpdate() (which isn't called at all unless the DF is visible)