|
13 | 13 |
|
14 | 14 | namespace flutter { |
15 | 15 |
|
| 16 | +namespace { |
| 17 | +// The maximum duration to block the platform thread for while waiting |
| 18 | +// for a window resize operation to complete. |
| 19 | +constexpr std::chrono::milliseconds kWindowResizeTimeout{100}; |
| 20 | + |
16 | 21 | /// Returns true if the surface will be updated as part of the resize process. |
17 | 22 | /// |
18 | 23 | /// This is called on window resize to determine if the platform thread needs |
19 | 24 | /// to be blocked until the frame with the right size has been rendered. It |
20 | 25 | /// should be kept in-sync with how the engine deals with a new surface request |
21 | 26 | /// as seen in `CreateOrUpdateSurface` in `GPUSurfaceGL`. |
22 | | -static bool SurfaceWillUpdate(size_t cur_width, |
23 | | - size_t cur_height, |
24 | | - size_t target_width, |
25 | | - size_t target_height) { |
| 27 | +bool SurfaceWillUpdate(size_t cur_width, |
| 28 | + size_t cur_height, |
| 29 | + size_t target_width, |
| 30 | + size_t target_height) { |
26 | 31 | // TODO (https://github.com/flutter/flutter/issues/65061) : Avoid special |
27 | 32 | // handling for zero dimensions. |
28 | 33 | bool non_zero_target_dims = target_height > 0 && target_width > 0; |
29 | 34 | bool not_same_size = |
30 | 35 | (cur_height != target_height) || (cur_width != target_width); |
31 | 36 | return non_zero_target_dims && not_same_size; |
32 | 37 | } |
| 38 | +} // namespace |
33 | 39 |
|
34 | 40 | FlutterWindowsView::FlutterWindowsView( |
35 | 41 | std::unique_ptr<WindowBindingHandler> window_binding) { |
@@ -150,9 +156,10 @@ void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) { |
150 | 156 | // Block the platform thread until: |
151 | 157 | // 1. GetFrameBufferId is called with the right frame size. |
152 | 158 | // 2. Any pending SwapBuffers calls have been invoked. |
153 | | - resize_cv_.wait(lock, [&resize_status = resize_status_] { |
154 | | - return resize_status == ResizeState::kDone; |
155 | | - }); |
| 159 | + resize_cv_.wait_for(lock, kWindowResizeTimeout, |
| 160 | + [&resize_status = resize_status_] { |
| 161 | + return resize_status == ResizeState::kDone; |
| 162 | + }); |
156 | 163 | } |
157 | 164 | } |
158 | 165 |
|
|
0 commit comments