Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions shell/platform/windows/angle_surface_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

#include "flutter/shell/platform/windows/angle_surface_manager.h"

#include <iostream>
#include <vector>

#include "flutter/fml/logging.h"

// Logs an EGL error to stderr. This automatically calls eglGetError()
// and logs the error code.
static void LogEglError(std::string message) {
EGLint error = eglGetError();
std::cerr << "EGL: " << message << std::endl;
std::cerr << "EGL: eglGetError returned " << error << std::endl;
FML_LOG(ERROR) << "EGL: " << message;
FML_LOG(ERROR) << "EGL: eglGetError returned " << error;
}

namespace flutter {
Expand Down Expand Up @@ -245,8 +246,8 @@ void AngleSurfaceManager::ResizeSurface(WindowsRenderTarget* render_target,
ClearContext();
DestroySurface();
if (!CreateSurface(render_target, width, height)) {
std::cerr << "AngleSurfaceManager::ResizeSurface failed to create surface"
<< std::endl;
FML_LOG(ERROR)
<< "AngleSurfaceManager::ResizeSurface failed to create surface";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/windows/external_texture_d3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <iostream>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/embedder/embedder_struct_macros.h"

namespace flutter {
Expand Down Expand Up @@ -107,7 +107,7 @@ bool ExternalTextureD3d::CreateOrUpdateTexture(
if (egl_surface_ == EGL_NO_SURFACE ||
eglBindTexImage(surface_manager_->egl_display(), egl_surface_,
EGL_BACK_BUFFER) == EGL_FALSE) {
std::cerr << "Binding D3D surface failed." << std::endl;
FML_LOG(ERROR) << "Binding D3D surface failed.";
}
last_surface_handle_ = handle;
}
Expand Down
18 changes: 8 additions & 10 deletions shell/platform/windows/flutter_project_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "flutter/shell/platform/windows/flutter_project_bundle.h"

#include <filesystem>
#include <iostream>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/common/engine_switches.h" // nogncheck
#include "flutter/shell/platform/common/path_utils.h"

Expand Down Expand Up @@ -34,9 +34,8 @@ FlutterProjectBundle::FlutterProjectBundle(
(!aot_library_path_.empty() && aot_library_path_.is_relative())) {
std::filesystem::path executable_location = GetExecutableDirectory();
if (executable_location.empty()) {
std::cerr
<< "Unable to find executable location to resolve resource paths."
<< std::endl;
FML_LOG(ERROR)
<< "Unable to find executable location to resolve resource paths.";
assets_path_ = std::filesystem::path();
icu_path_ = std::filesystem::path();
} else {
Expand All @@ -59,14 +58,13 @@ bool FlutterProjectBundle::HasValidPaths() {
UniqueAotDataPtr FlutterProjectBundle::LoadAotData(
const FlutterEngineProcTable& engine_procs) {
if (aot_library_path_.empty()) {
std::cerr
<< "Attempted to load AOT data, but no aot_library_path was provided."
<< std::endl;
FML_LOG(ERROR)
<< "Attempted to load AOT data, but no aot_library_path was provided.";
return UniqueAotDataPtr(nullptr, nullptr);
}
if (!std::filesystem::exists(aot_library_path_)) {
std::cerr << "Can't load AOT data from " << aot_library_path_.u8string()
<< "; no such file." << std::endl;
FML_LOG(ERROR) << "Can't load AOT data from "
<< aot_library_path_.u8string() << "; no such file.";
return UniqueAotDataPtr(nullptr, nullptr);
}
std::string path_string = aot_library_path_.u8string();
Expand All @@ -76,7 +74,7 @@ UniqueAotDataPtr FlutterProjectBundle::LoadAotData(
FlutterEngineAOTData data = nullptr;
auto result = engine_procs.CreateAOTData(&source, &data);
if (result != kSuccess) {
std::cerr << "Failed to load AOT data from: " << path_string << std::endl;
FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
return UniqueAotDataPtr(nullptr, nullptr);
}
return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
Expand Down
4 changes: 3 additions & 1 deletion shell/platform/windows/flutter_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <chrono>
#include <map>

#include "flutter/fml/logging.h"

namespace flutter {

namespace {
Expand Down Expand Up @@ -121,7 +123,7 @@ static uint64_t ConvertWinButtonToFlutterButton(UINT button) {
case XBUTTON2:
return kFlutterPointerButtonMouseForward;
}
std::cerr << "Mouse button not recognized: " << button << std::endl;
FML_LOG(WARNING) << "Mouse button not recognized: " << button;
return 0;
}

Expand Down
46 changes: 23 additions & 23 deletions shell/platform/windows/flutter_windows_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iostream>
#include <sstream>

#include "flutter/fml/logging.h"
#include "flutter/fml/platform/win/wstring_conversion.h"
#include "flutter/shell/platform/common/client_wrapper/binary_messenger_impl.h"
#include "flutter/shell/platform/common/path_utils.h"
Expand Down Expand Up @@ -156,17 +157,18 @@ FlutterWindowsEngine::FlutterWindowsEngine(const FlutterProjectBundle& project)
embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
FlutterEngineGetProcAddresses(&embedder_api_);

task_runner_ = std::make_unique<TaskRunner>(
embedder_api_.GetCurrentTime, [this](const auto* task) {
if (!engine_) {
std::cerr << "Cannot post an engine task when engine is not running."
<< std::endl;
return;
}
if (embedder_api_.RunTask(engine_, task) != kSuccess) {
std::cerr << "Failed to post an engine task." << std::endl;
}
});
task_runner_ =
std::make_unique<TaskRunner>(
embedder_api_.GetCurrentTime, [this](const auto* task) {
if (!engine_) {
FML_LOG(ERROR)
<< "Cannot post an engine task when engine is not running.";
return;
}
if (embedder_api_.RunTask(engine_, task) != kSuccess) {
FML_LOG(ERROR) << "Failed to post an engine task.";
}
});

// Set up the legacy structs backing the API handles.
messenger_ = std::make_unique<FlutterDesktopMessenger>();
Expand Down Expand Up @@ -206,15 +208,15 @@ bool FlutterWindowsEngine::Run() {

bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
if (!project_->HasValidPaths()) {
std::cerr << "Missing or unresolvable paths to assets." << std::endl;
FML_LOG(ERROR) << "Missing or unresolvable paths to assets.";
return false;
}
std::string assets_path_string = project_->assets_path().u8string();
std::string icu_path_string = project_->icu_path().u8string();
if (embedder_api_.RunsAOTCompiledDartCode()) {
aot_data_ = project_->LoadAotData(embedder_api_);
if (!aot_data_) {
std::cerr << "Unable to start engine without AOT data." << std::endl;
FML_LOG(ERROR) << "Unable to start engine without AOT data.";
return false;
}
}
Expand Down Expand Up @@ -272,10 +274,9 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
// method and only the entrypoint specified in project_ should be used.
if (!project_->dart_entrypoint().empty() && !entrypoint.empty() &&
project_->dart_entrypoint() != entrypoint) {
std::cerr << "Conflicting entrypoints were specified in "
"FlutterDesktopEngineProperties.dart_entrypoint and "
"FlutterDesktopEngineRun(engine, entry_point). "
<< std::endl;
FML_LOG(ERROR) << "Conflicting entrypoints were specified in "
"FlutterDesktopEngineProperties.dart_entrypoint and "
"FlutterDesktopEngineRun(engine, entry_point). ";
return false;
}
if (!entrypoint.empty()) {
Expand Down Expand Up @@ -339,8 +340,7 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) {
auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
&args, this, &engine_);
if (result != kSuccess || engine_ == nullptr) {
std::cerr << "Failed to start Flutter engine: error " << result
<< std::endl;
FML_LOG(ERROR) << "Failed to start Flutter engine: error " << result;
return false;
}

Expand Down Expand Up @@ -454,7 +454,7 @@ bool FlutterWindowsEngine::SendPlatformMessage(
embedder_api_.PlatformMessageCreateResponseHandle(
engine_, reply, user_data, &response_handle);
if (result != kSuccess) {
std::cout << "Failed to create response handle\n";
FML_LOG(ERROR) << "Failed to create response handle";
return false;
}
}
Expand Down Expand Up @@ -486,9 +486,9 @@ void FlutterWindowsEngine::SendPlatformMessageResponse(
void FlutterWindowsEngine::HandlePlatformMessage(
const FlutterPlatformMessage* engine_message) {
if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
std::cerr << "Invalid message size received. Expected: "
<< sizeof(FlutterPlatformMessage) << " but received "
<< engine_message->struct_size << std::endl;
FML_LOG(ERROR) << "Invalid message size received. Expected: "
<< sizeof(FlutterPlatformMessage) << " but received "
<< engine_message->struct_size;
return;
}

Expand Down
8 changes: 4 additions & 4 deletions shell/platform/windows/flutter_windows_texture_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "flutter/shell/platform/windows/flutter_windows_texture_registrar.h"

#include <iostream>
#include <mutex>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/embedder/embedder_struct_macros.h"
#include "flutter/shell/platform/windows/external_texture_d3d.h"
#include "flutter/shell/platform/windows/external_texture_pixelbuffer.h"
Expand All @@ -31,7 +31,7 @@ int64_t FlutterWindowsTextureRegistrar::RegisterTexture(

if (texture_info->type == kFlutterDesktopPixelBufferTexture) {
if (!texture_info->pixel_buffer_config.callback) {
std::cerr << "Invalid pixel buffer texture callback." << std::endl;
FML_LOG(ERROR) << "Invalid pixel buffer texture callback.";
return kInvalidTexture;
}

Expand All @@ -47,7 +47,7 @@ int64_t FlutterWindowsTextureRegistrar::RegisterTexture(
surface_type == kFlutterDesktopGpuSurfaceTypeD3d11Texture2D) {
auto callback = SAFE_ACCESS(gpu_surface_config, callback, nullptr);
if (!callback) {
std::cerr << "Invalid GPU surface descriptor callback." << std::endl;
FML_LOG(ERROR) << "Invalid GPU surface descriptor callback.";
return kInvalidTexture;
}

Expand All @@ -58,7 +58,7 @@ int64_t FlutterWindowsTextureRegistrar::RegisterTexture(
}
}

std::cerr << "Attempted to register texture of unsupport type." << std::endl;
FML_LOG(ERROR) << "Attempted to register texture of unsupport type.";
return kInvalidTexture;
}

Expand Down
5 changes: 2 additions & 3 deletions shell/platform/windows/keyboard_key_channel_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#include <windows.h>

#include <iostream>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/common/json_message_codec.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"

Expand Down Expand Up @@ -139,7 +138,7 @@ void KeyboardKeyChannelHandler::KeyboardHook(
event.AddMember(kTypeKey, kKeyUp, allocator);
break;
default:
std::cerr << "Unknown key event action: " << action << std::endl;
FML_LOG(WARNING) << "Unknown key event action: " << action;
callback(false);
return;
}
Expand Down
7 changes: 3 additions & 4 deletions shell/platform/windows/keyboard_key_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#include <windows.h>

#include <iostream>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"

namespace flutter {
Expand Down Expand Up @@ -48,10 +47,10 @@ void KeyboardKeyHandler::KeyboardHook(int key,
incoming->callback = std::move(callback);

if (pending_responds_.size() > kMaxPendingEvents) {
std::cerr
FML_LOG(ERROR)
<< "There are " << pending_responds_.size()
<< " keyboard events that have not yet received a response from the "
<< "framework. Are responses being sent?" << std::endl;
<< "framework. Are responses being sent?";
}
pending_responds_.push_back(std::move(incoming));

Expand Down
9 changes: 4 additions & 5 deletions shell/platform/windows/keyboard_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// found in the LICENSE file.

#include <assert.h>
#include <iostream>
#include <memory>
#include <string>

#include "flutter/fml/logging.h"
#include "flutter/shell/platform/windows/keyboard_manager.h"
#include "flutter/shell/platform/windows/keyboard_utils.h"

Expand Down Expand Up @@ -120,15 +120,14 @@ void KeyboardManager::RedispatchEvent(std::unique_ptr<PendingEvent> event) {
UINT result = window_delegate_->Win32DispatchMessage(
message.action, message.wparam, message.lparam);
if (result != 0) {
std::cerr << "Unable to synthesize event for keyboard event."
<< std::endl;
FML_LOG(ERROR) << "Unable to synthesize event for keyboard event.";
}
}
if (pending_redispatches_.size() > kMaxPendingEvents) {
std::cerr
FML_LOG(ERROR)
<< "There are " << pending_redispatches_.size()
<< " keyboard events that have not yet received a response from the "
<< "framework. Are responses being sent?" << std::endl;
<< "framework. Are responses being sent?";
}
}

Expand Down
13 changes: 8 additions & 5 deletions shell/platform/windows/platform_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <windows.h>

#include <cstring>
#include <iostream>
#include <optional>

#include "flutter/fml/logging.h"
#include "flutter/fml/platform/win/wstring_conversion.h"
#include "flutter/shell/platform/common/json_method_codec.h"
#include "flutter/shell/platform/windows/flutter_windows_view.h"
Expand Down Expand Up @@ -41,14 +41,16 @@ class ScopedGlobalMemory {
ScopedGlobalMemory(unsigned int flags, size_t bytes) {
memory_ = ::GlobalAlloc(flags, bytes);
if (!memory_) {
std::cerr << "Unable to allocate global memory: " << ::GetLastError();
FML_LOG(ERROR) << "Unable to allocate global memory: "
<< ::GetLastError();
}
}

~ScopedGlobalMemory() {
if (memory_) {
if (::GlobalFree(memory_) != nullptr) {
std::cerr << "Failed to free global allocation: " << ::GetLastError();
FML_LOG(ERROR) << "Failed to free global allocation: "
<< ::GetLastError();
}
}
}
Expand Down Expand Up @@ -79,7 +81,7 @@ class ScopedGlobalLock {
if (memory) {
locked_memory_ = ::GlobalLock(memory);
if (!locked_memory_) {
std::cerr << "Unable to acquire global lock: " << ::GetLastError();
FML_LOG(ERROR) << "Unable to acquire global lock: " << ::GetLastError();
}
}
}
Expand All @@ -89,7 +91,8 @@ class ScopedGlobalLock {
if (!::GlobalUnlock(source_)) {
DWORD error = ::GetLastError();
if (error != NO_ERROR) {
std::cerr << "Unable to release global lock: " << ::GetLastError();
FML_LOG(ERROR) << "Unable to release global lock: "
<< ::GetLastError();
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/windows/task_runner_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "flutter/shell/platform/windows/task_runner_window.h"

#include <algorithm>
#include <iostream>

#include "flutter/fml/logging.h"

namespace flutter {

Expand Down Expand Up @@ -52,7 +53,7 @@ std::shared_ptr<TaskRunnerWindow> TaskRunnerWindow::GetSharedInstance() {

void TaskRunnerWindow::WakeUp() {
if (!PostMessage(window_handle_, WM_NULL, 0, 0)) {
std::cerr << "Failed to post message to main thread." << std::endl;
FML_LOG(ERROR) << "Failed to post message to main thread.";
}
}

Expand Down