[flutter] Create the compositor context on the GPU task runner. (flutter/engine#10781)

The compositor context owns the session connection. The creation of the
session connection also does the initial present to clear the node
hierarchy. This present was happening perviously on the platform task
runner while all subsequent presents were on the GPU task runner. This
has now been rectified so all presents are on the GPU task runner.

BUG: FL-288
Change-Id: Ib294666ffb3b4575f93ad0b02a5d0fda71bfa0a8
This commit is contained in:
Kaushik Iska
2019-08-08 18:08:57 -07:00
committed by GitHub
parent 158315caf9
commit 6c97d0384f
5 changed files with 36 additions and 33 deletions

View File

@@ -62,13 +62,13 @@ CompositorContext::CompositorContext(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> 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(

View File

@@ -23,7 +23,7 @@ class CompositorContext final : public flutter::CompositorContext {
CompositorContext(std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fit::closure session_error_callback,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle);
~CompositorContext() override;

View File

@@ -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<flutter::CompositorContext> compositor_context;
{
TRACE_EVENT0("flutter", "CreateCompositorContext");
compositor_context = std::make_unique<flutter_runner::CompositorContext>(
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<flutter::Rasterizer> on_create_rasterizer =
fml::MakeCopyable([compositor_context = std::move(compositor_context)](
flutter::Shell& shell) mutable {
return std::make_unique<flutter::Rasterizer>(
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<flutter::Rasterizer> 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<flutter_runner::CompositorContext> compositor_context;
{
TRACE_DURATION("flutter", "CreateCompositorContext");
compositor_context =
std::make_unique<flutter_runner::CompositorContext>(
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<flutter::Rasterizer>(
shell.GetTaskRunners(), // task runners
std::move(compositor_context) // compositor context
);
});
UpdateNativeThreadLabelNames(thread_label_, task_runners);
settings_.verbose_logging = true;

View File

@@ -16,7 +16,7 @@ SessionConnection::SessionConnection(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> 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_);

View File

@@ -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<fuchsia::ui::scenic::Session> 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<VulkanSurfaceProducer> surface_producer_;
flutter::SceneUpdateContext scene_update_context_;
zx_handle_t vsync_event_handle_;
// A flow event trace id for following |Session::Present| calls into