keframe icon indicating copy to clipboard operation
keframe copied to clipboard

optimize the separated frame mechanisms

Open Nayuta403 opened this issue 3 years ago • 6 comments
trafficstars

  • [ ] #18

Nayuta403 avatar Apr 03 '22 08:04 Nayuta403

这个 issue 现在是什么进度呢?

youchant avatar Aug 29 '22 08:08 youchant

还没进度,现在的情况是说每次任务只渲染一个 widget,但其实可能它不怎么耗时。希望做到说,如果这个任务不怎么耗时,那么是不是可以再执行一个任务。

但这个依赖于,要得到每一个任务的执行时间,现在的每一个任务是 setState,这玩意儿在当前帧只是一个标记操作,下一帧执行耗时,所以没法拿到这一帧的时间。

我能想到的是,能不能先去把这个任务机制改下,不做 setState, 看下有没有办法直接在这一帧渲染 widget。一来可以统计时间(但这个时间只是 framework 的,可能没那么准),二来可以提升整个页面的渲染速度(理论上页面完成渲染的时间会快两倍)。

Nayuta403 avatar Sep 07 '22 03:09 Nayuta403

Not yet. At this point we're only rendering one widget per task, but it's probably not that time-consuming. Hopefully, if this task is not too time-consuming, can you execute another task?

But this depends on, you know, getting the execution time of each task, now each task is setState, this thing is markNeedsBuild operation in the current frame, the next frame takes time to execute, so you can't get the time for that frame.

The only thing I can think of is if I can change the task mechanism without setState and see if there is a way to render the widget directly in this frame. First, it can count the time (but this time is only framework, may not be so accurate), and second, it can improve the rendering speed of the whole page (theoretically, the page will finish rendering time twice faster).

Nayuta403 avatar Sep 07 '22 03:09 Nayuta403

I seem to come up with a solution here: https://github.com/flutter/flutter/issues/101227#issuecomment-1250056634

fzyzcjy avatar Sep 17 '22 11:09 fzyzcjy

I seem to come up with a solution here: flutter/flutter#101227 (comment)

Will there be a pull request any time soon? to test the solution.

inc16sec avatar Sep 19 '22 23:09 inc16sec

@inc16sec It is in https://github.com/fzyzcjy/flutter_smooth, but still WIP!

fzyzcjy avatar Sep 19 '22 23:09 fzyzcjy