Skip to content

[Desktop] Cannot close app if using dart:ui directly #126033

Closed
@loic-sharma

Description

@loic-sharma

Problem

On the master channel, "raw" dart:ui apps without widgets cannot be closed using the x in the title bar:

  • Windows - The window remains open
  • macOS - The window closes, however, both the app and flutter run do not exit. On stable, the window, app, and flutter run all exit.
  • Linux - First close attempt does nothing, second close attempt prints the error ** (layers:754): WARNING **: 10:07:23.518: Error returned from System.requestAppExit: Requested method is not implemented and the app exits.

Background

#30735 allowed Flutter apps to listen to application exits using the System.exitApplication handler registered by ServicesBinding. This works as expected for Flutter apps that have widgets.

However, "raw" Flutter apps that use dart:ui directly without widgets don't register a ServicesBinding, and the System.exitApplication handler is never registered. As a result, the embedder's application exit messages aren't processed and the app does not exit.

Reproduction

  1. Switch to the master channel
  2. Run the hello_world raw layer example on Windows or macOS:
    1. cd ./flutter/examples/layers
    2. If on Windows: flutter create --platforms=windows .
    3. If on Linux: flutter create --platforms=linux .
    4. flutter run ./raw/hello_world.dart
  3. Close the app using the x button on the app's title bar

The app should shutdown, however, it stays open.

/cc @yaakovschectman @gspencergoog

Metadata

Metadata

Labels

P0Critical issues such as a build break or regressiona: desktopRunning on desktopplatform-linuxBuilding on or for Linux specificallyplatform-macBuilding on or for macOS specificallyplatform-windowsBuilding on or for Windows specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions