Preempt
📄️ Idea
Starting from plain
📄️ How to trigger
By normal function call. The psuedo simplified core code looks like:
📄️ When to trigger
The answer is, when inside the build or layout phase, just call it when now - lastVsyncTime > threshold where threshold is smaller than and near 16.67ms. In other words, trigger when we are near a deadline. Using pseudo-code, it is:
📄️ What to do
Abstractly speaking, we should produce a new UI when doing a preempt. For example, when showing enter-page animation, the new UI will be a screen shifting pixel by pixel as time goes by.
📄️ PreemptBuilder
If this package stops at the API above, nobody will use it - you will have to write a ton of code to modify the Layer tree by yourself. The goal in this part is to create a developer-friendly API, indeed the PreemptBuilder. Recall the definition of PreemptBuilder(builder ...) - put the things that you want to be smooth inside the builder, and we are done. How is that implemented?
📄️ Post draw frame
Problem