From 9525672548022d55f8d08037dfa0a61f5396e02a Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Thu, 30 Apr 2020 15:25:48 -0700 Subject: [PATCH] [fuchsia] Log unregistered platform channels only once (flutter/engine#18064) This is to reduce log spam. Fixes: https://github.com/flutter/flutter/issues/55966 --- .../platform/fuchsia/flutter/platform_view.cc | 16 +++++++++++----- .../platform/fuchsia/flutter/platform_view.h | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.cc index 3795589ac6..d991c898f4 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.cc @@ -578,12 +578,18 @@ void PlatformView::HandlePlatformMessage( if (!message) { return; } - auto found = platform_message_handlers_.find(message->channel()); + const std::string channel = message->channel(); + auto found = platform_message_handlers_.find(channel); if (found == platform_message_handlers_.end()) { - FML_LOG(ERROR) - << "Platform view received message on channel '" << message->channel() - << "' with no registered handler. And empty response will be " - "generated. Please implement the native message handler."; + const bool already_errored = unregistered_channels_.count(channel); + if (!already_errored) { + FML_LOG(INFO) + << "Platform view received message on channel '" << message->channel() + << "' with no registered handler. And empty response will be " + "generated. Please implement the native message handler. This " + "message will appear only once per channel."; + unregistered_channels_.insert(channel); + } flutter::PlatformView::HandlePlatformMessage(std::move(message)); return; } diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.h b/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.h index a4b52028e7..1d13d4f660 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/platform_view.h @@ -109,6 +109,10 @@ class PlatformView final : public flutter::PlatformView, fit::function /* message */)> /* handler */> platform_message_handlers_; + // These are the channels that aren't registered and have been notified as + // such. Notifying via logs multiple times results in log-spam. See: + // https://github.com/flutter/flutter/issues/55966 + std::set unregistered_channels_; zx_handle_t vsync_event_handle_ = 0; void RegisterPlatformMessageHandlers();