Skip to content

Layout on the iOS profile and release mode happens with zero max size first and then the actual max size. #149974

@ksokolovskyi

Description

@ksokolovskyi

Steps to reproduce

  1. Run the code sample on an iOS device in debug mode - layout happens once with the actual max size
  2. Run the code sample on an iOS device in profile/release mode - layout happens twice (with zero max size first and then the actual max size)

Expected results

Layout happens once with the actual max size.

Actual results

Layout happens twice: zero max size first and then the actual max size.

Code sample

Code sample 1
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Flow(
      delegate: const MyFlowDelegate(),
      children: const [],
    );
  }
}

class MyFlowDelegate extends FlowDelegate {
  const MyFlowDelegate();

  @override
  Size getSize(BoxConstraints constraints) {
    final maxSize = constraints.biggest;

    print('LAYOUT');
    print('Max width: ${maxSize.width}');
    print('Max height: ${maxSize.height}');

    return constraints.biggest;
  }

  @override
  void paintChildren(FlowPaintingContext context) {}

  @override
  bool shouldRepaint(MyFlowDelegate oldDelegate) {
    return false;
  }
}
Code sample 2
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        final maxSize = constraints.biggest;

        print('LAYOUT');
        print('Max width: ${maxSize.width}');
        print('Max height: ${maxSize.height}');

        return const SizedBox.shrink();
      },
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

iOS debug logs
Launching lib/main.dart on Kostiantyn’s iPhone in debug mode...
Xcode build done.                                            8.0s
flutter: LAYOUT
flutter: Max width: 375.0
flutter: Max height: 812.0
iOS profile logs
Launching lib/main.dart on Kostiantyn’s iPhone in profile mode...
Xcode build done.                                           10.6s
flutter: LAYOUT
flutter: Max width: 0.0
flutter: Max height: 0.0
flutter: LAYOUT
flutter: Max width: 375.0
flutter: Max height: 812.0
iOS release logs
Launching lib/main.dart on Kostiantyn’s iPhone in release mode...
Xcode build done.                                           11.2s
flutter: LAYOUT
flutter: Max width: 0.0
flutter: Max height: 0.0
flutter: LAYOUT
flutter: Max width: 375.0
flutter: Max height: 812.0
Android debug logs
Launching lib/main.dart on SM A305FN in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Connecting to VM Service at ws://127.0.0.1:53486/QKI8BVXu2KA=/ws
I/flutter (21798): LAYOUT
I/flutter (21798): Max width: 411.42857142857144
I/flutter (21798): Max height: 843.4285714285714
Android release logs
Launching lib/main.dart on SM A305FN in release mode...
✓ Built build/app/outputs/flutter-apk/app-release.apk (6.5MB)
I/flutter (21797): LAYOUT
I/flutter (21797): Max width: 411.42857142857144
I/flutter (21797): Max height: 843.4285714285714
macOS debug logs
Launching lib/main.dart on macOS in debug mode...
✓ Built build/macos/Build/Products/Debug/ios_layout_bug.app
flutter: LAYOUT
flutter: Max width: 800.0
flutter: Max height: 600.0
macOS release logs
Launching lib/main.dart on macOS in release mode...
✓ Built build/macos/Build/Products/Release/ios_layout_bug.app (44.0MB)
flutter: LAYOUT
flutter: Max width: 800.0
flutter: Max height: 600.0

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.1 23B2073 darwin-arm64, locale en-US)
    • Flutter version 3.22.2 on channel stable at /Users/ksokolovskyi/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (4 days ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/ksokolovskyi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/ksokolovskyi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.90.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

Metadata

Metadata

Assignees

Labels

a: layoutSystemChrome and Framework's Layout Issuesfound in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: solvedIssue is closed as solvedteam-iosOwned by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions