Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
704f2348
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
704f2348
编写于
4月 20, 2021
作者:
K
Kaushik Iska
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pause dart microtasks while UI thread is processing frame workloads
上级
1019008f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
10 deletion
+41
-10
shell/common/shell_test.cc
shell/common/shell_test.cc
+1
-1
shell/common/shell_unittests.cc
shell/common/shell_unittests.cc
+1
-0
shell/common/vsync_waiter.cc
shell/common/vsync_waiter.cc
+22
-2
shell/common/vsync_waiter.h
shell/common/vsync_waiter.h
+5
-1
shell/common/vsync_waiter_fallback.cc
shell/common/vsync_waiter_fallback.cc
+6
-3
shell/common/vsync_waiter_fallback.h
shell/common/vsync_waiter_fallback.h
+3
-1
shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm
.../platform/darwin/ios/framework/Source/vsync_waiter_ios.mm
+2
-1
shell/platform/fuchsia/flutter/vsync_waiter.cc
shell/platform/fuchsia/flutter/vsync_waiter.cc
+1
-1
未找到文件。
shell/common/shell_test.cc
浏览文件 @
704f2348
...
...
@@ -325,7 +325,7 @@ std::unique_ptr<Shell> ShellTest::CreateShell(
std
::
make_unique
<
ShellTestVsyncWaiter
>
(
task_runners
,
vsync_clock
));
}
else
{
return
static_cast
<
std
::
unique_ptr
<
VsyncWaiter
>>
(
std
::
make_unique
<
VsyncWaiterFallback
>
(
task_runners
));
std
::
make_unique
<
VsyncWaiterFallback
>
(
task_runners
,
true
));
}
};
...
...
shell/common/shell_unittests.cc
浏览文件 @
704f2348
...
...
@@ -1335,6 +1335,7 @@ TEST_F(ShellTest, ReportTimingsIsCalledImmediatelyAfterTheFirstFrame) {
};
AddNativeCallback
(
"NativeReportTimingsCallback"
,
CREATE_NATIVE_ENTRY
(
nativeTimingCallback
));
ASSERT_TRUE
(
configuration
.
IsValid
());
RunEngine
(
shell
.
get
(),
std
::
move
(
configuration
));
for
(
int
i
=
0
;
i
<
10
;
i
+=
1
)
{
...
...
shell/common/vsync_waiter.cc
浏览文件 @
704f2348
...
...
@@ -91,7 +91,8 @@ void VsyncWaiter::ScheduleSecondaryCallback(uintptr_t id,
}
void
VsyncWaiter
::
FireCallback
(
fml
::
TimePoint
frame_start_time
,
fml
::
TimePoint
frame_target_time
)
{
fml
::
TimePoint
frame_target_time
,
bool
pause_secondary_tasks
)
{
Callback
callback
;
std
::
vector
<
fml
::
closure
>
secondary_callbacks
;
...
...
@@ -114,6 +115,9 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
if
(
callback
)
{
auto
flow_identifier
=
fml
::
tracing
::
TraceNonce
();
if
(
pause_secondary_tasks
)
{
PauseDartMicroTasks
();
}
// The base trace ensures that flows have a root to begin from if one does
// not exist. The trace viewer will ignore traces that have no base event
...
...
@@ -124,11 +128,15 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
TRACE_FLOW_BEGIN
(
"flutter"
,
kVsyncFlowName
,
flow_identifier
);
task_runners_
.
GetUITaskRunner
()
->
PostTaskForTime
(
[
callback
,
flow_identifier
,
frame_start_time
,
frame_target_time
]()
{
[
this
,
callback
,
flow_identifier
,
frame_start_time
,
frame_target_time
,
pause_secondary_tasks
]()
{
FML_TRACE_EVENT
(
"flutter"
,
kVsyncTraceName
,
"StartTime"
,
frame_start_time
,
"TargetTime"
,
frame_target_time
);
callback
(
frame_start_time
,
frame_target_time
);
TRACE_FLOW_END
(
"flutter"
,
kVsyncFlowName
,
flow_identifier
);
if
(
pause_secondary_tasks
)
{
ResumeDartMicroTasks
();
}
},
frame_start_time
);
}
...
...
@@ -139,4 +147,16 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
}
}
void
VsyncWaiter
::
PauseDartMicroTasks
()
{
auto
ui_task_queue_id
=
task_runners_
.
GetUITaskRunner
()
->
GetTaskQueueId
();
auto
task_queues
=
fml
::
MessageLoopTaskQueues
::
GetInstance
();
task_queues
->
PauseSecondarySource
(
ui_task_queue_id
);
}
void
VsyncWaiter
::
ResumeDartMicroTasks
()
{
auto
ui_task_queue_id
=
task_runners_
.
GetUITaskRunner
()
->
GetTaskQueueId
();
auto
task_queues
=
fml
::
MessageLoopTaskQueues
::
GetInstance
();
task_queues
->
ResumeSecondarySource
(
ui_task_queue_id
);
}
}
// namespace flutter
shell/common/vsync_waiter.h
浏览文件 @
704f2348
...
...
@@ -49,13 +49,17 @@ class VsyncWaiter : public std::enable_shared_from_this<VsyncWaiter> {
virtual
void
AwaitVSync
()
=
0
;
void
FireCallback
(
fml
::
TimePoint
frame_start_time
,
fml
::
TimePoint
frame_target_time
);
fml
::
TimePoint
frame_target_time
,
bool
pause_secondary_tasks
=
true
);
private:
std
::
mutex
callback_mutex_
;
Callback
callback_
;
std
::
unordered_map
<
uintptr_t
,
fml
::
closure
>
secondary_callbacks_
;
void
PauseDartMicroTasks
();
void
ResumeDartMicroTasks
();
FML_DISALLOW_COPY_AND_ASSIGN
(
VsyncWaiter
);
};
...
...
shell/common/vsync_waiter_fallback.cc
浏览文件 @
704f2348
...
...
@@ -21,8 +21,11 @@ static fml::TimePoint SnapToNextTick(fml::TimePoint value,
}
// namespace
VsyncWaiterFallback
::
VsyncWaiterFallback
(
TaskRunners
task_runners
)
:
VsyncWaiter
(
std
::
move
(
task_runners
)),
phase_
(
fml
::
TimePoint
::
Now
())
{}
VsyncWaiterFallback
::
VsyncWaiterFallback
(
TaskRunners
task_runners
,
bool
for_testing
)
:
VsyncWaiter
(
std
::
move
(
task_runners
)),
phase_
(
fml
::
TimePoint
::
Now
()),
for_testing_
(
for_testing
)
{}
VsyncWaiterFallback
::~
VsyncWaiterFallback
()
=
default
;
...
...
@@ -36,7 +39,7 @@ void VsyncWaiterFallback::AwaitVSync() {
auto
next
=
SnapToNextTick
(
fml
::
TimePoint
::
Now
(),
phase_
,
kSingleFrameInterval
);
FireCallback
(
next
,
next
+
kSingleFrameInterval
);
FireCallback
(
next
,
next
+
kSingleFrameInterval
,
!
for_testing_
);
}
}
// namespace flutter
shell/common/vsync_waiter_fallback.h
浏览文件 @
704f2348
...
...
@@ -15,12 +15,14 @@ namespace flutter {
/// A |VsyncWaiter| that will fire at 60 fps irrespective of the vsync.
class
VsyncWaiterFallback
final
:
public
VsyncWaiter
{
public:
VsyncWaiterFallback
(
TaskRunners
task_runners
);
explicit
VsyncWaiterFallback
(
TaskRunners
task_runners
,
bool
for_testing
=
false
);
~
VsyncWaiterFallback
()
override
;
private:
fml
::
TimePoint
phase_
;
const
bool
for_testing_
;
// |VsyncWaiter|
void
AwaitVSync
()
override
;
...
...
shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm
浏览文件 @
704f2348
...
...
@@ -23,7 +23,8 @@ VsyncWaiterIOS::VsyncWaiterIOS(flutter::TaskRunners task_runners)
callback:
std
:
:
bind
(
&
VsyncWaiterIOS
::
FireCallback
,
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
)])
{}
std
::
placeholders
::
_2
,
true
)])
{}
VsyncWaiterIOS
::~
VsyncWaiterIOS
()
{
// This way, we will get no more callbacks from the display link that holds a weak (non-nilling)
...
...
shell/platform/fuchsia/flutter/vsync_waiter.cc
浏览文件 @
704f2348
...
...
@@ -197,7 +197,7 @@ void VsyncWaiter::FireCallbackNow() {
}
fml
::
TimePoint
previous_vsync
=
next_vsync
-
vsync_info
.
presentation_interval
;
FireCallback
(
previous_vsync
,
next_vsync
);
FireCallback
(
previous_vsync
,
next_vsync
,
false
);
}
}
// namespace flutter_runner
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录