Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions shell/common/vsync_waiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "flutter/fml/task_runner.h"
#include "flutter/fml/trace_event.h"
#include "fml/message_loop_task_queues.h"
#include "fml/task_queue_id.h"

namespace flutter {

Expand Down Expand Up @@ -128,9 +129,12 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,

TRACE_FLOW_BEGIN("flutter", kVsyncFlowName, flow_identifier);

fml::TaskQueueId ui_task_queue_id =
task_runners_.GetUITaskRunner()->GetTaskQueueId();

task_runners_.GetUITaskRunner()->PostTaskForTime(
[this, callback, flow_identifier, frame_start_time, frame_target_time,
pause_secondary_tasks]() {
[ui_task_queue_id, 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);
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder =
Expand All @@ -140,7 +144,7 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
callback(std::move(frame_timings_recorder));
TRACE_FLOW_END("flutter", kVsyncFlowName, flow_identifier);
if (pause_secondary_tasks) {
ResumeDartMicroTasks();
ResumeDartMicroTasks(ui_task_queue_id);
}
},
frame_start_time);
Expand All @@ -158,8 +162,7 @@ void VsyncWaiter::PauseDartMicroTasks() {
task_queues->PauseSecondarySource(ui_task_queue_id);
}

void VsyncWaiter::ResumeDartMicroTasks() {
auto ui_task_queue_id = task_runners_.GetUITaskRunner()->GetTaskQueueId();
void VsyncWaiter::ResumeDartMicroTasks(fml::TaskQueueId ui_task_queue_id) {
auto task_queues = fml::MessageLoopTaskQueues::GetInstance();
task_queues->ResumeSecondarySource(ui_task_queue_id);
}
Expand Down
2 changes: 1 addition & 1 deletion shell/common/vsync_waiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class VsyncWaiter : public std::enable_shared_from_this<VsyncWaiter> {
std::unordered_map<uintptr_t, fml::closure> secondary_callbacks_;

void PauseDartMicroTasks();
void ResumeDartMicroTasks();
static void ResumeDartMicroTasks(fml::TaskQueueId ui_task_queue_id);

FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiter);
};
Expand Down