Skip to content

[Windows] Document how to do the "show window" migration manually #127695

@loic-sharma

Description

@loic-sharma

Background

Flutter 3.10 app startup has a race condition that can result in the window not being shown. #127046 updated the app template to fix this issue. Windows projects will need to be updated after the next Flutter release. An automatic migration was added for projects that have not modified their Windows entry point. However, the automatic migration may not be able to modify projects that have modified their Windows entry point.

Part of: #119415
See: #127046 (comment)

Solution

After the next Flutter release, document how to do this migration manually.

Example migration:

diff --git a/examples/hello_world/windows/runner/flutter_window.cpp b/examples/hello_world/windows/runner/flutter_window.cpp
index f68aa9c26c0f5..7f66913a0293c 100644
--- a/examples/hello_world/windows/runner/flutter_window.cpp
+++ b/examples/hello_world/windows/runner/flutter_window.cpp
@@ -35,6 +35,11 @@ bool FlutterWindow::OnCreate() {
     this->Show();
   });
 
+  // Flutter can complete the first frame before the "show window" callback is
+  // registered. The following call ensures a frame is pending to ensure the
+  // window is shown. It is a no-op if the first frame hasn't completed yet.
+  flutter_controller_->ForceRedraw();
+
   return true;
 }

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: desktopRunning on desktopplatform-windowsBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions