Skip to content

Worker Asynchronous Computation ​

1. Overview ​

In each frame of a minigame, the JS main thread mainly does two things: computation and rendering. Correspondingly, each frame's Frame Time = computation time + rendering time. According to RAIL, the user-perceived performance model proposed by the Chrome team, JS execution time (i.e. computation time) during animation should be less than 16ms, and ideally below 10ms, leaving an additional 6ms for rendering. Therefore, the 16ms of each frame is extremely important for a minigame.

However, in a minigame, some complex computations (such as physics engine simulation) can hardly be guaranteed to take less than 10ms, which often causes the game frame rate to drop and stuttering to occur. In particular, iOS's JavaScriptCore cannot enable JIT, which may cause very poor minigame performance on iOS.

For this reason, Runtime provides a Worker asynchronous computation capability, offloading complex computations to a Worker, which can improve runtime efficiency more than tenfold.

Using Worker asynchronous computation in Runtime requires no additional integration work.

2. Effects ​

  • Main thread computation time is greatly reduced

  • The main thread has ample time for rendering

  • Stable frame rate

  • Complex physics scenes no longer stutter