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

Conversation

@iskakaushik
Copy link
Contributor

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Jan 27, 2021

namespace flutter {

static bool IsValidResize(size_t cur_width,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a comment.

Also, I'm not sure "Valid" is really the right descriptor here. The OS is communicating something valid with a 0x0 resize.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to SurfaceWillUpdate, I am not a huge fan of it since the name expects the embedding to know when the engine will update the surface to synchronize resize events, open to alternative suggestions.

std::unique_lock<std::mutex> lock(resize_mutex_);
if (!IsValidResize(resize_target_width_, resize_target_height_, width,
height)) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the size doesn't change this is fine, but for 0x0 the surface actually is 0x0. Failing to send that information to the engine means will be out of sync with the surface it's drawing to. (I'm not clear on how problematic that could potentially be; e.g., is there potential for memory corruption as there would be in the case of a pixel buffer?)

Unless we're extremely confident that there will be no unexpected side-effects (given that this will need to be cherry-picked) I think for now, the safer approach would be to send the 0x0 metrics as we currently do and only bypass the resize state logic+blocking. We can leave a TODO with a pointer to flutter/flutter#65061 to resolve 0x0 handling in general, via something like a new embedder.h API that we call to tell the engine to suspend drawing, rather than doing nothing.

resize_target_height_ = height;
SendWindowMetrics(width, height, binding_handler_->GetDpiScale());

if (width > 0 && height > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I assumed from the bug description that we were blocking on an update that never came, but it looks like that already shouldn't have been the case. What exactly is causing the hang then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hang is caused because we don't ask for an FBO when the onscreen surface that is held transitively by the rasterizer is the same size as the requested size.

The resizing logic here assumes that every request to OnWindowSizeChanged will result in a new FBO being requested which is violated when we minimize-restore as we don't destroy the on-screen surface when that happens.

I will follow your recommendation and link to #23990 (comment) with a pointer that we likely want to destroy the on-screen surface when the application is minimized which would resolve this. For now, I will special case this in the resizing logic.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we're already keeping the old surface around? I thought it was controlled directly by the size we got from the OS (and thus would be zero-sized).

If we have a surface at the old size still, then I think I'm fine with your approach here, as long as you comment as to why.

@iskakaushik iskakaushik force-pushed the fix_windows_resize_deadlock branch from f94e4ec to ace3947 Compare January 27, 2021 18:15
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comment nit.


namespace flutter {

/// Returns true if the surface will be updated as part of the resize process.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you flesh this out to specifically say what other code this is required to stay in sync with?

Add more context around resizing.
@iskakaushik iskakaushik force-pushed the fix_windows_resize_deadlock branch from eabd8ea to 5394774 Compare January 28, 2021 16:06
@iskakaushik iskakaushik added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 28, 2021
@fluttergithubbot fluttergithubbot merged commit 3c3e2a4 into flutter:master Jan 28, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 28, 2021
christopherfujino added a commit that referenced this pull request Feb 3, 2021
…24142)

* add ffi_allocation_patch.dart to libraries.yaml 2 (#23954)

* Use `runes` to get code units in CanvasKit. (#24024)

* [windows] Honor only valid resize requests (#23990)

* Load FlutterLoader when creating FlutterEngineGroup (#23980)

* [canvaskit] remove the DOM node of unrendered platform view (#24001)

* update dart to 2.12.0-259.8.beta

* [web] Fix svg based stroke rendering. (#23969)

* [canvaskit] fix text background, foreground, color; add text style tests (#23800)

* [canvaskit] fix text background, foreground, familyFallback; add style tests

* add leak test

* update goldens_lock.yaml

* remove solo

* Warn when popping out of empty text style stack

* [web] Fix alignment issue in rich paragraphs (#23965)

* [web] Implement CanvasParagraph.getLineBoundary (#24037)

* [web] Fix text alignment when transform + tight constraints + DOM rendering (#24036)

* update licenses_third_party golden

Co-authored-by: Daco Harkes <[email protected]>
Co-authored-by: Harry Terkelsen <[email protected]>
Co-authored-by: Kaushik Iska <[email protected]>
Co-authored-by: xster <[email protected]>
Co-authored-by: Yegor <[email protected]>
Co-authored-by: Ferhat <[email protected]>
Co-authored-by: Mouad Debbar <[email protected]>
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flutter Application freezes when Maximized or Restored from Minimized window mode

3 participants