Skip to content

Exception: RenderViewport exceeded its maximum number of layout cycles #23527

Closed

Description

@scottdewald

I have an application that has horizontally scrollable tiles within a vertically scrollable list. These tiles are dynamically sized based on the screen size. It works well, but I noticed that on the iPhone 6s the tile sizes were calculated to be Size(104.1935483870967687, 156.2903225806451530). For some reason, this exact size caused the render exception below to be thrown. All other tile sizes I tried worked fine. Here is a pic of the sample app below which will reproduce the error on an iPhone 6s simulator.

https://imgur.com/a/QNRx4Lz

Steps to Reproduce

Run this sample application on the iPhone 6s simulator to see the render exception. Note, the tiles are normally dynamically sized, but I noticed that the exact size of (104.1935483870967687, 156.2903225806451530) was causing the exception so I have the sizes hardcode for now. Scroll the screen up and down to see the exception.

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: 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> {
  int _tabIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: (_tabIndex == 0) ? _createHomePage(context) : Container(),
    );
  }

  Widget _createHomePage(BuildContext context) {
    return ListView(
      children: List.generate(100, (index) => _createRow(context, index))
    );
  }

  Widget _createRow(BuildContext context, int rowIndex) {
    if (rowIndex % 3 == 0 || rowIndex % 3 == 1)
      return SizedBox(height: 24.0);

    // NOTE: the real code would call calculateTileSize(screenWidth) which returned the values below
    var screenWidth = MediaQuery.of(context).size.width;
    var tileSize = Size(104.1935483870967687, 156.2903225806451530);   // calculateTileSize(screenWidth);

    return Column(
      children: <Widget>[
        SizedBox(height: 16.0),
        Text("Row $rowIndex"),
        SizedBox(height: 4.0),
        SizedBox(
          width: screenWidth,
          height: tileSize.height,
          child: ListView(
            key: PageStorageKey<String>("RowKey$rowIndex"),
            scrollDirection: Axis.horizontal,
            children: List.generate(100, (tileIndex) => _createTile(context, rowIndex, tileIndex, tileSize)),
          ),
        )
      ],
    );
  }

  Widget _createTile(BuildContext context, int rowIndex, int tileIndex, Size tileSize) {
    return Padding(
      padding: const EdgeInsets.only(right: 8.0),
      child: Container(
        color: _getTileColor(rowIndex, tileIndex),
        child: SizedBox(
          width: tileSize.width,
          height: tileSize.height,
        ),
      ),
    );
  }

  Color _getTileColor(int rowIndex, int tileIndex) {
    var index = (rowIndex * 5 + tileIndex) % Colors.accents.length;
    return Colors.accents[index];
  }
}

Logs

[  +30 ms] executing: [/Users/scottdewald/Tools/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +32 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] executing: [/Users/scottdewald/Tools/flutter/] git rev-parse --abbrev-ref HEAD
[   +9 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[        ] executing: [/Users/scottdewald/Tools/flutter/] git ls-remote --get-url origin
[  +10 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] executing: [/Users/scottdewald/Tools/flutter/] git log -n 1 --pretty=format:%H
[  +14 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] f37c235c32fc15babe6dc7b7bc2ee4387e5ecf92
[        ] executing: [/Users/scottdewald/Tools/flutter/] git log -n 1 --pretty=format:%ar
[  +11 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 4 weeks ago
[        ] executing: [/Users/scottdewald/Tools/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +14 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v0.9.4-0-gf37c235c3
[ +279 ms] executing: /Users/scottdewald/Library/Android/sdk/platform-tools/adb devices -l
[   +8 ms] Exit code 0 from: /Users/scottdewald/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[   +4 ms] executing: idevice_id -h
[  +38 ms] /usr/bin/xcrun simctl list --json devices
[+1002 ms] Launching lib/main.dart on iPhone 6s in debug mode...
[  +10 ms] executing: /usr/bin/defaults read /Users/scottdewald/Programming/FlutterTest2/flutter_test_2/ios/Runner/Info CFBundleIdentifier
[ +141 ms] Exit code 0 from: /usr/bin/defaults read /Users/scottdewald/Programming/FlutterTest2/flutter_test_2/ios/Runner/Info CFBundleIdentifier
[        ] $(PRODUCT_BUNDLE_IDENTIFIER)
[  +11 ms] Building Runner.app for 6761ACC4-D0CD-474F-A6BA-C13BC11C8482.
[   +7 ms] executing: script /dev/null /usr/bin/log stream --style syslog --predicate processImagePath CONTAINS "6761ACC4-D0CD-474F-A6BA-C13BC11C8482"
[  +27 ms] [DEVICE LOG] Filtering the log data using "processImagePath CONTAINS "6761ACC4-D0CD-474F-A6BA-C13BC11C8482""
[   +4 ms] [DEVICE LOG] Timestamp                       (process)[PID]    
[ +123 ms] /Users/scottdewald/Tools/flutter/bin/cache/dart-sdk/bin/dart /Users/scottdewald/Tools/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root /Users/scottdewald/Tools/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --strong --target=flutter --no-link-platform --incremental --packages /Users/scottdewald/Programming/FlutterTest2/flutter_test_2/.packages --output-dill build/app.dill --depfile build/snapshot_blob.bin.d /Users/scottdewald/Programming/FlutterTest2/flutter_test_2/lib/main.dart
[+1476 ms] Building bundle
[        ] Writing asset files to build/flutter_assets
[  +41 ms] Wrote build/flutter_assets
[   +1 ms] executing: /usr/bin/xcrun simctl get_app_container 6761ACC4-D0CD-474F-A6BA-C13BC11C8482 com.example.flutterTest2
[        ] executing: /usr/bin/killall Runner
[ +203 ms] executing: /usr/bin/xcrun simctl launch 6761ACC4-D0CD-474F-A6BA-C13BC11C8482 com.example.flutterTest2 --enable-dart-profiling --enable-checked-mode --observatory-port=0
[ +217 ms] com.example.flutterTest2: 13612
[        ] Waiting for observatory port to be available...
[ +264 ms] [DEVICE LOG] 2018-10-25 14:46:49.978355-0500  localhost Runner[13612]: (QuartzCore) [com.apple.coreanimation:WindowServer] Initialized 2 displays
[  +12 ms] [DEVICE LOG] 2018-10-25 14:46:49.991233-0500  localhost Runner[13612]: (libMobileGestalt.dylib) libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
[        ] [DEVICE LOG] 2018-10-25 14:46:49.991289-0500  localhost Runner[13612]: (libMobileGestalt.dylib) MGIsDeviceOneOfType is not supported on this platform.
[        ] [DEVICE LOG] 2018-10-25 14:46:49.992149-0500  localhost Runner[13612]: (libAccessibility.dylib) [com.apple.Accessibility:AccessibilitySupport] Retrieving resting unlock: 0
[  +56 ms] [DEVICE LOG] 2018-10-25 14:46:50.048823-0500  localhost Runner[13612]: (UIKitCore) You've implemented -[<UIApplicationDelegate> application:performFetchWithCompletionHandler:], but you still need to add "fetch" to the list of your supported UIBackgroundModes in your Info.plist.
[        ] [DEVICE LOG] 2018-10-25 14:46:50.048961-0500  localhost Runner[13612]: (UIKitCore) You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
[  +62 ms] [DEVICE LOG] 2018-10-25 14:46:50.111898-0500  localhost Runner[13612]: (Flutter) flutter: Observatory listening on http://127.0.0.1:58557/
[   +3 ms] Observatory URL on device: http://127.0.0.1:58557/
[   +3 ms] Connecting to service protocol: http://127.0.0.1:58557/
[ +131 ms] Successfully connected to service protocol: http://127.0.0.1:58557/
[   +2 ms] getVM: {}
[   +9 ms] getIsolate: {isolateId: isolates/487795111}
[   +4 ms] _flutter.listViews: {isolateId: isolates/487795111}
[  +37 ms] DevFS: Creating new filesystem on the device (null)
[        ] _createDevFS: {fsName: flutter_test_2}
[  +21 ms] DevFS: Created new filesystem on the device (file:///Users/scottdewald/Library/Developer/CoreSimulator/Devices/6761ACC4-D0CD-474F-A6BA-C13BC11C8482/data/Containers/Data/Application/4A8502F4-32FC-4AAB-876B-08511B6E5886/tmp/flutter_test_2sqYo1u/flutter_test_2/)
[   +1 ms] Updating assets
[ +161 ms] Syncing files to device iPhone 6s...
[   +2 ms] DevFS: Starting sync from LocalDirectory: '/Users/scottdewald/Programming/FlutterTest2/flutter_test_2'
[        ] Scanning project files
[   +6 ms] Scanning package files
[  +91 ms] Scanning asset files
[        ] Scanning for deleted files
[   +8 ms] Compiling dart to kernel with 436 updated files
[   +4 ms] /Users/scottdewald/Tools/flutter/bin/cache/dart-sdk/bin/dart /Users/scottdewald/Tools/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root /Users/scottdewald/Tools/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --strong --target=flutter --output-dill build/app.dill --packages /Users/scottdewald/Programming/FlutterTest2/flutter_test_2/.packages --filesystem-scheme org-dartlang-root
[+1119 ms] Updating files
[  +56 ms] DevFS: Sync finished
[        ] Syncing files to device iPhone 6s... (completed)
[        ] Synced 0.8MB.
[   +1 ms] _flutter.listViews: {isolateId: isolates/487795111}
[   +6 ms] Connected to _flutterView/0x7ffd7bf07be8.
[   +1 ms] 🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[        ] An Observatory debugger and profiler on iPhone 6s is available at: http://127.0.0.1:58557/
[        ] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
[+5492 ms] [DEVICE LOG] 2018-10-25 14:46:57.280789-0500  localhost Runner[13612]: (Flutter) flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
[   +7 ms] flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
[        ] [DEVICE LOG] 2018-10-25 14:46:57.287736-0500  localhost Runner[13612]: (Flutter) flutter: The following assertion was thrown during performLayout():
[        ] [DEVICE LOG] 2018-10-25 14:46:57.287823-0500  localhost Runner[13612]: (Flutter) flutter: A RenderViewport exceeded its maximum number of layout cycles.
[        ] [DEVICE LOG] 2018-10-25 14:46:57.287909-0500  localhost Runner[13612]: (Flutter) flutter: RenderViewport render objects, during layout, can retry if either their slivers or their
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288009-0500  localhost Runner[13612]: (Flutter) flutter: ViewportOffset decide that the offset should be corrected to take into account information collected
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288099-0500  localhost Runner[13612]: (Flutter) flutter: during that layout.
[        ] flutter: The following assertion was thrown during performLayout():
[        ] flutter: A RenderViewport exceeded its maximum number of layout cycles.
[        ] flutter: RenderViewport render objects, during layout, can retry if either their slivers or their
[        ] flutter: ViewportOffset decide that the offset should be corrected to take into account information collected
[        ] flutter: during that layout.
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288169-0500  localhost Runner[13612]: (Flutter) flutter: In the case of this RenderViewport object, however, this happened 10 times and still there was no
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288249-0500  localhost Runner[13612]: (Flutter) flutter: consensus on the scroll offset. This usually indicates a bug. Specifically, it means that one of the
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288347-0500  localhost Runner[13612]: (Flutter) flutter: following three problems is being experienced by the RenderViewport object:
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288427-0500  localhost Runner[13612]: (Flutter) flutter:  * One of the RenderSliver children or the ViewportOffset have a bug such that they always think
[        ] flutter: In the case of this RenderViewport object, however, this happened 10 times and still there was no
[        ] flutter: consensus on the scroll offset. This usually indicates a bug. Specifically, it means that one of the
[        ] flutter: following three problems is being experienced by the RenderViewport object:
[        ] flutter:  * One of the RenderSliver children or the ViewportOffset have a bug such that they always think
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288512-0500  localhost Runner[13612]: (Flutter) flutter:    that they need to correct the offset regardless.
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288621-0500  localhost Runner[13612]: (Flutter) flutter:  * Some combination of the RenderSliver children and the ViewportOffset have a bad interaction such
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288713-0500  localhost Runner[13612]: (Flutter) flutter:    that one applies a correction then another applies a reverse correction, leading to an infinite
[        ] [DEVICE LOG] 2018-10-25 14:46:57.288998-0500  localhost Runner[13612]: (Flutter) flutter:    loop of corrections.
[        ] [DEVICE LOG] 2018-10-25 14:46:57.289109-0500  localhost Runner[13612]: (Flutter) flutter:  * There is a pathological case that would eventually resolve, but it is so complicated that it
[        ] [DEVICE LOG] 2018-10-25 14:46:57.289379-0500  localhost Runner[13612]: (Flutter) flutter:    cannot be resolved in any reasonable number of layout passes.
[        ] [DEVICE LOG] 2018-10-25 14:46:57.290086-0500  localhost Runner[13612]: (Flutter) flutter:
[        ] flutter:    that they need to correct the offset regardless.
[        ] flutter:  * Some combination of the RenderSliver children and the ViewportOffset have a bad interaction such
[        ] flutter:    that one applies a correction then another applies a reverse correction, leading to an infinite
[        ] flutter:    loop of corrections.
[        ] flutter:  * There is a pathological case that would eventually resolve, but it is so complicated that it
[        ] flutter:    cannot be resolved in any reasonable number of layout passes.
[        ] flutter:
[        ] [DEVICE LOG] 2018-10-25 14:46:57.290177-0500  localhost Runner[13612]: (Flutter) flutter: When the exception was thrown, this was the stack:
[        ] flutter: When the exception was thrown, this was the stack:
[   +1 ms] [DEVICE LOG] 2018-10-25 14:46:57.293689-0500  localhost Runner[13612]: (Flutter) flutter: #0      RenderViewport.performLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1253:9)
[        ] flutter: #0      RenderViewport.performLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1253:9)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.293855-0500  localhost Runner[13612]: (Flutter) flutter: #1      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1273:6)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.293968-0500  localhost Runner[13612]: (Flutter) flutter: #2      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1506:7)
[        ] flutter: #1      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1273:6)
[        ] flutter: #2      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1506:7)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294094-0500  localhost Runner[13612]: (Flutter) flutter: #3      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:765:18)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294224-0500  localhost Runner[13612]: (Flutter) flutter: #4      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
[        ] flutter: #3      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:765:18)
[        ] flutter: #4      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294342-0500  localhost Runner[13612]: (Flutter) flutter: #5      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:674:13)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294466-0500  localhost Runner[13612]: (Flutter) flutter: #6      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
[        ] flutter: #5      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:674:13)
[        ] flutter: #6      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294588-0500  localhost Runner[13612]: (Flutter) flutter: #7      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294744-0500  localhost Runner[13612]: (Flutter) flutter: #8      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294859-0500  localhost Runner[13612]: (Flutter) flutter: #9      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
[        ] flutter: #7      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
[        ] flutter: #8      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
[        ] flutter: #9      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.294981-0500  localhost Runner[13612]: (Flutter) flutter: #10     _invoke (dart:ui/hooks.dart:139:13)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.295098-0500  localhost Runner[13612]: (Flutter) flutter: #11     _drawFrame (dart:ui/hooks.dart:128:3)
[        ] flutter: #10     _invoke (dart:ui/hooks.dart:139:13)
[        ] flutter: #11     _drawFrame (dart:ui/hooks.dart:128:3)
[   +6 ms] [DEVICE LOG] 2018-10-25 14:46:57.303394-0500  localhost Runner[13612]: (Flutter) flutter:
[        ] flutter:
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303466-0500  localhost Runner[13612]: (Flutter) flutter: The following RenderObject was being processed when the exception was fired:
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303520-0500  localhost Runner[13612]: (Flutter) flutter:   RenderViewport#51a50 NEEDS-LAYOUT NEEDS-PAINT
[        ] flutter: The following RenderObject was being processed when the exception was fired:
[        ] flutter:   RenderViewport#51a50 NEEDS-LAYOUT NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303586-0500  localhost Runner[13612]: (Flutter) flutter:   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#1ac85] ← Semantics ← Listener ←
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303670-0500  localhost Runner[13612]: (Flutter) flutter:   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fd452] ←
[        ] flutter:   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#1ac85] ← Semantics ← Listener ←
[        ] flutter:   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#fd452] ←
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303743-0500  localhost Runner[13612]: (Flutter) flutter:   _ScrollSemantics-[GlobalKey#83949] ← Scrollable ← PrimaryScrollController ← ListView ← MediaQuery
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303808-0500  localhost Runner[13612]: (Flutter) flutter:   ← ⋯
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303886-0500  localhost Runner[13612]: (Flutter) flutter:   parentData: <none> (can use size)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.303970-0500  localhost Runner[13612]: (Flutter) flutter:   constraints: BoxConstraints(0.0<=w<=375.0, 0.0<=h<=667.0)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.304055-0500  localhost Runner[13612]: (Flutter) flutter:   layer: OffsetLayer#c85aa
[        ] flutter:   _ScrollSemantics-[GlobalKey#83949] ← Scrollable ← PrimaryScrollController ← ListView ← MediaQuery
[        ] flutter:   ← ⋯
[        ] flutter:   parentData: <none> (can use size)
[        ] flutter:   constraints: BoxConstraints(0.0<=w<=375.0, 0.0<=h<=667.0)
[        ] flutter:   layer: OffsetLayer#c85aa
[        ] [DEVICE LOG] 2018-10-25 14:46:57.304131-0500  localhost Runner[13612]: (Flutter) flutter:   size: Size(375.0, 667.0)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.304216-0500  localhost Runner[13612]: (Flutter) flutter:   axisDirection: down
[        ] [DEVICE LOG] 2018-10-25 14:46:57.304420-0500  localhost Runner[13612]: (Flutter) flutter:   crossAxisDirection: right
[        ] [DEVICE LOG] 2018-10-25 14:46:57.304786-0500  localhost Runner[13612]: (Flutter) flutter:   offset: ScrollPositionWithSingleContext#0e979(offset: 270.2, range: 0.0..7738.6, viewport: 667.0,
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305005-0500  localhost Runner[13612]: (Flutter) flutter:   ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305168-0500  localhost Runner[13612]: (Flutter) flutter:   BallisticScrollActivity#3fb6e(AnimationController#4a359(▶ 270.207; for BallisticScrollActivity)),
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305375-0500  localhost Runner[13612]: (Flutter) flutter:   ScrollDirection.forward)
[        ] flutter:   size: Size(375.0, 667.0)
[        ] flutter:   axisDirection: down
[        ] flutter:   crossAxisDirection: right
[        ] flutter:   offset: ScrollPositionWithSingleContext#0e979(offset: 270.2, range: 0.0..7738.6, viewport: 667.0,
[        ] flutter:   ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
[        ] flutter:   BallisticScrollActivity#3fb6e(AnimationController#4a359(▶ 270.207; for BallisticScrollActivity)),
[        ] flutter:   ScrollDirection.forward)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305463-0500  localhost Runner[13612]: (Flutter) flutter:   anchor: 0.0
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305608-0500  localhost Runner[13612]: (Flutter) flutter: This RenderObject had the following descendants (showing up to depth 5):
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305785-0500  localhost Runner[13612]: (Flutter) flutter:   RenderSliverPadding#0b812 relayoutBoundary=up1 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.305909-0500  localhost Runner[13612]: (Flutter) flutter:     RenderSliverList#e6967 relayoutBoundary=up2 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.306068-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#8a47c relayoutBoundary=up3 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.306192-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#467ee relayoutBoundary=up4 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.306363-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#bca97 relayoutBoundary=up3 NEEDS-PAINT
[        ] flutter:   anchor: 0.0
[        ] flutter: This RenderObject had the following descendants (showing up to depth 5):
[        ] flutter:   RenderSliverPadding#0b812 relayoutBoundary=up1 NEEDS-PAINT
[        ] flutter:     RenderSliverList#e6967 relayoutBoundary=up2 NEEDS-PAINT
[        ] flutter:       RenderRepaintBoundary#8a47c relayoutBoundary=up3 NEEDS-PAINT
[        ] flutter:         RenderConstrainedBox#467ee relayoutBoundary=up4 NEEDS-PAINT
[        ] flutter:       RenderRepaintBoundary#bca97 relayoutBoundary=up3 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307227-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#f871a relayoutBoundary=up4 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307326-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#2a880 relayoutBoundary=up3 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307410-0500  localhost Runner[13612]: (Flutter) flutter:         RenderFlex#daa20 relayoutBoundary=up4 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307498-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#4903a relayoutBoundary=up5 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307591-0500  localhost Runner[13612]: (Flutter) flutter:           RenderParagraph#be4e9 relayoutBoundary=up5 NEEDS-PAINT
[        ] flutter:         RenderConstrainedBox#f871a relayoutBoundary=up4 NEEDS-PAINT
[        ] flutter:       RenderRepaintBoundary#2a880 relayoutBoundary=up3 NEEDS-PAINT
[        ] flutter:         RenderFlex#daa20 relayoutBoundary=up4 NEEDS-PAINT
[        ] flutter:           RenderConstrainedBox#4903a relayoutBoundary=up5 NEEDS-PAINT
[        ] flutter:           RenderParagraph#be4e9 relayoutBoundary=up5 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307675-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#168ed relayoutBoundary=up5 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307810-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#960a8 relayoutBoundary=up5 NEEDS-PAINT
[        ] [DEVICE LOG] 2018-10-25 14:46:57.307995-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#f697f relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.308139-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#b508d relayoutBoundary=up4
[        ] flutter:           RenderConstrainedBox#168ed relayoutBoundary=up5 NEEDS-PAINT
[        ] flutter:           RenderConstrainedBox#960a8 relayoutBoundary=up5 NEEDS-PAINT
[        ] flutter:       RenderRepaintBoundary#f697f relayoutBoundary=up3
[        ] flutter:         RenderConstrainedBox#b508d relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.308420-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#d737f relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.308639-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#369b6 relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.309010-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#e167c relayoutBoundary=up3
[        ] flutter:       RenderRepaintBoundary#d737f relayoutBoundary=up3
[        ] flutter:         RenderConstrainedBox#369b6 relayoutBoundary=up4
[        ] flutter:       RenderRepaintBoundary#e167c relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.309243-0500  localhost Runner[13612]: (Flutter) flutter:         RenderFlex#f46ea relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.309463-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#9bf29 relayoutBoundary=up5
[        ] [DEVICE LOG] 2018-10-25 14:46:57.309661-0500  localhost Runner[13612]: (Flutter) flutter:           RenderParagraph#4559e relayoutBoundary=up5
[        ] flutter:         RenderFlex#f46ea relayoutBoundary=up4
[        ] flutter:           RenderConstrainedBox#9bf29 relayoutBoundary=up5
[        ] flutter:           RenderParagraph#4559e relayoutBoundary=up5
[        ] [DEVICE LOG] 2018-10-25 14:46:57.309955-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#74612 relayoutBoundary=up5
[        ] [DEVICE LOG] 2018-10-25 14:46:57.310244-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#d8b8b relayoutBoundary=up5
[        ] [DEVICE LOG] 2018-10-25 14:46:57.310565-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#c21b0 relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.310771-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#3051d relayoutBoundary=up4
[        ] flutter:           RenderConstrainedBox#74612 relayoutBoundary=up5
[        ] flutter:           RenderConstrainedBox#d8b8b relayoutBoundary=up5
[        ] flutter:       RenderRepaintBoundary#c21b0 relayoutBoundary=up3
[        ] flutter:         RenderConstrainedBox#3051d relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.310922-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#8b55f relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311068-0500  localhost Runner[13612]: (Flutter) flutter:         RenderConstrainedBox#1ccc8 relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311225-0500  localhost Runner[13612]: (Flutter) flutter:       RenderRepaintBoundary#a8c53 relayoutBoundary=up3
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311393-0500  localhost Runner[13612]: (Flutter) flutter:         RenderFlex#9bd17 relayoutBoundary=up4
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311525-0500  localhost Runner[13612]: (Flutter) flutter:           RenderConstrainedBox#482bf relayoutBoundary=up5
[        ] flutter:       RenderRepaintBoundary#8b55f relayoutBoundary=up3
[        ] flutter:         RenderConstrainedBox#1ccc8 relayoutBoundary=up4
[        ] flutter:       RenderRepaintBoundary#a8c53 relayoutBoundary=up3
[        ] flutter:         RenderFlex#9bd17 relayoutBoundary=up4
[        ] flutter:           RenderConstrainedBox#482bf relayoutBoundary=up5
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311685-0500  localhost Runner[13612]: (Flutter) flutter:   ...(descendants list truncated after 25 lines)
[        ] [DEVICE LOG] 2018-10-25 14:46:57.311878-0500  localhost Runner[13612]: (Flutter) flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
[        ] flutter:   ...(descendants list truncated after 25 lines)
[        ] flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
Analyzing flutter_test_2...                                      
No issues found! (ran in 1.3s)
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.13.6 17G2307, locale en-US)
    • Flutter version 0.9.4 at /Users/scottdewald/Tools/flutter
    • Framework revision f37c235c32 (4 weeks ago), 2018-09-25 17:45:40 -0400
    • Engine revision 74625aed32
    • Dart version 2.1.0-dev.5.0.flutter-a2eb050044

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/scottdewald/Library/Android/sdk
    • Android NDK at /Users/scottdewald/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Community Edition (version 2018.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 29.1.3
    • Dart plugin version 182.4999

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

[✓] Connected devices (1 available)
    • iPhone 6s • 6761ACC4-D0CD-474F-A6BA-C13BC11C8482 • ios • iOS 12.0 (simulator)

• No issues found!

Activity

  1. added
    c: crashStack traces logged to the console
    platform-iosiOS applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    engineflutter/engine related. See also e: labels.
    on Oct 27, 2018
  2. added this to the milestone on Oct 27, 2018
  3. added
    f: scrollingViewports, list views, slivers, etc.
    and removed
    engineflutter/engine related. See also e: labels.
    on Nov 10, 2018
  4. idealopamp commented on Nov 23, 2018

    @idealopamp

    This looks like it could be the same root cause as an issue I filed in #19245 , although in 19245 I have seen this on Android emulators as well as my Pixel 3 XL. At least in 19245, there is an infinite loop in RenderShrinkWrappingViewport.performLayout stemming from floating point precision issues using a scrollOffsetCorrection computed in RenderSliverList.performLayout. One superficial difference compared to 19245 is that RenderShrinkWrappingViewport doesn't have a limit on the number of iterations, so it just goes in an infinite loop instead of throwing an exception.

    If your issue is in fact the same root cause, it would make sense that you could see this issue for only one specific widget size because the bug is sensitive to the specific numerical values for the pixels and pixel offsets. RenderViewport mentions some other scenarios that could cause this exception to be raised, but it could also be the floating point precision issue, which I described with a bit more detail in #19245 (comment) .

  5. lidemin commented on Jan 15, 2019

    @lidemin

    I have met similar issue when I was using iPhone X, but it can not be reproduced on Android devices or other iPhone models.

  6. vejmartin commented on Feb 2, 2019

    @vejmartin

    Stumbled across this issue while running a SliverList with a SliverAppBar on Android.
    Adding an epsilon comparison in sliver_list.dart where firstChildScrollOffset < 0.0 resolved it for me.
    Replace:

    final double firstChildScrollOffset = earliestScrollOffset - paintExtentOf(firstChild);
    if (firstChildScrollOffset < 0.0) {

    with:

    doubleCmp(double lhs, double rhs){
      return ((lhs - rhs).abs() < 10e-6 ? 0 : lhs.compareTo(rhs));
    }
    
    final double firstChildScrollOffset = earliestScrollOffset - paintExtentOf(firstChild);
    if (doubleCmp(firstChildScrollOffset, 0.0) < 0) {
  7. smiLLe commented on Feb 26, 2019

    @smiLLe

    Same for me, on android emu and iPhone emu

    [✓] Flutter (Channel dev, v1.2.2, on Mac OS X 10.13.6 17G3025, locale en-DE)
        • Flutter version 1.2.2 at /Users/../Documents/flutter
        • Framework revision 007a415c2a (4 days ago), 2019-02-21 20:22:47 -0800
        • Engine revision f1f19bba8f
        • Dart version 2.2.0 (build 2.2.0-dev.2.1 c92d5ca288)
    

    Error:

    _flutter: Another exception was thrown: A RenderViewport exceeded its maximum number of layout cycles._
    

    This happens in a CustomScrollView.

  8. zoechi commented on Feb 26, 2019

    @zoechi
    Contributor

    @smiLLe can you please provide a minimal reproduction of your case?

  9. smiLLe commented on Mar 6, 2019

    @smiLLe

    @zoechi It happens randomly in a complex sliver list in my project. But it does only happen when i scroll to the top and reach the top of the list (The blue overscroll half circle appears).

    My layout looks like this:

    Scaffold(
      appBar: MyAppBar(),
      drawer: MyAppDrawer(),
      child: CustomScrollView(slivers: [
        SliverList(), // SliverChildBuilderDelegate
        SliverList(), // SliverChildBuilderDelegate
      ],),
    );

    I will try to create a similar layout in a new project that i can share with you

  10. shafqatu commented on Mar 17, 2019

    @shafqatu

    I have the same problem too, I am testing the same app on both android and iOS, on IOS I am getting this error "A RenderViewport exceeded its maximum number of layout cycles." on on simulator and real physical device.

  11. bondanherumurti commented on Mar 18, 2019

    @bondanherumurti

    It also happened in my listview

          children: <Widget>[
            new Image(
              image: AssetImage('assets/banner.png'),
              fit: BoxFit.scaleDown,
            ),
            new Padding(padding: new EdgeInsets.only(top: 20.0)),
            new Container(
              height: 150.0,
              child: new ListView(
                padding: new EdgeInsets.only(left: 2.0),
                scrollDirection: Axis.horizontal,
                children: <Widget>[
                  Container(
                    decoration: new BoxDecoration(
                      color: const Color(0xFFaf5875),
                      borderRadius: new BorderRadius.all(Radius.circular(10.0))
                    ),
                    width: 150.0,
                    margin: EdgeInsets.symmetric(horizontal: 10.0),
                    child: new Column(
                      mainAxisSize: MainAxisSize.max,
                      children: <Widget>[
                        new Container(
                          padding: EdgeInsets.only(top: 30.0, bottom: 20.0),
                          child: new Center(
                              child: new Icon(BelsbeeIcon.iconfinder_7_463427, size: 60.0, color: Colors.white,)
                          ),
                        ),
                        new Text("CHOOSE A DRESS", style: TextStyle(fontFamily: 'Montserrat Medium', fontSize: 14.0, color: Colors.white70))
                      ],
                    )
                  ),
                  Container(
                      decoration: new BoxDecoration(
                          color: const Color(0xFFaf5875),
                          borderRadius: new BorderRadius.all(Radius.circular(10.0))
                      ),
                      width: 150.0,
                      margin: EdgeInsets.symmetric(horizontal: 10.0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                            padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
                            child: new Center(
                                child: new Icon(BelsbeeIcon.iconfinder_prince_princess_crown_queen_999767, size: 70.0, color: Colors.white,)
                            ),
                          ),
                          new Text("BE A QUEEN", style: TextStyle(fontFamily: 'Montserrat Medium', fontSize: 14.0, color: Colors.white70))
                        ],
                      )
                  ),
                  Container(
                      decoration: new BoxDecoration(
                          color: const Color(0xFFaf5875),
                          borderRadius: new BorderRadius.all(Radius.circular(10.0))
                      ),
                      width: 150.0,
                      margin: EdgeInsets.symmetric(horizontal: 10.0),
                      child: new Column(
                        children: <Widget>[
                          new Container(
                            padding: EdgeInsets.only(top: 30.0, bottom: 20.0),
                            child: new Center(
                                child: new Icon(BelsbeeIcon.iconfinder_logistic_shipping_vehicles_002_2563595, size: 50.0, color: Colors.white,)
                            ),
                          ),
                          new Text("EASY DELIVERY & RETURN", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat Medium', fontSize: 14.0, color: Colors.white70))
                        ],
                      )
                  ),
                ],
              ),
            ),
            new Padding(padding: new EdgeInsets.only(top: 20.0)),
            new Container(
              child: new Column(
                children: <Widget>[
                  new Container(
                    decoration: new BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(5.0)),
                      color: Colors.yellow,
                      image: DecorationImage(
                          image: new AssetImage("assets/promo-1.jpg"),
                          fit: BoxFit.cover
                      )
                    ),
                    margin: EdgeInsets.symmetric(horizontal: 10.0),
                    height: 100.0
                  ),
                  new Padding(padding: new EdgeInsets.only(top: 10.0)),
                  new Container(
                    margin: EdgeInsets.symmetric(horizontal: 10.0),
                    height: 100.0,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(5.0)),
                        image: new DecorationImage(
                          image: new AssetImage("assets/most-popular.jpg"),
                          fit: BoxFit.cover)
                    ),
                  ),
                  new Padding(padding: new EdgeInsets.only(top: 10.0))
                ],
              )
            ),
            new Container(
              padding: new EdgeInsets.symmetric(horizontal: 10.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  new Column(
                    children: <Widget>[
                      new Container(
                        margin: EdgeInsets.only(bottom: 10.0),
                        height: 200.0,
                        width: (width/2) - 15.0,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            color: Colors.yellow
                        ),
                      )
                    ],
                  ),
                  new Column(
                    mainAxisSize: MainAxisSize.max,
                    children: <Widget>[
                      new Container(
                        margin: EdgeInsets.only(bottom: 10.0),
                        height: 100.0,
                        width: (width/2) - 15.0,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            color: Colors.yellow
                        ),
                      ),
                      new Container(
                        height: 300.0,
                        width: (width/2) - 15.0,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            color: Colors.yellow
                        ),
                      )
                    ],
                  )
                ],
              ),
            ),
            new Container(
              height: 200.0,
              decoration: new BoxDecoration(
                color: Colors.yellow,
              ),
            )
          ],
        );
    

    and this is the error generated whenever i reach bottom and scrolled to the top

    flutter: The following assertion was thrown during performLayout():
    flutter: A RenderViewport exceeded its maximum number of layout cycles.
    flutter: RenderViewport render objects, during layout, can retry if either their slivers or their
    flutter: ViewportOffset decide that the offset should be corrected to take into account information collected
    flutter: during that layout.
    flutter: In the case of this RenderViewport object, however, this happened 10 times and still there was no
    flutter: consensus on the scroll offset. This usually indicates a bug. Specifically, it means that one of the
    flutter: following three problems is being experienced by the RenderViewport object:
    flutter:  * One of the RenderSliver children or the ViewportOffset have a bug such that they always think
    flutter:    that they need to correct the offset regardless.
    flutter:  * Some combination of the RenderSliver children and the ViewportOffset have a bad interaction such
    flutter:    that one applies a correction then another applies a reverse correction, leading to an infinite
    flutter:    loop of corrections.
    flutter:  * There is a pathological case that would eventually resolve, but it is so complicated that it
    flutter:    cannot be resolved in any reasonable number of layout passes.
    flutter:
    flutter: When the exception was thrown, this was the stack:
    flutter: #0      RenderViewport.performLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1253:9)
    flutter: #1      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1273:6)
    flutter: #2      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1506:7)
    flutter: #3      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:765:18)
    flutter: #4      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
    flutter: #5      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:674:13)
    flutter: #6      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
    flutter: #7      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
    flutter: #8      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
    flutter: #9      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
    flutter: #10     _invoke (dart:ui/hooks.dart:139:13)
    flutter: #11     _drawFrame (dart:ui/hooks.dart:128:3)
    flutter:
    flutter: The following RenderObject was being processed when the exception was fired:
    flutter:   RenderViewport#34495 NEEDS-LAYOUT NEEDS-PAINT
    flutter:   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#3043a] ← Semantics ← Listener ←
    flutter:   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#01316] ←
    flutter:   _ScrollSemantics-[GlobalKey#c3fff] ← Scrollable ← PrimaryScrollController ← ListView ←
    flutter:   AnotherScreen ← ⋯
    flutter:   parentData: <none> (can use size)
    flutter:   constraints: BoxConstraints(0.0<=w<=320.0, 0.0<=h<=435.0)
    flutter:   layer: OffsetLayer#455d0
    flutter:   size: Size(320.0, 435.0)
    flutter:   axisDirection: down
    flutter:   crossAxisDirection: right
    flutter:   offset: ScrollPositionWithSingleContext#73245(offset: 334.4, range: 0.0..704.8, viewport: 435.0,
    flutter:   ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
    flutter:   BallisticScrollActivity#68a38(AnimationController#c4069(▶ 334.372; for BallisticScrollActivity)),
    flutter:   ScrollDirection.forward)
    flutter:   anchor: 0.0
    flutter: This RenderObject had the following descendants (showing up to depth 5):
    flutter:   RenderSliverPadding#a82c4 relayoutBoundary=up1 NEEDS-PAINT
    flutter:     RenderSliverList#8666d relayoutBoundary=up2 NEEDS-PAINT
    flutter:       RenderRepaintBoundary#c532e relayoutBoundary=up3 NEEDS-PAINT
    flutter:         RenderSemanticsAnnotations#db9bd relayoutBoundary=up4 NEEDS-PAINT
    flutter:           RenderImage#b69e6 relayoutBoundary=up5 NEEDS-PAINT
    flutter:       RenderRepaintBoundary#061f7 relayoutBoundary=up3 NEEDS-PAINT
    flutter:         RenderPadding#4f722 relayoutBoundary=up4 NEEDS-PAINT
    flutter:       RenderRepaintBoundary#1e13a relayoutBoundary=up3 NEEDS-PAINT
    flutter:         RenderConstrainedBox#ec0ee relayoutBoundary=up4 NEEDS-PAINT
    flutter:           _RenderScrollSemantics#bc85e NEEDS-PAINT
    flutter:       RenderRepaintBoundary#6ad16 relayoutBoundary=up3 NEEDS-PAINT
    flutter:         RenderPadding#f64c6 relayoutBoundary=up4 NEEDS-PAINT
    flutter:       RenderRepaintBoundary#c47ef relayoutBoundary=up3
    flutter:         RenderFlex#f3822 relayoutBoundary=up4
    flutter:           RenderPadding#74786 relayoutBoundary=up5
    flutter:           RenderPadding#44b8b relayoutBoundary=up5
    flutter:           RenderPadding#18e96 relayoutBoundary=up5
    flutter:           RenderPadding#3ed60 relayoutBoundary=up5
    flutter:       RenderRepaintBoundary#c5a6b relayoutBoundary=up3
    flutter:         RenderPadding#46343 relayoutBoundary=up4
    flutter:           RenderFlex#303c3 relayoutBoundary=up5
    flutter:       RenderRepaintBoundary#46797 relayoutBoundary=up3
    flutter:         RenderConstrainedBox#200fb relayoutBoundary=up4
    flutter:           RenderDecoratedBox#5607c
    flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
    flutter: Another exception was thrown: A RenderViewport exceeded its maximum number of layout cycles.
    flutter: Another exception was thrown: A RenderViewport exceeded its maximum number of layout cycles.```
    
  12. dark-chocolate commented on Mar 29, 2019

    @dark-chocolate

    @zoechi Here is the minimal code that will reproduce the issue, however it is happening not for any particular device, but for all devices.

    When you scroll from top to bottom up to say index 25 and suddenly scroll back to the top (0th index) very fast, it shows the error.

    Minimal Code

    void main() => runApp(MaterialApp(home: HomePage()));
    
    class HomePage extends StatefulWidget {
      @override
      _HomePageState createState() => _HomePageState();
    }
    
    class _HomePageState extends State<HomePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text("Title")),
          body: ListView.builder(
            itemCount: 100,
            itemBuilder: (context, index) {
              if (index % 10 == 0) return Image.asset("assets/images/chocolate.png");
              return ListTile(title: Text("Item ${index}"));
            },
          ),
        );
      }
    }
    

    Trace

    
    ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
    I/flutter ( 4769): The following assertion was thrown during performLayout():
    I/flutter ( 4769): A RenderViewport exceeded its maximum number of layout cycles.
    I/flutter ( 4769): RenderViewport render objects, during layout, can retry if either their slivers or their
    I/flutter ( 4769): ViewportOffset decide that the offset should be corrected to take into account information collected
    I/flutter ( 4769): during that layout.
    I/flutter ( 4769): In the case of this RenderViewport object, however, this happened 10 times and still there was no
    I/flutter ( 4769): consensus on the scroll offset. This usually indicates a bug. Specifically, it means that one of the
    I/flutter ( 4769): following three problems is being experienced by the RenderViewport object:
    I/flutter ( 4769):  * One of the RenderSliver children or the ViewportOffset have a bug such that they always think
    I/flutter ( 4769):    that they need to correct the offset regardless.
    I/flutter ( 4769):  * Some combination of the RenderSliver children and the ViewportOffset have a bad interaction such
    I/flutter ( 4769):    that one applies a correction then another applies a reverse correction, leading to an infinite
    I/flutter ( 4769):    loop of corrections.
    I/flutter ( 4769):  * There is a pathological case that would eventually resolve, but it is so complicated that it
    I/flutter ( 4769):    cannot be resolved in any reasonable number of layout passes.
    I/flutter ( 4769): 
    I/flutter ( 4769): When the exception was thrown, this was the stack:
    I/flutter ( 4769): #0      RenderViewport.performLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1255:9)
    I/flutter ( 4769): #1      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1275:6)
    I/flutter ( 4769): #2      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1519:7)
    I/flutter ( 4769): #3      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
    I/flutter ( 4769): #4      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:336:19)
    I/flutter ( 4769): #5      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
    I/flutter ( 4769): #6      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:275:5)
    I/flutter ( 4769): #7      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1008:15)
    I/flutter ( 4769): #8      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:948:9)
    I/flutter ( 4769): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:860:5)
    I/flutter ( 4769): #13     _invoke (dart:ui/hooks.dart:219:10)
    I/flutter ( 4769): #14     _drawFrame (dart:ui/hooks.dart:178:3)
    I/flutter ( 4769): (elided 3 frames from package dart:async)
    I/flutter ( 4769): 
    I/flutter ( 4769): The following RenderObject was being processed when the exception was fired:
    I/flutter ( 4769):   RenderViewport#c5af6 NEEDS-LAYOUT NEEDS-PAINT
    I/flutter ( 4769):   creator: Viewport ← IgnorePointer-[GlobalKey#c767e] ← Semantics ← Listener ← _GestureSemantics ←
    I/flutter ( 4769):   RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#d7d1d] ← Listener ← _ScrollableScope
    I/flutter ( 4769):   ← _ScrollSemantics-[GlobalKey#9399b] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← ⋯
    I/flutter ( 4769):   parentData: <none> (can use size)
    I/flutter ( 4769):   constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=512.0)
    I/flutter ( 4769):   layer: OffsetLayer#9cd7e
    I/flutter ( 4769):   size: Size(360.0, 512.0)
    I/flutter ( 4769):   axisDirection: down
    I/flutter ( 4769):   crossAxisDirection: right
    I/flutter ( 4769):   offset: ScrollPositionWithSingleContext#d5cbe(offset: 342.9, range: 0.0..5823.2, viewport: 512.0,
    I/flutter ( 4769):   ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics,
    I/flutter ( 4769):   BallisticScrollActivity#e6a89(AnimationController#f6b9b(▶ 342.913; for BallisticScrollActivity)),
    I/flutter ( 4769):   ScrollDirection.forward)
    I/flutter ( 4769):   anchor: 0.0
    I/flutter ( 4769): This RenderObject had the following descendants (showing up to depth 5):
    I/flutter ( 4769):   RenderSliverPadding#f6e3a relayoutBoundary=up1 NEEDS-PAINT
    I/flutter ( 4769):     RenderSliverList#ab244 relayoutBoundary=up2 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#4fe73 relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#53f7b relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsAnnotations#18e63 relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#187ad relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#7ac1b relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsGestureHandler#20bc8 relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#6b21c relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#30ac8 relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsGestureHandler#6937b relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#c8fb8 relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#8fad9 relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsGestureHandler#1f314 relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#89d5d relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#70212 relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsGestureHandler#43a1c relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#4ca93 relayoutBoundary=up3 NEEDS-PAINT
    I/flutter ( 4769):         RenderRepaintBoundary#92403 relayoutBoundary=up4 NEEDS-PAINT
    I/flutter ( 4769):           RenderSemanticsGestureHandler#8a024 relayoutBoundary=up5 NEEDS-PAINT
    I/flutter ( 4769):       RenderIndexedSemantics#bce23 relayoutBoundary=up3
    I/flutter ( 4769):         RenderRepaintBoundary#c7825 relayoutBoundary=up4
    I/flutter ( 4769):           RenderSemanticsGestureHandler#d73cb relayoutBoundary=up5
    I/flutter ( 4769):       RenderIndexedSemantics#71566 relayoutBoundary=up3
    I/flutter ( 4769):         RenderRepaintBoundary#46023 relayoutBoundary=up4
    I/flutter ( 4769):           RenderSemanticsGestureHandler#e1c80 relayoutBoundary=up5
    I/flutter ( 4769):       RenderIndexedSemantics#fb467 relayoutBoundary=up3
    I/flutter ( 4769):         RenderRepaintBoundary#5a3e1 relayoutBoundary=up4
    I/flutter ( 4769):           RenderSemanticsGestureHandler#7c6a2 relayoutBoundary=up5
    I/flutter ( 4769): ════════════════════════════════════════════════════════════════════════════════════════════════════
    
  13. self-assigned this
    on Apr 5, 2019
  14. chunhtai commented on Apr 9, 2019

    @chunhtai
    Contributor

    It looks like this is caused by double precision error. If we have certain height of widget in sliver list, the way we calculate layout offset of children will introduce some double precision error. Later when we scroll all the way to top, we will try to correct the error by shifting the scroll offset even if it is so tiny and does not really need to be corrected (~2e-14).

    Most of the time it is correctable, but some times it fail to do so due to precision error in double operation(again...)

    for example iphone 6s
    corrected_scrollofset = scrolloffset + correction
    if scrolloffset = 258.8489087697789 and correction = 0.00000000000002842170943040401
    Then the scrolloffset does not change after correction due to precision error.
    258.8489087697789 + 0.00000000000002842170943040401 = 258.8489087697789
    Thus, it stuck on an infinite update loop.

    I think there is nothing we can do to the floating operation error. This is more like a hardware limitation. The thing we can do is try to find a way to work around this issue. I will put up a pr shortly with possible fix.

  15. github-actions commented on Aug 14, 2021

    @github-actions

    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.

  16. locked as resolved and limited conversation to collaborators on Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consolee: device-specificOnly manifests on certain devicesf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specifically

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions