# Image Animation on a Timer. Timer sometimes gets slower

**URL:** <https://forum.inductiveautomation.com/t/image-animation-on-a-timer-timer-sometimes-gets-slower/68968>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 24, 2023, 2:28pm UTC](https://forum.inductiveautomation.com/t/image-animation-on-a-timer-timer-sometimes-gets-slower/68968 "2023-01-24T14:28:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Laplante](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@Emile\_Laplante](https://forum.inductiveautomation.com/u/Emile_Laplante)\
**Post date:** [January 24, 2023, 2:28pm UTC](https://forum.inductiveautomation.com/t/image-animation-on-a-timer-timer-sometimes-gets-slower/68968/1 "2023-01-24T14:28:25Z")

</div>

Hi,

I run an animation in vision by changing the position of an image with the function system.gui.transform() using the changed value of an object timer. It works great, but sometimes, the timer slows down. It seems to increment at half the speed (similar to this post : [Timer running slow](https://forum.inductiveautomation.com/t/timer-running-slow/6348)). What is the issue? Is it related to a perfromance issue? Is there a work around?

Thank you!

---

<div class="post-metadata">

**Author:** ![Emile\_Laplante](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@Emile\_Laplante](https://forum.inductiveautomation.com/u/Emile_Laplante)\
**Post date:** [January 24, 2023, 2:40pm UTC](https://forum.inductiveautomation.com/t/image-animation-on-a-timer-timer-sometimes-gets-slower/68968/2 "2023-01-24T14:40:27Z")

</div>

I might have a clue,

The speed of the timer seems to be correlated with the gateway ping time. When I see the ping time getting slower, the timer runs slower:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2b5bc9047aaff2d168c55610f051bf480d9d358.png)

So, how can I get a timer that is not affected by the gateway ping time?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 24, 2023, 3:07pm UTC](https://forum.inductiveautomation.com/t/image-animation-on-a-timer-timer-sometimes-gets-slower/68968/3 "2023-01-24T15:07:13Z")

</div>

That usually means you are regularly calling out to the gateway on your foreground (user interface) thread. That should be avoided. The most common culprits are tag reads, alarm status calls, and database queries in event scripts. Including those called from runScript(). Wherever possible use tag bindings, indirect tag bindings, and named query bindings to bring gateway information to the client. Those run in the background. Then the foreground scripts can access the values of **properties** , which do not require a call-out.

In a pinch, use `system.util.invokeAsynchronous()` to run something in the background. At the end of its function, use `system.util.invokeLater()` to deliver results to your UI. (Or write to client tags--that is safe in the background.)
