未验证 提交 fa435385 编写于 作者: J Jason Simmons 提交者: GitHub

Use the GPU thread for Android surface on-screen context lifecycle operations (#8234)

Fixes https://github.com/flutter/flutter/issues/29679
上级 10e1addd
......@@ -45,15 +45,33 @@ void PlatformViewAndroid::NotifyCreated(
fml::RefPtr<AndroidNativeWindow> native_window) {
if (android_surface_) {
InstallFirstFrameCallback();
android_surface_->SetNativeWindow(native_window);
fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(),
[&latch, surface = android_surface_.get(),
native_window = std::move(native_window)]() {
surface->SetNativeWindow(native_window);
latch.Signal();
});
latch.Wait();
}
PlatformView::NotifyCreated();
}
void PlatformViewAndroid::NotifyDestroyed() {
PlatformView::NotifyDestroyed();
if (android_surface_) {
android_surface_->TeardownOnScreenContext();
fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(),
[&latch, surface = android_surface_.get()]() {
surface->TeardownOnScreenContext();
latch.Signal();
});
latch.Wait();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册