[fuchsia] Log unregistered platform channels only once (flutter/engine#18064)
This is to reduce log spam. Fixes: https://github.com/flutter/flutter/issues/55966
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ class PlatformView final : public flutter::PlatformView,
|
||||
fit::function<void(
|
||||
fml::RefPtr<flutter::PlatformMessage> /* 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<std::string /* channel */> unregistered_channels_;
|
||||
zx_handle_t vsync_event_handle_ = 0;
|
||||
|
||||
void RegisterPlatformMessageHandlers();
|
||||
|
||||
Reference in New Issue
Block a user