WebKitโs internal timer management is a little peculiar in general and, in particular, in iOS. They are registered in NSDefaultRunLoopMode mode, therefore, for example, when scrolling in the user interface, Javascript events are not triggered, but they are also not aggregated, as with regular timers ( NSTimer ).
To answer your question when the application process is paused, the timers are also paused, so they will not start until the process is paused. As soon as the process resumes for some reason (the user opened the application, background extraction, etc.), the Timers will resume their run and return to the relative point when the last tick should have been.
So, if you set a timer for every 10 seconds and close the application with t + 1 second, then open it again at t + 35 seconds, the timer will light up after 5 seconds; you will not hear retroactive ticks t + 10, t + 20 and t + 30 seconds.
Note. This is a timing management based on UIWebView / WebKitLegacy / technology; I am not very good at how WKWebView / WebKit2 / handles them.
Leo natan
source share