[windows] No frames are presented for any non-composited window state (hidden / cloaked / alpha-layered / fully off-screen) — request: an opt-in "keep rendering while not visible" switch

Đang mở
#197,046 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
12/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, dart

Hướng nghiên cứu

Start by reading windows_lifecycle_manager.cc to see how visibility is derived, then trace the present path from compositor_opengl.cc through egl/surface.cc and the vsync timer in flutter_windows_engine.cc, plus the busy-wait in flutter_windows_view.cc. Reproduce with a minimal Windows runner that cloaks its window and counts FrameTiming arrivals, as in the issue's snippet. Done means an agreed design (opt-in switch or documented support matrix) for presenting into a non-composited window.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

a: desktop c: new feature engine found in release: 3.47 platform-windows team-windows
Steps to reproduce

Any Flutter Windows app (tested on 3.47.7). From Dart, cloak the window, pump
forced frames, and count FrameTiming arrivals; then uncloak and repeat:

import 'dart:ffi';
import 'dart:ui' as ui;
import 'package:ffi/ffi.dart' show calloc;
import 'package:flutter/scheduler.dart';

// hwnd: FindWindowW on the runner window title, e.g. via a 2-line FFI
// shim — any handle for the app's top-level window works.
final dwmapi = DynamicLibrary.open('dwmapi.dll');
final int Function(int, int, Pointer<Int32>, int) _setAttr = dwmapi
    .lookupFunction<Int32 Function(IntPtr, Int32, Pointer<Int32>, Int32),
        int Function(int, int, Pointer<Int32>, int)>('DwmSetWindowAttribute');

void cloak(int hwnd, bool on) {
  final p = calloc<Int32>()..value = on ? 1 : 0;
  _setAttr(hwnd, 13 /* DWMWA_CLOAK */, p, 4); // or: ShowWindow(SW_HIDE),
  calloc.free(p);                             // or: SLWA alpha, or SetWindowPos off-screen
}

// Arm: addTimingsCallback counting arrivals. Pump: scheduleForcedFrame()
// every 16ms for 240 ticks (~3.8s).
//
// Observed while cloaked:      pumped=240, FrameTiming arrived=0
// Observed uncloaked:          pumped=240, arrived≈190 (vsync cadence)

Repeat the pump with each of these invisibility primitives — all five
starve on-demand and forced frames
after the pipeline idles:

Window state Continuous pump (pipeline never idles) On-demand / forced frame after idle wake
ShowWindow(SW_HIDE) 0 frames 0 frames
DWMWA_CLOAK 0 frames 0 frames (metrics + widget builds DO continue)
SetLayeredWindowAttributes(alpha=0) ≈1 frame/sec starved past any reasonable watchdog
SetLayeredWindowAttributes(alpha=1) + WS_EX_LAYERED ≈50 fps starved: e.g. 14/15 reveals hit a 250ms watchdog, zero FrameTiming
SetWindowPos fully outside all monitor rects (window WS_VISIBLE, uncloaked, perfectly normal to Win32) ≈50 fps starved: 5/6 reveals hit the 250ms watchdog, one raster release at 134ms

The pattern that matters for real apps: a pipeline that never idles keeps
rastering at ~50fps in the "softer" states (alpha=1, off-screen), but the
first on-demand frame after an idle period never presents.
A continuous
pump therefore looks alive while the state a launcher/floating-panel
actually needs — render one frame now that the user summoned content —
is dead.

Environment
  • Flutter 3.47.7 stable, Windows embedder (Impeller path)
  • Windows 11 Pro 26200, mixed-DPI dual monitor (1.25x / 1.5x)
  • Standard runner, per-overlay window = WS_POPUP + WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TOPMOST, backdrop DWMSBT_TRANSIENTWINDOW
What we verified in the embedder source (tag 3.47.7)
  • There is no explicit visibility gate anywhere in the Windows embedder:
    lifecycle visibility is derived purely from WM_SHOWWINDOW /
    WM_SIZE(SIZE_MINIMIZED) / WM_DESTROY (windows_lifecycle_manager.cc);
    vsync is a system-level timer (DwmGetCompositionTimingInfo(NULL, ...),
    flutter_windows_engine.cc); the framework has no FlutterView.visible.
    FrameTiming receipts are emitted only after eglSwapBuffers returns
    (compositor_opengl.cc → egl/surface.cc), so the stall is downstream of
    the embedder: the ANGLE window surface is a blt-model, 1-buffer
    swapchain
    (CreateSwapChainForHwnd, DXGI_SWAP_EFFECT_SEQUENTIAL —
    Flutter does not pass EGL_DIRECT_COMPOSITION_ANGLE), and present
    appears to be gated on DWM consuming the window — which stops for every
    state in the table above. (Mechanism attribution is our hypothesis, but
    it is the only one consistent with all five cells plus the ~0.75s
    present-backlog drain we measure at reveal.)
  • Secondary finding: FlutterWindowsView::OnWindowSizeChanged blocks the
    platform thread in a busy-wait for up to kWindowResizeTimeout
    (100ms, flutter_windows_view.cc) until a frame is presented. While
    the window is in any non-composited state, no present ever lands, so
    every resize burns ~100ms of the platform thread — the thread that
    pumps messages for ALL windows of the process in multi-window apps — and
    leaves a pending resize target that a later frame "fulfills" (the
    mechanism described in #194679).
Use case

Floating panels (launchers, command palettes, switchers, clipboard bars)
must be invisible between summons. Every desktop stack we checked can
pre-render content invisibly and then reveal atomically — WinUI3 apps
cloak the window, wait for the first composition frame, then uncloak
(microsoft/PowerToys #39170, #52105); WPF apps cloak after
UpdateLayout() (Flow-Launcher #3391); on macOS, alphaValue = 0 +
orderFrontRegardless keeps AppKit rendering. Flutter Windows is the one
stack where there is no window state that renders on demand while the
user cannot see it
, so the panel always opens with the PREVIOUS session's
last frame composited for 1-2 frames — a visible stale-content flash.

Request

An opt-in switch — engine-level or FlutterView-level (e.g.
"keep presenting while hidden", possibly implemented as a DComp surface
path or a copy-model present that is not gated on composition) — so a
Windows Flutter app can render a fresh frame into an invisible window and
reveal it atomically. Even a documented, supported statement of "which
states can present on demand" would settle the design space; today the
answer has to be discovered by experiment, and the answer is "none".

Related: #194679 (resize state machine + pending-target fulfill),
#191870 / #190075 / #191865 (the same zero-present family on Linux/macOS).

Ngôn ngữ chính
Dart
Star
181k
Fork
32.2k
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
387

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flutter/flutter

Tất cả issue của flutter/flutter

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.