Delay between end of onUpdate and other events

Since adding a second timer to my widget app, I’ve noticed an issue in the simulator: after each call to onUpdate in my view, there’s a 2-3 second delay before any other queued events (timers, user input, web responses) are processed.

If I disable (comment out) either of the two main timers, the delay disappears.

To investigate further, I added a third timer inside onUpdate that triggers a one-time callback after 50ms. This third timer doesn’t appear to contribute to the issue, the original delay still occurs only if both main timers are active.

public function onUpdate( dc as Dc ) as Void {
    EvccHelperBase.debug("WidgetSiteBase: onUpdate" );
    // Some drawing
    EvccHelperBase.debug( "WidgetSiteBase: onUpdate completed" );
    _updateCounter++;
    if( _updateCounter > 2 ) {
        var timer = new Toybox.Timer.Timer();
        timer.start( method( :testTimer ), 50, false );
    }
}
private var _updateCounter as Number = 0;
public function testTimer() as Void {
    EvccHelperBase.debug( "WidgetSiteBase: timer triggered" );
}

The test timer is used solely to ensure that a timer event is queued immediately after onUpdate completes. A counter is necessary because, during startup, I can only instantiate two timers -attempting to create a third results in an error. However, after the startup phase, I’m able to instantiate the third timer without any issues.

Here’s the log file that demonstrates the problem:

12.4.2025 17:21:42: TaskQueue: timer triggered
12.4.2025 17:21:42: TaskQueue: timer triggered
12.4.2025 17:21:42: WidgetSiteBase: onUpdate
12.4.2025 17:21:42: WidgetSiteBase: onUpdate completed
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:44: WidgetSiteBase: timer triggered
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:44: TaskQueue: timer triggered
12.4.2025 17:21:45: MultiStateRequestsTimer: timer triggered
12.4.2025 17:21:46: StateRequest: onReceive

You can see the gap between the end of onUpdate at 17:21:42 and the first timer event that follows at 17:21:44. Another timer appears to be slipping in between onUpdate and the test timer.

All my event handlers include debug output, so I’m confident that none of my code is being executed during that two-second delay.

The first of the two main timers is initialized as follows - it’s responsible for performing regular web requests:

public class EvccMultiStateRequestsHandler {
    private var _timer as Timer.Timer = new Timer.Timer();
    
    public function startRequestTimer() as Void {
        _timer.start( method( :makeRequest ), 5000, true );
    }

    public function makeRequest() as Void {
        //...
    }
}


The second timer handles a queue of tasks and is set up like this:
class EvccTaskQueue {
    private static var _instance as EvccTaskQueue?;
    public static function getInstance() as EvccTaskQueue {
        if( _instance == null ) { _instance = new EvccTaskQueue(); }
        return _instance as EvccTaskQueue;
    }

    private function initialize() {}

    private var _timer as Timer.Timer = new Timer.Timer();
    
    private function startTimer() as Void {
        _timer.start( method( :executeTask ), 50, false );
    }

    public function executeTask() as Void {
            // ...
            startTimer();
    }
}

Both code snippets are simplified, but they should capture the essence of what’s going on.

Does anyone have an idea what in my code might be causing the delay after onUpdate, and how it could be related to the two timers?

  • I think switchToView draws the new view to a buffered bitmap that is than used to animate the slide (according to what you request in the last param) and then onUpdate is called another time to update the view.

  • I did some more testing today, and it looks like the issue is specific to SDK 8.1.0 and 8.1.1. When I downgrade to SDK 7.1.1, the same configuration runs smoothly - no onUpdate delays at all.

    Unfortunately, I’m unable to test with newer 7.x versions because they no longer support my device (epix2pro47mm). Attempting to compile gives the following error: Device 'epix2pro47mm' requires API Level '5.1.0'. The current SDK supports up to API Level '5.0.1'. Try updating your SDK using the Connect IQ SDK Manager.

    I've now raised a bug report for the onUpdate delay here:

    https://forums.garmin.com/developer/connect-iq/i/bug-reports/simulator-onupdate-delay-issue-with-sdk-8-1-0-and-8-1-1

    It’s still unclear what exactly in my code triggers the delay, but it seems to get worse the more sites and views I include - likely due to increased memory usage, additional timers, and processing overhead. That might also explain why it doesn’t happen in small, simplified test apps.

    Since the issue does not occur with older SDK versions, and also does not occur on a real device even with SDK 8.1.x, I’m now a bit more confident that my architecture and code are sound - and that this is likely a simulator-specific problem introduced in SDK 8.1.x.

    For now, I’ll continue using SDK 7.1.1 for simulator testing, and I’ll test future 8.x versions to see if the issue is resolved.