Fix a race in ShellTest.EncodeImageFailsWithoutGPUImpeller (#167669)

This commit is contained in:
Jason Simmons 2025-04-23 22:18:40 +00:00 committed by GitHub
parent 8440a6e75f
commit e1630da24f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -464,13 +464,16 @@ TEST_F(ShellTest, EncodeImageFailsWithoutGPUImpeller) {
AddNativeCallback("TurnOffGPU", CREATE_NATIVE_ENTRY(turn_off_gpu));
auto flush_awaiting_tasks = [&](Dart_NativeArguments args) {
task_runners.GetIOTaskRunner()->PostTask([&] {
std::shared_ptr<impeller::Context> impeller_context =
shell->GetIOManager()->GetImpellerContext();
// This will cause the stored tasks to overflow and start throwing them
// away.
for (int i = 0; i < impeller::Context::kMaxTasksAwaitingGPU; i++) {
impeller_context->StoreTaskForGPU([] {}, [] {});
fml::WeakPtr io_manager = shell->GetIOManager();
task_runners.GetIOTaskRunner()->PostTask([io_manager] {
if (io_manager) {
std::shared_ptr<impeller::Context> impeller_context =
io_manager->GetImpellerContext();
// This will cause the stored tasks to overflow and start throwing them
// away.
for (int i = 0; i < impeller::Context::kMaxTasksAwaitingGPU; i++) {
impeller_context->StoreTaskForGPU([] {}, [] {});
}
}
});
};