Closed kenzieschmoll closed 3 days ago
@chinmaygarde @liyuqian @Hixie
Good question. I think a clear definition would help us and our developers a lot.
My personal understanding is that "jank" is the opposite of "smooth". Latency is another issue. It's kind like when you buy a gaming monitor, you'll check 2 separate specs:
I think the separation of smoothness and latency also applies to Flutter. It's best to measure, track, and optimize them separately.
For the "jank" or smoothness specifically, it's just about how continuous your frames are. If you have two frames that differ from one another significantly in an unexpected way, users will detect such "jank" or non-smoothness.
In my experience, there are 2 ways to have such non-smoothness:
Now let's turn back to the latency. When there's a high latency, users may still see a very smooth animation, but they'll feel that the animation is lagged behind their input. Note that "an input event" is required for a nontrivial latency issue. If there's no user input and you see a lagged but smooth animation, you can simply shift your time function a little to synchronize everything. So if we're going to measure the latency, it's better to measure from the start of the input event. Measuring from the start of rendering is Ok (just like the monitors only measure latency from the input signal to the output pixels). But be aware that doesn't tell the full story of user-experienced latency.
@kenzieschmoll I have some doubts about the case 2 diagram. In my understanding, after the cpu calculation is completed, data is submitted to the gpu for rendering. Why does the gpu start rendering before the cpu ends in the diagram? Thank you for your answer.
Let's say I have two subsequent frames A and A+1 in chronological order. Is it possible for frame A is still in the middle of rasterizing while frame A+1 is in building phase (raster time of A overlaps with frame A+1's build time)?
Is it possible for frame A is still in the middle of rasterizing while frame A+1 is in building phase (raster time of A overlaps with frame A+1's build time)?
Yes this is possible, and most of the time expected. Build and Raster happen on two different threads and can happen in parallel.
Closing since there is no action to be taken here.
Starting an issue to track this discussion: what makes a frame janky?
Right now, we consider a frame to be janky when the sum of UI and GPU durations exceed the target time limit per frame (currently hard coded to ~16ms). We do not give each thread a 16ms threshold because we are also concerned with latency.
Question: To determine whether a frame is janky, should we A) add the durations of UI work and GPU work (current implementation), or B) use the duration of the frame?
Case 1: When both the sum of durations and frame duration meet the target, it does not matter which way we determine jank.
Case 2 (problem case): The sum of durations exceeds the target, but the frame duration does not.
Case 3 (problem case): The frame duration exceeds the target, but the sum of durations does not.