mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make resume dart microtasks static to avoid capturing vsync waiter (flutter/engine#26440)
This avoids the race where vsync waiter was shutdown before the tasks on ui task runner got flushed. Fixes: https://github.com/flutter/flutter/issues/82024
This commit is contained in:
parent
f552538752
commit
41ba3d48d1
@ -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 {
|
||||
|
||||
@ -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 =
|
||||
@ -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);
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user