diff --git a/shell/platform/fuchsia/flutter/flatland_platform_view.cc b/shell/platform/fuchsia/flutter/flatland_platform_view.cc index ba71e15e7588e..cbadf9d47b6e0 100644 --- a/shell/platform/fuchsia/flutter/flatland_platform_view.cc +++ b/shell/platform/fuchsia/flutter/flatland_platform_view.cc @@ -182,17 +182,9 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created, FML_CHECK(weak); FML_CHECK(weak->child_view_info_.count(content_id.value) == 0); - // Bind the child view watcher to the platform thread so that the FIDL calls - // are handled on the platform thread. - fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher = - child_view_watcher_handle.Bind(); - FML_CHECK(child_view_watcher); - - child_view_watcher.set_error_handler( - [weak, view_id, content_id](zx_status_t status) { - FML_LOG(WARNING) << "Child disconnected. ChildViewWatcher status: " - << status; - + platform_task_runner->PostTask(fml::MakeCopyable( + [weak, view_id, content_id, + watcher_handle = std::move(child_view_watcher_handle)]() mutable { if (!weak) { FML_LOG(WARNING) << "Flatland View bound to PlatformView after PlatformView was " @@ -200,25 +192,33 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created, return; } - // Disconnected views cannot listen to pointer events. - weak->pointer_injector_delegate_->OnDestroyView(view_id); + // Bind the child view watcher to the platform thread so that the FIDL + // calls are handled on the platform thread. + fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher = + watcher_handle.Bind(); + FML_CHECK(child_view_watcher); - weak->OnChildViewDisconnected(content_id.value); - }); - - platform_task_runner->PostTask( - fml::MakeCopyable([weak, view_id, content_id, - watcher = std::move(child_view_watcher)]() mutable { - if (!weak) { + child_view_watcher.set_error_handler([weak, view_id, content_id]( + zx_status_t status) { FML_LOG(WARNING) - << "Flatland View bound to PlatformView after PlatformView was " - "destroyed; ignoring."; - return; - } + << "Child disconnected. ChildViewWatcher status: " << status; + + if (!weak) { + FML_LOG(WARNING) << "Flatland View bound to PlatformView after " + "PlatformView was " + "destroyed; ignoring."; + return; + } + + // Disconnected views cannot listen to pointer events. + weak->pointer_injector_delegate_->OnDestroyView(view_id); + + weak->OnChildViewDisconnected(content_id.value); + }); weak->child_view_info_.emplace( std::piecewise_construct, std::forward_as_tuple(content_id.value), - std::forward_as_tuple(view_id, std::move(watcher))); + std::forward_as_tuple(view_id, std::move(child_view_watcher))); weak->child_view_info_.at(content_id.value) .child_view_watcher->GetStatus(