From af8d122a438c601bdcf21a569ba75efba367edfd Mon Sep 17 00:00:00 2001 From: Alexander Biggs Date: Thu, 4 Nov 2021 17:28:01 -0400 Subject: [PATCH] [fuchsia] Add more logging for error cases. (flutter/engine#29397) --- .../shell/platform/fuchsia/flutter/component_v1.cc | 9 +++++++++ .../shell/platform/fuchsia/flutter/component_v2.cc | 9 +++++++++ .../flutter/shell/platform/fuchsia/flutter/engine.cc | 4 ++++ .../fuchsia/flutter/gfx_session_connection.cc | 12 +++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc index 721a4fd2274..2c6b95f4c06 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc @@ -485,6 +485,11 @@ void ComponentV1::OnEngineTerminate(const Engine* shell_holder) { }); if (found == shell_holders_.end()) { + // This indicates a deeper issue with memory management and should never + // happen. + FML_LOG(ERROR) << "Tried to terminate an unregistered shell holder."; + FML_DCHECK(false); + return; } @@ -494,11 +499,15 @@ void ComponentV1::OnEngineTerminate(const Engine* shell_holder) { auto return_code = shell_holder->GetEngineReturnCode(); if (return_code.has_value()) { last_return_code_ = {true, return_code.value()}; + } else { + FML_LOG(ERROR) << "Failed to get return code from terminated shell holder."; } shell_holders_.erase(found); if (shell_holders_.size() == 0) { + FML_VLOG(-1) << "Killing component because all shell holders have been " + "terminated."; Kill(); // WARNING: Don't do anything past this point because the delegate may have // collected this instance via the termination callback. diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc index 7d079196dc1..f5f83c9ccdc 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc @@ -535,6 +535,11 @@ void ComponentV2::OnEngineTerminate(const Engine* shell_holder) { }); if (found == shell_holders_.end()) { + // This indicates a deeper issue with memory management and should never + // happen. + FML_LOG(ERROR) << "Tried to terminate an unregistered shell holder."; + FML_DCHECK(false); + return; } @@ -544,11 +549,15 @@ void ComponentV2::OnEngineTerminate(const Engine* shell_holder) { auto return_code = shell_holder->GetEngineReturnCode(); if (return_code.has_value()) { last_return_code_ = {true, return_code.value()}; + } else { + FML_LOG(ERROR) << "Failed to get return code from terminated shell holder."; } shell_holders_.erase(found); if (shell_holders_.size() == 0) { + FML_VLOG(-1) << "Killing component because all shell holders have been " + "terminated."; Kill(); // WARNING: Don't do anything past this point because the delegate may have // collected this instance via the termination callback. diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc index dd590b596e2..859208b10c9 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc @@ -222,6 +222,7 @@ void Engine::Initialize( weak = weak_factory_.GetWeakPtr()]() { task_runner->PostTask([weak]() { if (weak) { + FML_LOG(ERROR) << "Terminating from session_error_callback"; weak->Terminate(); } }); @@ -340,6 +341,8 @@ void Engine::Initialize( weak = weak_factory_.GetWeakPtr()]() { task_runner->PostTask([weak]() { if (weak) { + FML_LOG(ERROR) << "Terminating from " + "on_session_listener_error_callback"; weak->Terminate(); } }); @@ -619,6 +622,7 @@ void Engine::Initialize( // The engine could have been killed by the caller right after the // constructor was called but before it could run on the UI thread. if (weak) { + FML_LOG(ERROR) << "Terminating from on_run_failure"; weak->Terminate(); } }; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/gfx_session_connection.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/gfx_session_connection.cc index 688016b3071..530b07d8e76 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/gfx_session_connection.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/gfx_session_connection.cc @@ -4,12 +4,11 @@ #include "gfx_session_connection.h" +#include #include #include - -#include -#include #include +#include #include "flutter/fml/make_copyable.h" #include "flutter/fml/time/time_point.h" @@ -222,8 +221,11 @@ GfxSessionConnection::GfxSessionConnection( next_presentation_info_.set_presentation_time(0); - session_wrapper_.set_error_handler( - [callback = session_error_callback](zx_status_t status) { callback(); }); + session_wrapper_.set_error_handler([callback = session_error_callback]( + zx_status_t status) { + FML_LOG(ERROR) << "scenic::Session error: " << zx_status_get_string(status); + callback(); + }); // Set the |fuchsia::ui::scenic::OnFramePresented()| event handler that will // fire every time a set of one or more frames is presented.