[UWP] Xamarin.Forms.Device.StartTimer is inaccurate #1623
This obviously makes it unusable as a method for displaying smooth graphics, as in the suggested code here which requres updating once a frame.
I have not tested on other Xamarin.Forms platforms.
Steps to Reproduce
FSharp test code:
Wait for numbers to stabilize.
on a 59fps screen
on a 30fps screen
All timers are inaccurate, and the interval is always the minimal guaranteed interval. But I agree that in this case, it's off by a wide margin for precise high-frequency timing.
deprecating it, in favor of
The Xamarin Forms code looks OK:
There are apparently threading advantages of DispatcherTimer comapred to System.Threading.Timer. The problem may be that thread scheduling has a granularity of 50ms . This suggests that the slowness of the timer is a Windows issue affecting all Timers rather than a Xamarin.Forms bug.
However, given that this slowness exists, Xamarin.Forms code which uses timers to get smooth animation should be changed.
A search of DispatcherTimer in this repo returns several examples with
A workaround appears to be to use
Would the best solution, to allow Xamarin.Forms users to do something once a frame, be to create a Xamarin.Forms Rendering event, assuming this does not already exist?
I hope this comment is helpful even though I have limited understanding of the underlying issues.
@mattleibow do you have an opinion about how to achieve smooth rendering on Windows? This affects SkiaSharp uses, including your answer in the link in the OP.
I propose splitting this into two issues: