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

Commit 3c3e2a4

Browse files
authored
[windows] Honor only valid resize requests (#23990)
1 parent f9c0985 commit 3c3e2a4

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

shell/platform/windows/flutter_windows_view.cc

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

99
namespace flutter {
1010

11+
/// Returns true if the surface will be updated as part of the resize process.
12+
///
13+
/// This is called on window resize to determine if the platform thread needs
14+
/// to be blocked until the frame with the right size has been rendered. It
15+
/// should be kept in-sync with how the engine deals with a new surface request
16+
/// as seen in `CreateOrUpdateSurface` in `GPUSurfaceGL`.
17+
static bool SurfaceWillUpdate(size_t cur_width,
18+
size_t cur_height,
19+
size_t target_width,
20+
size_t target_height) {
21+
// TODO (https://github.com/flutter/flutter/issues/65061) : Avoid special
22+
// handling for zero dimensions.
23+
bool non_zero_dims = target_height > 0 && target_width > 0;
24+
bool not_same_size =
25+
(cur_height != target_height) || (cur_width != target_width);
26+
return non_zero_dims && not_same_size;
27+
}
28+
1129
FlutterWindowsView::FlutterWindowsView(
1230
std::unique_ptr<WindowBindingHandler> window_binding) {
1331
surface_manager_ = std::make_unique<AngleSurfaceManager>();
@@ -80,12 +98,18 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) {
8098
void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) {
8199
// Called on the platform thread.
82100
std::unique_lock<std::mutex> lock(resize_mutex_);
83-
resize_status_ = ResizeState::kResizeStarted;
84-
resize_target_width_ = width;
85-
resize_target_height_ = height;
101+
102+
bool surface_will_update = SurfaceWillUpdate(
103+
resize_target_width_, resize_target_height_, width, height);
104+
if (surface_will_update) {
105+
resize_status_ = ResizeState::kResizeStarted;
106+
resize_target_width_ = width;
107+
resize_target_height_ = height;
108+
}
109+
86110
SendWindowMetrics(width, height, binding_handler_->GetDpiScale());
87111

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

0 commit comments

Comments
 (0)