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

Conversation

@loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Apr 9, 2023

Currently, closing the window does the following:

  1. The FlutterWindowsView destroys its surface
  2. The FlutterWindowsView destroys the FlutterWindowsEngine it owns
  3. The FlutterWindowsEngine shuts down the real engine (1, 2)

As a result, the raster thread may attempt to draw to a destroyed surface. This change ensures the engine is shutdown before destroying the view's resources. This ensures the raster thread is stopped before the underlying surface is destroyed.

Addresses flutter/flutter#124463

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@loic-sharma loic-sharma marked this pull request as ready for review April 9, 2023 01:37
Copy link
Contributor

@yaakovschectman yaakovschectman left a comment

Choose a reason for hiding this comment

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

LGTM save for one nit. Thanks!

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Looks good.

I can't remember, do we allow headless execution on Windows? If so, we probably want to only shutdown if headless execution isn't permitted. On macOS/iOS we do this by setting an ivar in our engine wrapper. On Linux we have a separate headless renderer.

@loic-sharma
Copy link
Member Author

loic-sharma commented Apr 12, 2023

I can't remember, do we allow headless execution on Windows?

Kind of. On Windows you can create an engine and run it without attaching a view controller. During that period, Windows is effectively running in headless mode and will ignore attempts to render. However, the Windows engine cannot transition back to headless mode once a view controller has been attached. The view controller owns the engine, destroying the view controller will shutdown the engine. This is something we'll fix as part of the multi-view work :)

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 12, 2023
@auto-submit auto-submit bot merged commit 5c65118 into flutter:main Apr 12, 2023
zhongwuzw pushed a commit to zhongwuzw/engine that referenced this pull request Apr 14, 2023
…41012)

[Windows] Shutdown the engine before destroying the surface
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants