-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specifically
Description
Using Flutter on Windows Devices, if the FlutterWnd is hidden and then reshown, the FlutterViewController will be blank. The Widgets won't be drawn until we trigger the update manually.
The bug as shown in the video:
flutter_win_hide-show_bug.mp4
Steps to Reproduce
- Create a Windows demo
- Copy and paste 'Code Sample' into main.cpp
- flutter run
- The window will be displayed after the Demo started, and it will hidden after 13 seconds.
- At then it will be reshown agin, but the FlutterViewController will be 'blank'.
Expected results:
The FlutterViewController should draw the Widgets.
Actual results:
Only blank page.
Code sample
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <windows.h>
#include "flutter_window.h"
#include "utils.h"
#include <Windows.h>
#include <iostream>
static HWND sFlutterWnd = nullptr;
static void CALLBACK HideTimerProc(HWND hwnd, UINT nMsg, UINT_PTR nTimerId, DWORD dwTime)
{
std::cout << "HideTimeProc fired" << std::endl;
::ShowWindow(sFlutterWnd, SW_HIDE);
::KillTimer(sFlutterWnd, 1);
}
static void CALLBACK ShowTimerProc(HWND hwnd, UINT nMsg, UINT_PTR nTimerId, DWORD dwTime)
{
std::cout << "ShowTimeProc fired" << std::endl;
::ShowWindow(sFlutterWnd, SW_SHOWNORMAL);
::KillTimer(sFlutterWnd, 2);
}
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
CreateAndAttachConsole();
}
// Initialize COM, so that it is available for use in the library and/or
// plugins.
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
flutter::DartProject project(L"data");
std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"example", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
sFlutterWnd = window.GetHandle();
// hide
SetTimer(sFlutterWnd, 1, 13 * 1000, HideTimerProc);
// show
SetTimer(sFlutterWnd, 2, 15 * 1000, ShowTimerProc);
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
::CoUninitialize();
return EXIT_SUCCESS;
}
Logs
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.4-0.0.pre.1, on Microsoft Windows [Version 10.0.19042.1586], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.10)[√] Android Studio (version 2020.3)
[√] VS Code (version 1.66.0)
[√] Connected device (3 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specifically