Skip to content

Commit

Permalink
[fuchsia] Add more logging for error cases. (flutter#29397)
Browse files Browse the repository at this point in the history
  • Loading branch information
akbiggs committed Nov 4, 2021
1 parent 3364409 commit 4684d23
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
9 changes: 9 additions & 0 deletions shell/platform/fuchsia/flutter/component_v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions shell/platform/fuchsia/flutter/component_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/fuchsia/flutter/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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();
}
};
Expand Down
12 changes: 7 additions & 5 deletions shell/platform/fuchsia/flutter/gfx_session_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

#include "gfx_session_connection.h"

#include <lib/async/cpp/time.h>
#include <lib/async/default.h>

#include <lib/async/cpp/task.h>
#include <lib/async/cpp/time.h>
#include <lib/async/default.h>
#include <lib/fit/function.h>
#include <zircon/status.h>

#include "flutter/fml/make_copyable.h"
#include "flutter/fml/time/time_point.h"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4684d23

Please sign in to comment.