I have code that changes the color of an image when a touch screen on Windows 10 is touched. When the screen is touched I also have an external function that I call to toggle a GPIO pin on a board. My coworker ran some tests with an optical sensor to see the latency on the color changing. We always have 60+ fps. The code for the color change is before the code toggling the GPIO pin but the color change is actually occurring 100 ms after the GPIO pin is toggled(My coworker is using a program that shows him when the screen is touched, when the pin is toggled, and when the color change occurs). I tried calling Canvas.ForceUpdateAllCanvases and I also tried LayoutRebuilder.ForceRebuildLayoutImmediate but this did not affect the time taken for the actual color change to occur. Is there any way to reduce this latency? Am I doing something wrong somehow?

  • \$\begingroup\$ Waiting for VSync, a frame of swap chain latency, then the display latency of your screen could account for the bulk of this time. Have you tried using other observable outputs (like manipulating a non-UI object) to compare the latency and isolate whether it's specifically the GUI system adding latency, or another source common to the rest of your game's rendering pipeline? \$\endgroup\$ – DMGregory Aug 21 '19 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.