Skip to content

Consider hiding windows until the engine is active in the desktop runner templates #55427

@stuartmorgan-g

Description

@stuartmorgan-g

A common request from people trying Flutter on desktop is being able to control initial window size and position from Dart, which makes sense given that application logic for Flutter apps often lives entirely in Dart. Currently, however, the windows are made as part of creating the associated engine, so their initial size is set in the platform (ObjC, C++) code.

The window_size FDE plugin (which will eventually be replaced with framework functionality) allows repositioning it, but because of the ordering and the async nature of engine startup, doing that at startup is very ugly; the window is briefly visible with one frame, then jumps to another frame. (This also means that the common desktop functionality of remembering window frames currently has to be done in platform code, not Dart, which is not ideal either.)

A possible solution here would be to have the runner template create the window hidden, and add an early lifecycle event to a system channel which would trigger the window to show. We could include a frame in that message, so that the window would only ever be visible with a frame controlled by Dart code. We could even consider having that message sent only after the first paint is finished to avoid an initial white frame.

This has to be balanced against the fact that it'll make the window slower to show up, but I think that will still be substantially better in most cases. If it's slow enough for that to be an issue, a splash screen that's separate from the window would be a much cleaner user experience (although of course ideally, it should be fast enough that that's not necessary)

Status:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.platform-linuxBuilding on or for Linux specificallyplatform-macBuilding on or for macOS specificallyplatform-windowsBuilding on or for Windows specificallyteam-macosOwned by the macOS platform teamtriaged-macosTriaged by the macOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions