-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to Reproduce
- Paste the application pasted below inside IntelliJ.
- Start emulator or attach a physical device
- Click the Run (>) button to run the app (same issue from flutter run)
- Both the log and the button shows ui.window.physicalSize=Size(0.0, 0.0)
Note: Terminate the app and Run (>) again a few times if first run does not reproduce.
This does not happen in 100% of tries; in the emulator, almost always. On a physical device (tried Z160) less often.
Logs
Logs from IDE
On first application start, the size is reported incorrectly as (0,0) - both in emulation and physical device.
Launching examples/build_size_bug_on_first_plugin.dart on Android SDK built for x86 in debug mode...
Running 'gradle assembleDebug'...
Built build/app/outputs/apk/app-debug.apk (21.6MB).
I/flutter ( 3819): ### Size: ui.window.physicalSize=Size(0.0, 0.0), windowLogicalSize=Size(0.0, 0.0),logicalSize=Size(0.0, 0.0)
I/Choreographer( 3819): Skipped 37 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 3819): eglMakeCurrent: 0xade85660: ver 2 0 (tinfo 0xade83ed0)
Syncing files to device Android SDK built for x86...
After clicking the + Button, size reported correctly
I/flutter ( 3819): ### Size: ui.window.physicalSize=Size(768.0, 1184.0), windowLogicalSize=Size(384.0, 592.0),logicalSize=Size(384.0, 296.0)
I/flutter ( 3819): ### Size: ui.window.physicalSize=Size(768.0, 1184.0), windowLogicalSize=Size(384.0, 592.0),logicalSize=Size(384.0, 296.0)
I/flutter ( 3819): ### Size: ui.window.physicalSize=Size(768.0, 1184.0), windowLogicalSize=Size(384.0, 592.0),logicalSize=Size(384.0, 296.0)
Also correct after restarting (hitting the Run> button), size reported correctly
Performing full restart...
I/flutter ( 3819): ### Size: ui.window.physicalSize=Size(768.0, 1184.0), windowLogicalSize=Size(384.0, 592.0),logicalSize=Size(384.0, 296.0)
Restarted app in 1,361ms.
Logs from flutter run
mzimmermann@home-server:~/dev/my-projects-source/public-on-github/flutter_experiments> flutter run examples/build_size_bug_on_first_plugin.dart
Launching examples/build_size_bug_on_first_plugin.dart on Android SDK built for x86 in debug mode...
Running 'gradle assembleDebug'... 1.8s
Built build/app/outputs/apk/app-debug.apk (21.6MB).
I/flutter ( 3988): ### Size: ui.window.physicalSize=Size(0.0, 0.0), windowLogicalSize=Size(0.0, 0.0),logicalSize=Size(0.0, 0.0)
I/Choreographer( 3988): Skipped 43 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 3988): eglMakeCurrent: 0xaab05540: ver 2 0 (tinfo 0xaab03f30)
Syncing files to device Android SDK built for x86... 3.5s
🔥 To hot reload your app on the fly, press "r". To restart the app entirely, press "R".
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:8110/
For a more detailed help message, press "h". To quit, press "q".
Run flutter analyze and attach any output of that command also.
mzimmermann@home-server:~/dev/my-projects-source/public-on-github/flutter_experiments> flutter analyze
Analyzing /home/mzimmermann/dev/my-projects-source/public-on-github/flutter_experiments...
hint • Unused import at examples/build_size_bug_on_first_plugin.dart:2:8 • unused_import
hint • Unused import at examples/build_size_bug_on_first_plugin.dart:5:8 • unused_import
2 issues found.
(Ran in 7.2s)
Flutter Doctor
Paste the output of running flutter doctor here.
mzimmermann@home-server:~/dev/my-projects-source/public-on-github/flutter_experiments> flutter doctor
[✓] Flutter (on Linux, locale en_CA.UTF-8, channel alpha)
• Flutter at /home/mzimmermann/software/flutter/gitclone/flutter
• Framework revision d36e2f6191 (8 weeks ago), 2017-06-21 15:09:10 -0700
• Engine revision b0dee695ec
• Tools Dart version 1.24.0-dev.6.7
[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at /home/mzimmermann/software/android/studio/sdk
• Platform android-25, build-tools 25.0.3
• ANDROID_HOME = /home/mzimmermann/software/android/studio/sdk
• Java binary at: /home/mzimmermann/software/android/studio/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] Android Studio (version 2.3)
• Android Studio at /home/mzimmermann/software/android/studio/android-studio
• Gradle version 3.2
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] IntelliJ IDEA Ultimate Edition (version 2017.2)
• Flutter plugin version 16.0
• Dart plugin version 172.3544.10
[✓] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.0 (API 24) (emulator)
The code
I can probably simplify, the only thing that seems to matter is asking for
ui.window.physicalSize
inside build()
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart' as widgets; // note: external package imp
import 'dart:ui' as ui;
import 'dart:math' as math;
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo Title',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _stateChanger() {
this.setState(() { // on State
});
}
@override
Widget build(BuildContext context) {
final double devicePixelRatio = ui.window.devicePixelRatio;
final ui.Size windowLogicalSize = ui.window.physicalSize / devicePixelRatio;
// Let us give the Painter full width and half of height.
final ui.Size logicalSize =
new Size(windowLogicalSize.width, windowLogicalSize.height / 2);
print(" ### Size: ui.window.physicalSize=${ui.window.physicalSize}, "
"windowLogicalSize=$windowLogicalSize,"
"logicalSize=$logicalSize");
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'size=$logicalSize - this prints (0,0) in first run after device connect.',
),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _stateChanger,
tooltip: 'Just force a refresh',
child: new Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods. );
);
}
}maryx and yunyu
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team