Skip to content

Flutter 3.35 freezes when switching to full screen mode on the Windows platform #176088

@CarGuo

Description

@CarGuo

Steps to reproduce

Run the following code to achieve full screen operation through windowManager on Win11, Only appears in release mode, not in debug modeflutter build windows), then click the button to exit full screen through windowManager, and the program freezes :

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();
  WindowOptions windowOptions = const WindowOptions(
    fullScreen: true,
    titleBarStyle: TitleBarStyle.hidden,
    alwaysOnTop: false,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });
  runApp(const TestApp());
}

class TestApp extends StatelessWidget {
  const TestApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            body: Center(
      child: TextButton(
          onPressed: () {
            windowManager.setFullScreen(false);
          },
          child: Text("Click me")),
    )));
  }
}

Expected results

Can switch between full screen and non full screen modes normally

Actual results

The program freezes after switching

Screenshots or Video

Screenshots / Video demonstration
7992aae9cd52eedf6369247dd7cedf53.mp4

This can fix by disabling merged threads on Windows by updating windows/runner/main.cpp file:

flutter::DartProject project(L"data");
project.set_ui_thread_policy(flutter::UIThreadPolicy::RunOnSeparateThread);

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: desktopRunning on desktopc: performanceRelates to speed or footprint issues (see "perf:" labels)c: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.found in release: 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryplatform-windowsBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamtriaged-windowsTriaged by the Windows platform teamworkaround availableThere is a workaround available to overcome the issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions