Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f94e4ec

Browse files
committed
[windows] Honor only valid resize requests
Fixes: flutter/flutter#74797
1 parent 3035bc5 commit f94e4ec

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

shell/platform/windows/flutter_windows_view.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
namespace flutter {
1010

11+
static bool IsValidResize(size_t cur_width,
12+
size_t cur_height,
13+
size_t target_width,
14+
size_t target_height) {
15+
bool non_zero_dims = target_height > 0 && target_width > 0;
16+
bool not_same_size =
17+
(cur_height != target_height) || (cur_width != target_width);
18+
return non_zero_dims && not_same_size;
19+
}
20+
1121
FlutterWindowsView::FlutterWindowsView(
1222
std::unique_ptr<WindowBindingHandler> window_binding) {
1323
surface_manager_ = std::make_unique<AngleSurfaceManager>();
@@ -80,19 +90,22 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) {
8090
void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) {
8191
// Called on the platform thread.
8292
std::unique_lock<std::mutex> lock(resize_mutex_);
93+
if (!IsValidResize(resize_target_width_, resize_target_height_, width,
94+
height)) {
95+
return;
96+
}
97+
8398
resize_status_ = ResizeState::kResizeStarted;
8499
resize_target_width_ = width;
85100
resize_target_height_ = height;
86101
SendWindowMetrics(width, height, binding_handler_->GetDpiScale());
87102

88-
if (width > 0 && height > 0) {
89-
// Block the platform thread until:
90-
// 1. GetFrameBufferId is called with the right frame size.
91-
// 2. Any pending SwapBuffers calls have been invoked.
92-
resize_cv_.wait(lock, [&resize_status = resize_status_] {
93-
return resize_status == ResizeState::kDone;
94-
});
95-
}
103+
// Block the platform thread until:
104+
// 1. GetFrameBufferId is called with the right frame size.
105+
// 2. Any pending SwapBuffers calls have been invoked.
106+
resize_cv_.wait(lock, [&resize_status = resize_status_] {
107+
return resize_status == ResizeState::kDone;
108+
});
96109
}
97110

98111
void FlutterWindowsView::OnPointerMove(double x, double y) {

0 commit comments

Comments
 (0)