-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
a: desktopRunning on desktopRunning on desktopc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.39Found to occur in 3.39Found to occur in 3.39frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has 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 specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-windowsOwned by the Windows platform teamOwned by the Windows platform team
Description
Display(id: 65537, size: Size(3456.0, 2090.0), devicePixelRatio: 2.0, refreshRate: 120.0)
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: 'dart:ui/window.dart': Failed assertion: line 106 pos 12: '<optimized out>': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:67:4)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:49:5)
#2 FlutterView.display (dart:ui/window.dart:106:12)
#3 main (package:untitled/main.dart:64:64)
#4 _runMain.<anonymous closure> (dart:ui/hooks.dart:345:23)
#5 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:314:19)
#6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)How to reproduce:
import 'dart:convert';
import 'dart:ffi';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// GOOD CALL
print(WidgetsBinding.instance.platformDispatcher.views.first.display);
final user32 = DynamicLibrary.open('user32.dll');
final msvcrt = DynamicLibrary.open('msvcrt.dll');
final malloc = msvcrt
.lookupFunction<
Pointer<Void> Function(IntPtr),
Pointer<Void> Function(int)
>('malloc');
final findWindowA = user32
.lookupFunction<
Pointer<Void> Function(Pointer<Int8>, Pointer<Int8>),
Pointer<Void> Function(Pointer<Int8>, Pointer<Int8>)
>('FindWindowA');
final setWindowPos = user32
.lookupFunction<
Int32 Function(
Pointer<Void>,
Pointer<Void>,
Int32,
Int32,
Int32,
Int32,
Uint32,
),
int Function(Pointer<Void>, Pointer<Void>, int, int, int, int, int)
>('SetWindowPos');
final classNameBytes = [...ascii.encode('FLUTTER_RUNNER_WIN32_WINDOW'), 0];
final ptr = malloc(classNameBytes.length).cast<Int8>();
for (var i = 0; i < classNameBytes.length; i++) {
ptr[i] = classNameBytes[i];
}
final hwnd = findWindowA(ptr, nullptr.cast());
if (hwnd.address != 0) {
setWindowPos(
hwnd,
nullptr,
0,
0,
100,
200,
// SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED
0x0004 | 0x0010 | 0x0020,
);
}
// ALREADY BAD CALL
print(WidgetsBinding.instance.platformDispatcher.views.first.display);
runApp(const MaterialApp(debugShowCheckedModeBanner: false, home: Test()));
}
class Test extends StatelessWidget {
const Test({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF0F2F5),
body: Center(
child: SizedBox(
width: 1000,
height: 600,
child: GridView.builder(
padding: const EdgeInsets.all(20),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 20,
mainAxisSpacing: 20,
childAspectRatio: 16 / 9,
),
itemCount: 8,
itemBuilder: (context, index) {
return SizedBox(child: Text('123'));
},
),
),
),
);
}
}Doctor v
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.38.3, on Microsoft Windows [Version 10.0.26100.7171], locale en-US)
[√] Windows Version (Windows 11 or higher, 24H2, 2009)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.14.21 (November 2025))
[√] Connected device (2 available)
[√] Network resources
! Doctor found issues in 2 categories.
SetWindowPos is used to change size of app' window
Metadata
Metadata
Assignees
Labels
a: desktopRunning on desktopRunning on desktopc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.39Found to occur in 3.39Found to occur in 3.39frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has 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 specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-windowsOwned by the Windows platform teamOwned by the Windows platform team