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

Commit ace3947

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

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

shell/platform/windows/flutter_windows_view.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88

99
namespace flutter {
1010

11+
/// Returns true if the surface will be updated as part of the resize process.
12+
static bool SurfaceWillUpdate(size_t cur_width,
13+
size_t cur_height,
14+
size_t target_width,
15+
size_t target_height) {
16+
// TODO (https://github.com/flutter/flutter/issues/65061) : Avoid special
17+
// handling for zero dimensions.
18+
bool non_zero_dims = target_height > 0 && target_width > 0;
19+
bool not_same_size =
20+
(cur_height != target_height) || (cur_width != target_width);
21+
return non_zero_dims && not_same_size;
22+
}
23+
1124
FlutterWindowsView::FlutterWindowsView(
1225
std::unique_ptr<WindowBindingHandler> window_binding) {
1326
surface_manager_ = std::make_unique<AngleSurfaceManager>();
@@ -80,12 +93,18 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) {
8093
void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) {
8194
// Called on the platform thread.
8295
std::unique_lock<std::mutex> lock(resize_mutex_);
83-
resize_status_ = ResizeState::kResizeStarted;
84-
resize_target_width_ = width;
85-
resize_target_height_ = height;
96+
97+
bool surface_will_update = SurfaceWillUpdate(
98+
resize_target_width_, resize_target_height_, width, height);
99+
if (surface_will_update) {
100+
resize_status_ = ResizeState::kResizeStarted;
101+
resize_target_width_ = width;
102+
resize_target_height_ = height;
103+
}
104+
86105
SendWindowMetrics(width, height, binding_handler_->GetDpiScale());
87106

88-
if (width > 0 && height > 0) {
107+
if (surface_will_update) {
89108
// Block the platform thread until:
90109
// 1. GetFrameBufferId is called with the right frame size.
91110
// 2. Any pending SwapBuffers calls have been invoked.

0 commit comments

Comments
 (0)