Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In release mode we start off at 0x0 but we don't in debug mode #5259

Closed
dragostis opened this issue Aug 5, 2016 · 13 comments
Closed

In release mode we start off at 0x0 but we don't in debug mode #5259

dragostis opened this issue Aug 5, 2016 · 13 comments
Labels
a: animation Animation APIs framework flutter/packages/flutter repository. See also f: labels.

Comments

@dragostis
Copy link
Contributor

Consider the following applet:

void main() {
  runApp(
    new MaterialApp(
      title: 'Bug Showcase',
      theme: new ThemeData(
        primarySwatch: Colors.blue
      ),
      home: new LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
          print(constraints);
          return new Container();
        }
      )
    )
  );
}

Running with flutter run this outputs:

I/flutter : BoxConstraints(w=360.0, h=640.0)

Running with flutter run --release this outputs:

I/flutter : BoxConstraints(w=0.0, h=0.0)
I/flutter : BoxConstraints(w=360.0, h=640.0)

This is problematic especially in the case of animating a widget based on its initial constraints.

@dragostis dragostis added ⚠ bug framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs labels Aug 5, 2016
@eseidelGoogle
Copy link
Contributor

Presumably this is a race? @abarth does this mean we're doing a build before we know the screen size? FYI @chinmaygarde @jason-simmons

@chinmaygarde
Copy link
Member

Window metrics can be updated at any time. Animations will have to account for the same in any case (not just the initial resize). Can you confirm you are getting window.onMetricsChanged(); at different spots on debug and release?

@chinmaygarde
Copy link
Member

We can reorder initialization to make sure we call main after at least one resize.

@dragostis
Copy link
Contributor Author

I'm trying

  ui.window.onMetricsChanged = () {
    print(ui.window.size);
  };

right before runApp(), but it doesn't print anything, regardless of whether or not I use --release.

@abarth
Copy link
Contributor

abarth commented Aug 5, 2016

The hook only takes one function and the framework is probably overwriting your function. You probably want to put your print in bindings.dart.

@chinmaygarde
Copy link
Member

@abarth, @dragostis: I am not sure where the fix for this lies. Backing up the initial call to main till the first resize on all platforms is convoluted. However, we can change the initial main closure be something else, say, _start. This can then decide when to call main.

@abarth
Copy link
Contributor

abarth commented Aug 8, 2016

IMHO, apps should be robust to being sized 0x0 at startup. If the issue is inconsistency, maybe we should make that happen every time instead of having it be a race.

@dragostis
Copy link
Contributor Author

@abarth Sure, the only issue might be the transition from 0x0 to WxH that the user might not consider. Anyway, this is not really user-facing.

@abarth
Copy link
Contributor

abarth commented Aug 8, 2016

Exactly. We should force developers to consider those cases. Otherwise we'll have to slow down app launch to ensure that the width and height are always available at startup.

@Hixie
Copy link
Contributor

Hixie commented Sep 9, 2016

The complex_layout benchmark triggers this in a way that crashes the framework, fwiw.

@Hixie
Copy link
Contributor

Hixie commented Oct 26, 2016

This also affects --no-hot debug mode.

@Hixie Hixie changed the title Running in release mode pushed zero box constraints. In release mode we start off at 0x0 but we don't in debug mode May 6, 2017
@Hixie
Copy link
Contributor

Hixie commented Nov 14, 2017

Closing this in favour of #6537.

@Hixie Hixie closed this as completed Nov 14, 2017
aam added a commit to aam/flutter that referenced this issue May 17, 2018
Changes since last roll:
```
4374ccc Roll Dart to 43635d3372253262cbf51e55b2ccfceae4f94682. (flutter#5282)
8862465 [fuchsia] Update FIDL include paths. (flutter#5279)
a7b44d4 Only send a11y events if a11y is turned on (flutter#5281)
f218099 Roll src/third_party/skia/ 02faa2b99..94f585ed0 (8 commits) (flutter#5280)
30c649d [fuchsia] Teach engine how to set up an isolate from a list of kernel files. (flutter#5210)
c95d432 Roll src/third_party/skia/ 682c58da4..02faa2b99 (10 commits) (flutter#5277)
bbfe593 Enable flutter service protocol rpcs to run on UI isolate. (flutter#5263)
4dc0183 Roll src/third_party/skia/ 4c2a34e48..682c58da4 (1 commit) (flutter#5276)
ff884db Roll src/third_party/skia/ 5b8b472b3..4c2a34e48 (1 commit) (flutter#5274)
d6f0f2f Roll src/third_party/skia/ c8799aa92..5b8b472b3 (7 commits) (flutter#5273)
d1d5497 Drain any pending work on the IO thread before shutting down the platform view (flutter#5272)
e32e390 Roll Dart to a5c11d7d0329432ca37e35bb249b20f60aa0aa31. (flutter#5269)
db34bb6 Roll buildroot to 78cf6d88d1a8b6f8293649508f2c1db6ad385fb0 for newer GN for Windows. (flutter#5271)
645c15f Roll src/third_party/skia/ 6e9f34f0e..c8799aa92 (13 commits) (flutter#5270)
99b3262 Mark the linux group testonly (flutter#5268)
17a71f6 Build the flutter tester on Linux in the default group. (flutter#5267)
63fdebf Revert "Roll Dart to a5c11d7d0329432ca37e35bb249b20f60aa0aa31. (flutter#5259)" (flutter#5266)
755dbee Roll Dart to a5c11d7d0329432ca37e35bb249b20f60aa0aa31. (flutter#5259)
73a0014 Create an empty group that the Fuchsia bots use to determine the root_out_dir. (flutter#5265)
c7ab033 Support a model where the application creates a FlutterNativeView that is never destroyed (flutter#5256)
e463e80 Roll src/third_party/skia/ 81f60ecd9..6e9f34f0e (7 commits) (flutter#5264)
be6c517 Fix documentation mistake in painting.dart (flutter#5236)
fb303b9 Roll src/third_party/skia/ 6bbd386a0..81f60ecd9 (1 commit) (flutter#5262)
765b7d4 Roll src/third_party/skia/ 3b9effcb1..6bbd386a0 (2 commits) (flutter#5260)
c3c6c36 Create a session presentation backed Vsync waiter on Fuchsia. (flutter#5255)
f943345 Roll src/third_party/skia/ 8803ebb47..3b9effcb1 (8 commits) (flutter#5257)
f12b5a5 Roll src/third_party/skia/ 16ffdd4ed..8803ebb47 (8 commits) (flutter#5254)
cde5014 Roll src/third_party/skia/ 5140f9a8e..16ffdd4ed (4 commits) (flutter#5252)
4a5d8bc Roll src/third_party/skia/ b06a1eb4e..5140f9a8e (1 commit) (flutter#5251)
966ef68 Roll src/third_party/skia/ ec48812c5..b06a1eb4e (1 commit) (flutter#5250)
fb89534 Roll src/third_party/skia/ 96b0b46f2..ec48812c5 (1 commit) (flutter#5249)
5f57c59 Roll src/third_party/skia/ 3202ac4d2..96b0b46f2 (1 commit) (flutter#5248)
```
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: animation Animation APIs framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

5 participants