Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a1101e9

Browse files
authored
[fuchsia] Bind ChildViewWatcher on platform thread (#42222)
This CL posts ChildViewWatcher calls on platform thread. Bug: fxb/125256
1 parent 2a325ee commit a1101e9

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

shell/platform/fuchsia/flutter/flatland_platform_view.cc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -182,43 +182,43 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created,
182182
FML_CHECK(weak);
183183
FML_CHECK(weak->child_view_info_.count(content_id.value) == 0);
184184

185-
// Bind the child view watcher to the platform thread so that the FIDL calls
186-
// are handled on the platform thread.
187-
fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher =
188-
child_view_watcher_handle.Bind();
189-
FML_CHECK(child_view_watcher);
190-
191-
child_view_watcher.set_error_handler(
192-
[weak, view_id, content_id](zx_status_t status) {
193-
FML_LOG(WARNING) << "Child disconnected. ChildViewWatcher status: "
194-
<< status;
195-
185+
platform_task_runner->PostTask(fml::MakeCopyable(
186+
[weak, view_id, content_id,
187+
watcher_handle = std::move(child_view_watcher_handle)]() mutable {
196188
if (!weak) {
197189
FML_LOG(WARNING)
198190
<< "Flatland View bound to PlatformView after PlatformView was "
199191
"destroyed; ignoring.";
200192
return;
201193
}
202194

203-
// Disconnected views cannot listen to pointer events.
204-
weak->pointer_injector_delegate_->OnDestroyView(view_id);
195+
// Bind the child view watcher to the platform thread so that the FIDL
196+
// calls are handled on the platform thread.
197+
fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher =
198+
watcher_handle.Bind();
199+
FML_CHECK(child_view_watcher);
205200

206-
weak->OnChildViewDisconnected(content_id.value);
207-
});
208-
209-
platform_task_runner->PostTask(
210-
fml::MakeCopyable([weak, view_id, content_id,
211-
watcher = std::move(child_view_watcher)]() mutable {
212-
if (!weak) {
201+
child_view_watcher.set_error_handler([weak, view_id, content_id](
202+
zx_status_t status) {
213203
FML_LOG(WARNING)
214-
<< "Flatland View bound to PlatformView after PlatformView was "
215-
"destroyed; ignoring.";
216-
return;
217-
}
204+
<< "Child disconnected. ChildViewWatcher status: " << status;
205+
206+
if (!weak) {
207+
FML_LOG(WARNING) << "Flatland View bound to PlatformView after "
208+
"PlatformView was "
209+
"destroyed; ignoring.";
210+
return;
211+
}
212+
213+
// Disconnected views cannot listen to pointer events.
214+
weak->pointer_injector_delegate_->OnDestroyView(view_id);
215+
216+
weak->OnChildViewDisconnected(content_id.value);
217+
});
218218

219219
weak->child_view_info_.emplace(
220220
std::piecewise_construct, std::forward_as_tuple(content_id.value),
221-
std::forward_as_tuple(view_id, std::move(watcher)));
221+
std::forward_as_tuple(view_id, std::move(child_view_watcher)));
222222

223223
weak->child_view_info_.at(content_id.value)
224224
.child_view_watcher->GetStatus(

0 commit comments

Comments
 (0)