3

I've built several release builds in the past but suddenly my release builds are no longer working. My debug builds are working fine. I can not determine what has changed since the last time I successfully built.

Every attempt for iOS release build lead to a similar stacktrace involving TypeFlowAnalysis.

I have a very long log but from what I can tell the crux of it is:

  [ +608 ms] Persisting file store
                        [   +1 ms] Done persisting file store
                        [   +3 ms] "flutter assemble" took 2,571,290ms.
                        [        ] ensureAnalyticsSent: 0ms
                        [        ] Running shutdown hooks
                        [        ] Shutdown hooks complete
                        [        ] exiting with code 1
                        [+2568997 ms] Exhausted heap space, trying to allocate 268435488 bytes.

                        [   +1 ms] Unhandled exception:
                                   Out of Memory
                                   #0      _LinkedHashSetMixin._init (dart:collection-patch/compact_hash.dart:824:17)
                                   #1      _LinkedHashSetMixin._rehash (dart:collection-patch/compact_hash.dart:803:7)
                                   #2      _LinkedHashSetMixin._add (dart:collection-patch/compact_hash.dart:865:7)
                                   #3      _DependencyTracker.addDependentInvocation
(package:vm/transformations/type_flow/analysis.dart:59:28)
                                   #4      TypeFlowAnalysis.applyCall
(package:vm/transformations/type_flow/analysis.dart:1720:20)
                                   #5      Call.apply (package:vm/transformations/type_flow/summary.dart:268:31)
                                   #6      Summary.apply (package:vm/transformations/type_flow/summary.dart:724:33)
                                   #7      _DirectInvocation._processFunction
(package:vm/transformations/type_flow/analysis.dart:307:24)
                                   #8      _WorkList.processInvocation
(package:vm/transformations/type_flow/analysis.dart:1472:27)
                                   #9      _DispatchableInvocation.process.<anonymous closure>
                                   (package:vm/transformations/type_flow/analysis.dart:449:44)
                                   #10     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
                                   #11     _DispatchableInvocation.process
(package:vm/transformations/type_flow/analysis.dart:423:12)
                                   #12     _WorkList.processInvocation
(package:vm/transformations/type_flow/analysis.dart:1472:27)
                                   #13     _WorkList.process (package:vm/transformations/type_flow/analysis.dart:1414:7)
                                   #14     TypeFlowAnalysis.process (package:vm/transformations/type_flow/analysis.dart:1604:14)
                                   #15     transformComponent (package:vm/transformations/type_flow/transformer.dart:111:20)
                                   #16     runGlobalTransformations (package:vm/kernel_front_end.dart:492:20)
                                   #17     compileToKernel (package:vm/kernel_front_end.dart:411:11)
                                   #18     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #19     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #20     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #21     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #22     Future._completeWithValue (dart:async/future_impl.dart:566:5)
                                   #23     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #24     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #25     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #26     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #27     Future._completeWithValue (dart:async/future_impl.dart:566:5)
                                   #28     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #29     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #30     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #31     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #32     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   ...
                                   ...
                                   #39     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #40     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #41     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #42     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #43     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #44     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #45     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #46     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #47     Future._completeWithValue (dart:async/future_impl.dart:566:5)
                                   #48     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #49     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #50     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #51     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #52     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #53     _FutureListener.handleValue (dart:async/future_impl.dart:147:18)
                                   #54     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:766:45)
                                   #55     Future._propagateToListeners (dart:async/future_impl.dart:795:13)
                                   #56     _rootRunUnary (dart:async/zone.dart:1399:47)
                                   #57     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
                                   #58     _rootRun (dart:async/zone.dart:1391:13)
                                   #59     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1225:23)
                                   #60     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
                                   #61     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
                                   #62     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
                                   #63     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:405:11)
                                   #64     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
                                   #65     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

Ruling out the version of Flutter: I tried upgrading flutter to the latest stable (3.7). I tried downgrading to the version of flutter I used during the last successful release build (3.3.6).

Ruling out platform: I have the out of memory issue on iOS (stack above). Building the Android appbundle, I don't get a stacktrace but instead the system (M1 Mac 64GB) runs out of application memory.

Dependencies: Tried using the dependencies I used in the last successful release build Tried upgraded all dependencies

The usual go-to's: flutter clean, clearing XCode DerivedData, flutter pub cache clean, pod cache clean --all mentioned as solutions to similar questions found of SO.

None of the above fixed my issue.

Flutter: Exhausted heap space, trying to allocate 8589934608 bytes and laptop stops responding

^^ and other answers seem to suggest that upgrading Flutter, or cleaning Flutter will usually solve the problem with no real explanations as to why or pointing to the actual issue. These date back to 2020/21 so not sure if they are still relevant for Flutter 3+

I'm working on bisecting back to find the last known good commit but with release build taking over an hour it will take me sometime. It is a fairly large project with lots of code-gen but nothing has changed dramatically in terms of projects size since the last successful build.

Here is my flutter doctor:

╰─ flutter doctor -v                                                                                                                                                                                ─╯[✓] Flutter (Channel stable, 3.3.6, on macOS 12.6 21G115 darwin-arm, locale en-US)• Flutter version 3.3.6 on channel stable at /Users/alyibrahim/dev/flutter• Upstream repository https://github.com/flutter/flutter.git• Framework revision 6928314d50 (3 months ago), 2022-10-25 16:34:41 -0400• Engine revision 3ad69d7be3• Dart version 2.18.2• DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)• Android SDK at /Users/alyibrahim/Library/Android/sdk• Platform android-33, build-tools 33.0.0• ANDROID_HOME = /Users/alyibrahim/Library/Android/sdk• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)• Xcode at /Applications/Xcode.app/Contents/Developer• Build 14C18• CocoaPods version 1.11.3

[✓] Android Studio (version 2021.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 11.0.13+0-b1751.21-8125866)

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

[✓] Connected device (1 available)• macOS (desktop) • macos • darwin-arm64 • macOS 12.6 21G115 darwin-arm

[✓] HTTP Host Availability• All required HTTP hosts are available

• No issues found!
Aly Ibrahim
  • 51
  • 1
  • 5
  • 1
    Did you find a fix for this? I am having the same issue. – Tony Raul Blanco Fernandez Feb 04 '23 at 16:17
  • Unfortunately I have not found the root cause. I suspect the culprit is the code generated GraphQL classes. I am using [Ferry](https://pub.dev/packages/ferry)for code generation. I reduced the complexity of the graph, regenerated, and recompiled and the compile succeed. This is not a long term solution as I am not always going to be able to reduce the complexity of the datamodel. How many total classes do you have in your application? Are you by chance also use lots of code gen? – Aly Ibrahim Feb 05 '23 at 21:19

0 Answers0