diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc index 1f4c8e854fd48..61d1bf99c2cac 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/shell/platform/fuchsia/flutter/compositor_context.cc @@ -62,13 +62,13 @@ CompositorContext::CompositorContext( std::string debug_label, fuchsia::ui::views::ViewToken view_token, fidl::InterfaceHandle session, - fit::closure session_error_callback, + fml::closure session_error_callback, zx_handle_t vsync_event_handle) : debug_label_(std::move(debug_label)), session_connection_(debug_label_, std::move(view_token), std::move(session), - std::move(session_error_callback), + session_error_callback, vsync_event_handle) {} void CompositorContext::OnSessionMetricsDidChange( diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h index 80dc103f36780..290bd0883f436 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ b/shell/platform/fuchsia/flutter/compositor_context.h @@ -23,7 +23,7 @@ class CompositorContext final : public flutter::CompositorContext { CompositorContext(std::string debug_label, fuchsia::ui::views::ViewToken view_token, fidl::InterfaceHandle session, - fit::closure session_error_callback, + fml::closure session_error_callback, zx_handle_t vsync_event_handle); ~CompositorContext() override; diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 7c85458193db7..9dd97677006d3 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -134,7 +134,7 @@ Engine::Engine(Delegate& delegate, // This handles the fidl error callback when the Session connection is // broken. The SessionListener interface also has an OnError method, which is // invoked on the platform thread (in PlatformView). - fit::closure on_session_error_callback = + fml::closure on_session_error_callback = [dispatcher = async_get_default_dispatcher(), weak = weak_factory_.GetWeakPtr()]() { async::PostTask(dispatcher, [weak]() { @@ -144,30 +144,6 @@ Engine::Engine(Delegate& delegate, }); }; - // Create the compositor context from the scenic pointer to create the - // rasterizer. - std::unique_ptr compositor_context; - { - TRACE_EVENT0("flutter", "CreateCompositorContext"); - compositor_context = std::make_unique( - thread_label_, // debug label - std::move(view_token), // scenic view we attach our tree to - std::move(session), // scenic session - std::move(on_session_error_callback), // session did encounter error - vsync_event_.get() // vsync event handle - ); - } - - // Setup the callback that will instantiate the rasterizer. - flutter::Shell::CreateCallback on_create_rasterizer = - fml::MakeCopyable([compositor_context = std::move(compositor_context)]( - flutter::Shell& shell) mutable { - return std::make_unique( - shell.GetTaskRunners(), // task runners - std::move(compositor_context) // compositor context - ); - }); - // Get the task runners from the managed threads. The current thread will be // used as the "platform" thread. const flutter::TaskRunners task_runners( @@ -178,6 +154,33 @@ Engine::Engine(Delegate& delegate, CreateFMLTaskRunner(threads_[2]->dispatcher()) // io ); + // Setup the callback that will instantiate the rasterizer. + flutter::Shell::CreateCallback on_create_rasterizer = + fml::MakeCopyable([thread_label = thread_label_, // + view_token = std::move(view_token), // + session = std::move(session), // + on_session_error_callback, // + vsync_event = vsync_event_.get() // + ](flutter::Shell& shell) mutable { + std::unique_ptr compositor_context; + { + TRACE_DURATION("flutter", "CreateCompositorContext"); + compositor_context = + std::make_unique( + thread_label, // debug label + std::move(view_token), // scenic view we attach our tree to + std::move(session), // scenic session + on_session_error_callback, // session did encounter error + vsync_event // vsync event handle + ); + } + + return std::make_unique( + shell.GetTaskRunners(), // task runners + std::move(compositor_context) // compositor context + ); + }); + UpdateNativeThreadLabelNames(thread_label_, task_runners); settings_.verbose_logging = true; diff --git a/shell/platform/fuchsia/flutter/session_connection.cc b/shell/platform/fuchsia/flutter/session_connection.cc index 21e06564b1850..8f82b9338278b 100644 --- a/shell/platform/fuchsia/flutter/session_connection.cc +++ b/shell/platform/fuchsia/flutter/session_connection.cc @@ -16,7 +16,7 @@ SessionConnection::SessionConnection( std::string debug_label, fuchsia::ui::views::ViewToken view_token, fidl::InterfaceHandle session, - fit::closure session_error_callback, + fml::closure session_error_callback, zx_handle_t vsync_event_handle) : debug_label_(std::move(debug_label)), session_wrapper_(session.Bind(), nullptr), @@ -27,9 +27,7 @@ SessionConnection::SessionConnection( scene_update_context_(&session_wrapper_, surface_producer_.get()), vsync_event_handle_(vsync_event_handle) { session_wrapper_.set_error_handler( - [callback = std::move(session_error_callback)](zx_status_t status) { - callback(); - }); + [callback = session_error_callback](zx_status_t status) { callback(); }); session_wrapper_.SetDebugName(debug_label_); diff --git a/shell/platform/fuchsia/flutter/session_connection.h b/shell/platform/fuchsia/flutter/session_connection.h index 6f740a2e5748e..4183b91467eca 100644 --- a/shell/platform/fuchsia/flutter/session_connection.h +++ b/shell/platform/fuchsia/flutter/session_connection.h @@ -16,6 +16,7 @@ #include "flutter/flow/compositor_context.h" #include "flutter/flow/scene_update_context.h" +#include "flutter/fml/closure.h" #include "flutter/fml/macros.h" #include "flutter/fml/trace_event.h" #include "vulkan_surface_producer.h" @@ -29,7 +30,7 @@ class SessionConnection final { SessionConnection(std::string debug_label, fuchsia::ui::views::ViewToken view_token, fidl::InterfaceHandle session, - fit::closure session_error_callback, + fml::closure session_error_callback, zx_handle_t vsync_event_handle); ~SessionConnection(); @@ -68,6 +69,7 @@ class SessionConnection final { std::unique_ptr surface_producer_; flutter::SceneUpdateContext scene_update_context_; + zx_handle_t vsync_event_handle_; // A flow event trace id for following |Session::Present| calls into