Improve diffs app usage of requestIdleCallback

Important

  • For the context of this effort, please see: #323616 (closed)
  • Until we can bring the TBT metric within acceptable ranges, that issue will stay open.
  • This issue tracks only the delivery of this solution/approach

Summary

In the diffs app we use requestIdleCallback to start the render queue for the diffs themselves. This is fine and allows us to wait until the browser is ready before doing anything. However, we should look at using the IdleDeadline passed in to determine how many diffs we can actually render in the idling time.

https://gitlab.com/gitlab-org/gitlab/-/blob/25c1fcfc6c58606789e78a96538173e7a5492e8f/app/assets/javascripts/diffs/components/app.vue#L352

Improvements

Look into using the IdleDeadline parameter passed into the requestIdleCallback callback method.

We should also look at other usages in the diffs app and see if we can improve them.

We could also look at adding this into rendering the diff lines themselves.

Risks

We should in theory improve the blocking time by only rendering what we know we can render. However, doing this probably means the total rendering time will increase as we wait for the browser to go idle before doing any rendering work.

This will probably be more visible when rendering diff lines.

Involved components

Optional: Intended side effects

Optional: Missing test coverage

/cc @andr3

Edited by André Luís