Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
flush per task.
  • Loading branch information
jonahwilliams committed May 28, 2025
commit ce948baa96deff349b9ceba51c3c2fda1fd9098d
35 changes: 21 additions & 14 deletions engine/src/flutter/impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,27 @@ new ContextMTL(flags, device, command_queue,
Lock lock(tasks_awaiting_gpu_mutex_);
std::swap(tasks_awaiting_gpu, tasks_awaiting_gpu_);
}
is_gpu_disabled_sync_switch_->Execute(
fml::SyncSwitch::Handlers()
.SetIfFalse([&] {
for (const auto& task : tasks_awaiting_gpu) {
task.task();
}
})
.SetIfTrue([&] {
// Lost access to the GPU immediately after it was activated. This
// may happen if the app was quickly foregrounded/backgrounded from
// a push notification. Store the tasks on the context again.
Lock lock(tasks_awaiting_gpu_mutex_);
std::swap(tasks_awaiting_gpu, tasks_awaiting_gpu_);
}));
std::vector<PendingTasks> tasks_to_queue;
for (const auto& task : tasks_awaiting_gpu) {
is_gpu_disabled_sync_switch_->Execute(fml::SyncSwitch::Handlers()
.SetIfFalse([&] { task.task(); })
.SetIfTrue([&] {
// Lost access to the GPU
// immediately after it was
// activated. This may happen if
// the app was quickly
// foregrounded/backgrounded
// from a push notification.
// Store the tasks on the
// context again.
tasks_to_queue.push_back(task);
}));
}
if (!tasks_to_queue.empty()) {
Lock lock(tasks_awaiting_gpu_mutex_);
tasks_awaiting_gpu_.insert(tasks_awaiting_gpu_.end(),
tasks_to_queue.begin(), tasks_to_queue.end());
}
}

ContextMTL::SyncSwitchObserver::SyncSwitchObserver(ContextMTL& parent)
Expand Down