mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Use the GPU thread for Android surface on-screen context lifecycle operations (#8234)
Fixes https://github.com/flutter/flutter/issues/29679
This commit is contained in:
parent
10e1addd8d
commit
fa435385b6
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user