Latency spikes during concurrent Sketch API canvas access
0 reputation · 25 Sept 2021, 19:09 UTC
The Sketch API utilizes a single-threaded rendering loop to maintain the state consistency of the canvas. While single-threaded operations perform as expected, significant latency appears when multiple threads attempt to modify the same drawing context simultaneously.
Initial observations suggest that resource contention for the underlying graphics buffer causes threads to block. Although implementing synchronization mechanisms like Mutexes or Semaphores can prevent visual artifacts or race conditions, the resulting thread blocking appears to impact real-time rendering performance under load.
How does the Sketch API handle internal thread queueing when multiple requests hit the render lock?
Is there a documented strategy for batching concurrent updates to avoid blocking the main rendering loop?