[macos] Using App.xcframework and FlutterMacOS.framework directly leads to exception when engine is started

This issue has been created since 2022-11-23.

Documentation mentions 2 ways of integrating flutter engine into existing app. First one is to use pod and second is to use generated frameworks directly. First one works fine, but second results in an exception when engine is started (btw, it works fine with iOS):

2022-11-23 13:49:01.183731+0200 weatherMacOSSwift[41929:261526] Metal API Validation Enabled
Exhausted heap space, trying to allocate 32 bytes.
../../third_party/dart/runtime/vm/object.cc: 2727: error: Out of memory.
version=2.18.4 (stable) (Tue Nov 1 15:15:07 2022 +0000) on "macos_arm64"
pid=41929, thread=259, isolate_group=vm-isolate(0x13388d800), isolate=vm-isolate(0x133892400)
isolate_instructions=1088cf140, vm_instructions=1088cf140
  pc 0x0000000108a2a874 fp 0x000000016d70a5a0 dart::Profiler::DumpStackTrace(void*)+0x90
  pc 0x00000001088cf31c fp 0x000000016d70a5c0 dart::Assert::Fail(char const*, ...) const+0x28
  pc 0x00000001089a2bd0 fp 0x000000016d70a620 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x134
  pc 0x00000001089d56b4 fp 0x000000016d70a6b0 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xcc
  pc 0x00000001089d5b18 fp 0x000000016d70a6f0 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x40
  pc 0x0000000108aa864c fp 0x000000016d70a820 dart::StubCode::Generate(char const*, dart::compiler::ObjectPoolBuilder*, void (*)(dart::compiler::Assembler*))+0xb0
  pc 0x0000000108aa8500 fp 0x000000016d70a8e0 dart::StubCode::Init()+0xa8
  pc 0x000000010891b5f4 fp 0x000000016d70af30 dart::Dart::DartInit(Dart_InitializeParams const*)+0x438
  pc 0x000000010891b894 fp 0x000000016d70af60 dart::Dart::Init(Dart_InitializeParams const*)+0x48
  pc 0x0000000108890154 fp 0x000000016d70b0d0 DartVMInitializer::Initialize(Dart_InitializeParams*, bool, bool)+0x34
  pc 0x000000010888ebb8 fp 0x000000016d70b2f0 flutter::DartVM::DartVM(std::__1::shared_ptr<flutter::DartVMData const>, std::__1::shared_ptr<flutter::IsolateNameServer>)+0x8ac
  pc 0x000000010888e1dc fp 0x000000016d70b960 flutter::DartVM::Create(flutter::Settings, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>, std::__1::shared_ptr<flutter::IsolateNameServer>)+0xf4
  pc 0x0000000108890cfc fp 0x000000016d70bff0 flutter::DartVMRef::Create(flutter::Settings, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>)+0x208
  pc 0x00000001086fdaac fp 0x000000016d70cbc0 flutter::Shell::Create(flutter::PlatformData const&, flutter::TaskRunners, flutter::Settings, std::__1::function<std::__1::unique_ptr<flutter::PlatformView, std::__1::default_delete<flutter::PlatformView> > (flutter::Shell&)> const&, std::__1::function<std::__1::unique_ptr<flutter::Rasterizer, std::__1::default_delete<flutter::Rasterizer> > (flutter::Shell&)> const&, bool)+0x124
  pc 0x00000001088b97fc fp 0x000000016d70d270 flutter::EmbedderEngine::LaunchShell()+0x74
  pc 0x00000001088a5274 fp 0x000000016d70d3e0 FlutterEngineRunInitialized+0xd8
  pc 0x0000000108056e98 fp 0x000000016d70d770 -[FlutterEngine runWithEntrypoint:]+0x548
  pc 0x00000001026f2424 fp 0x000000016d70d870 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVF+0x110
  pc 0x00000001026f2820 fp 0x000000016d70d8f0 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVFTo+0x8c
  pc 0x000000018eab5468 fp 0x000000016d70d900 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__+0x1c
  pc 0x020c00018eb59bb8 fp 0x000000016d70d920 ___CFXRegistrationPost_block_invoke+0x20c000000000034
  pc 0xac0e80018eb59b24 fp 0x000000016d70d9e0 _CFXRegistrationPost+0xac0e8000000001c8
  pc 0x8f5e80018ea840f8 fp 0x000000016d70e390 _CFXNotificationPost+0x8f5e8000000002dc
  pc 0x375000018f949c28 fp 0x000000016d70e3c0 -[NSNotificationCenter postNotificationName:object:userInfo:]+0x3750000000000060
  pc 0x467c80019162f28c fp 0x000000016d70e420 -[NSApplication _postDidFinishNotification]+0x467c800000000154
  pc 0x5d7680019162efa4 fp 0x000000016d70e450 -[NSApplication _sendFinishLaunchingNotification]+0x5d768000000000ec
  pc 0x5a2200019162c9c8 fp 0x000000016d70e4f0 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]+0x5a2200000000024c
  pc 0x7d5c00019162c5a8 fp 0x000000016d70e550 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]+0x7d5c00000000030c
  pc 0x7b4c00018f9767d8 fp 0x000000016d70e5a0 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]+0x7b4c00000000015c
  pc 0x2c7600018f976610 fp 0x000000016d70e5e0 _NSAppleEventManagerGenericHandler+0x2c76000000000060
  pc 0x1a06800195266ac4 fp 0x000000016d70e8c0 _AppleEventsCheckInAppWithBlock+0x1a06800000003b04
  pc 0xde4a00019526641c fp 0x000000016d70e8f0 _AppleEventsCheckInAppWithBlock+0xde4a00000000345c
  pc 0x784000019525f4b4 fp 0x000000016d70e960 aeProcessAppleEvent+0x78400000000001e8
  pc 0x832480019770f95c fp 0x000000016d70e9a0 AEProcessAppleEvent+0x8324800000000044
  pc 0x4e170001916268f4 fp 0x000000016d70edf0 _DPSNextEvent+0x4e17000000000734
  pc 0x485f800191624e14 fp 0x000000016d70f070 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0x485f800000000530
  pc 0xa853800191616fe0 fp 0x000000016d70f0f0 -[NSApplication run]+0xa853800000000254
  pc 0xc11f0001915e86fc fp 0x000000016d70f160 NSApplicationMain+0xc11f00000000046c
  pc 0xca620001026f2b28 fp 0x000000016d70f180 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ+0xca62000000000028
  pc 0x00000001026f2af0 fp 0x000000016d70f1b0 $s17weatherMacOSSwift11AppDelegateC5$mainyyFZ+0x2c
  pc 0x00000001026f2bc0 fp 0x000000016d70f1d0 main+0x1c
  pc 0x000000010287108c fp 0x000000016d70f320 Unknown symbol
-- End of DumpStackTrace

Steps to Reproduce (check WeatherApp.zip)

  1. Create flutter application flutter create --template app --platforms macos weather_app
  2. cd weather_app
  3. flutter build macos-framework

Create macOS application using XCode (Swift and storyboard is fine).

  1. Find App.xcframework and FlutterMacOS.xcframework inside weather_app/build/macos/frameworks/Debug, drop them to project settings like so:

image

  1. Replace AppDelegate.swift with this:
import Cocoa
import FlutterMacOS

@main
class AppDelegate: NSObject, NSApplicationDelegate {
    var engine: FlutterEngine?;

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        engine = FlutterEngine.init(name: "Weather", project: nil, allowHeadlessExecution: true)
        engine?.run(withEntrypoint: nil); // <<<--- this is where it crashes
        
        var channel = FlutterMethodChannel(name: "mychannel", binaryMessenger: engine!.binaryMessenger)
        channel.invokeMethod("makeString", arguments: 123)
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }

    func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
        return true
    }
}

It's not required for this bug, but you also can modify a bit dart side, to listen for messages on "mychannel":

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  print("Starting");
  const platform = MethodChannel('mychannel');
  platform.setMethodCallHandler(handle);
  runApp(const MyApp());
}

Future<dynamic> handle(MethodCall call) async {
  print("Handling message " + call.toString());
  return 10;
}

Expected results:

In console you should see:

2022-11-23 12:47:53.112656+0200 weather_app[17476:119641] Metal API Validation Enabled
flutter: The Dart VM service is listening on http://127.0.0.1:57174/5MZPYgCShK4=/
flutter: Starting
flutter: Handling message MethodCall(makeString, 123)

Actual results:

Exception when engine.run() is executed

2022-11-23 13:49:01.183731+0200 weatherMacOSSwift[41929:261526] Metal API Validation Enabled
Exhausted heap space, trying to allocate 32 bytes.
../../third_party/dart/runtime/vm/object.cc: 2727: error: Out of memory.
version=2.18.4 (stable) (Tue Nov 1 15:15:07 2022 +0000) on "macos_arm64"
pid=41929, thread=259, isolate_group=vm-isolate(0x13388d800), isolate=vm-isolate(0x133892400)
isolate_instructions=1088cf140, vm_instructions=1088cf140
  pc 0x0000000108a2a874 fp 0x000000016d70a5a0 dart::Profiler::DumpStackTrace(void*)+0x90
  pc 0x00000001088cf31c fp 0x000000016d70a5c0 dart::Assert::Fail(char const*, ...) const+0x28
  pc 0x00000001089a2bd0 fp 0x000000016d70a620 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x134
  pc 0x00000001089d56b4 fp 0x000000016d70a6b0 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xcc
  pc 0x00000001089d5b18 fp 0x000000016d70a6f0 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x40
  pc 0x0000000108aa864c fp 0x000000016d70a820 dart::StubCode::Generate(char const*, dart::compiler::ObjectPoolBuilder*, void (*)(dart::compiler::Assembler*))+0xb0
  pc 0x0000000108aa8500 fp 0x000000016d70a8e0 dart::StubCode::Init()+0xa8
  pc 0x000000010891b5f4 fp 0x000000016d70af30 dart::Dart::DartInit(Dart_InitializeParams const*)+0x438
  pc 0x000000010891b894 fp 0x000000016d70af60 dart::Dart::Init(Dart_InitializeParams const*)+0x48
  pc 0x0000000108890154 fp 0x000000016d70b0d0 DartVMInitializer::Initialize(Dart_InitializeParams*, bool, bool)+0x34
  pc 0x000000010888ebb8 fp 0x000000016d70b2f0 flutter::DartVM::DartVM(std::__1::shared_ptr<flutter::DartVMData const>, std::__1::shared_ptr<flutter::IsolateNameServer>)+0x8ac
  pc 0x000000010888e1dc fp 0x000000016d70b960 flutter::DartVM::Create(flutter::Settings, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>, std::__1::shared_ptr<flutter::IsolateNameServer>)+0xf4
  pc 0x0000000108890cfc fp 0x000000016d70bff0 flutter::DartVMRef::Create(flutter::Settings, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>)+0x208
  pc 0x00000001086fdaac fp 0x000000016d70cbc0 flutter::Shell::Create(flutter::PlatformData const&, flutter::TaskRunners, flutter::Settings, std::__1::function<std::__1::unique_ptr<flutter::PlatformView, std::__1::default_delete<flutter::PlatformView> > (flutter::Shell&)> const&, std::__1::function<std::__1::unique_ptr<flutter::Rasterizer, std::__1::default_delete<flutter::Rasterizer> > (flutter::Shell&)> const&, bool)+0x124
  pc 0x00000001088b97fc fp 0x000000016d70d270 flutter::EmbedderEngine::LaunchShell()+0x74
  pc 0x00000001088a5274 fp 0x000000016d70d3e0 FlutterEngineRunInitialized+0xd8
  pc 0x0000000108056e98 fp 0x000000016d70d770 -[FlutterEngine runWithEntrypoint:]+0x548
  pc 0x00000001026f2424 fp 0x000000016d70d870 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVF+0x110
  pc 0x00000001026f2820 fp 0x000000016d70d8f0 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVFTo+0x8c
  pc 0x000000018eab5468 fp 0x000000016d70d900 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__+0x1c
  pc 0x020c00018eb59bb8 fp 0x000000016d70d920 ___CFXRegistrationPost_block_invoke+0x20c000000000034
  pc 0xac0e80018eb59b24 fp 0x000000016d70d9e0 _CFXRegistrationPost+0xac0e8000000001c8
  pc 0x8f5e80018ea840f8 fp 0x000000016d70e390 _CFXNotificationPost+0x8f5e8000000002dc
  pc 0x375000018f949c28 fp 0x000000016d70e3c0 -[NSNotificationCenter postNotificationName:object:userInfo:]+0x3750000000000060
  pc 0x467c80019162f28c fp 0x000000016d70e420 -[NSApplication _postDidFinishNotification]+0x467c800000000154
  pc 0x5d7680019162efa4 fp 0x000000016d70e450 -[NSApplication _sendFinishLaunchingNotification]+0x5d768000000000ec
  pc 0x5a2200019162c9c8 fp 0x000000016d70e4f0 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]+0x5a2200000000024c
  pc 0x7d5c00019162c5a8 fp 0x000000016d70e550 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]+0x7d5c00000000030c
  pc 0x7b4c00018f9767d8 fp 0x000000016d70e5a0 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]+0x7b4c00000000015c
  pc 0x2c7600018f976610 fp 0x000000016d70e5e0 _NSAppleEventManagerGenericHandler+0x2c76000000000060
  pc 0x1a06800195266ac4 fp 0x000000016d70e8c0 _AppleEventsCheckInAppWithBlock+0x1a06800000003b04
  pc 0xde4a00019526641c fp 0x000000016d70e8f0 _AppleEventsCheckInAppWithBlock+0xde4a00000000345c
  pc 0x784000019525f4b4 fp 0x000000016d70e960 aeProcessAppleEvent+0x78400000000001e8
  pc 0x832480019770f95c fp 0x000000016d70e9a0 AEProcessAppleEvent+0x8324800000000044
  pc 0x4e170001916268f4 fp 0x000000016d70edf0 _DPSNextEvent+0x4e17000000000734
  pc 0x485f800191624e14 fp 0x000000016d70f070 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0x485f800000000530
  pc 0xa853800191616fe0 fp 0x000000016d70f0f0 -[NSApplication run]+0xa853800000000254
  pc 0xc11f0001915e86fc fp 0x000000016d70f160 NSApplicationMain+0xc11f00000000046c
  pc 0xca620001026f2b28 fp 0x000000016d70f180 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ+0xca62000000000028
  pc 0x00000001026f2af0 fp 0x000000016d70f1b0 $s17weatherMacOSSwift11AppDelegateC5$mainyyFZ+0x2c
  pc 0x00000001026f2bc0 fp 0x000000016d70f1d0 main+0x1c
  pc 0x000000010287108c fp 0x000000016d70f320 Unknown symbol
-- End of DumpStackTrace
Code sample [WeatherApp.zip](https://github.com/flutter/flutter/files/10075474/WeatherApp.zip)
Logs
flutter doctor -v                                                                       1 ✘  14:29:11 
[✓] Flutter (Channel stable, 3.3.8, on macOS 12.6 21G115 darwin-arm, locale en-FI)
    • Flutter version 3.3.8 on channel stable at /Users/sergiy.dubovik/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (2 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/sergiy.dubovik/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

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

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

[✓] 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)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/sergiy.dubovik/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/sergiy.dubovik/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/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.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.48.0

[✓] Connected device (3 available)
    • iPhone 14 Pro (mobile) • 3BAF699A-06EF-4ABA-B810-33C1D01E8873 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-0
      (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110

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

! Doctor found issues in 1 category.
danagbemava-nc wrote this answer on 2022-11-23

Issue is reproducible using the steps outlined above.

logs
error: Error reading commands from file lldbinit - file not found.
2022-11-23 13:40:28.838513+0000 weatherMacOSSwift[36616:2462750] Metal API Validation Enabled
Exhausted heap space, trying to allocate 32 bytes.
../../third_party/dart/runtime/vm/object.cc: 2784: error: Out of memory.
version=2.19.0-421.0.dev (dev) (Tue Nov 22 15:11:36 2022 -0800) on "macos_arm64"
pid=36616, thread=259, isolate_group=vm-isolate(0x141875600), isolate=vm-isolate(0x14187ba00)
os=macos, arch=arm64, comp=no, sim=no
isolate_instructions=10b3943e0, vm_instructions=10b3943e0
  pc 0x000000010b4f69b0 fp 0x000000016afd7500 dart::Profiler::DumpStackTrace(void*)+0x90
  pc 0x000000010b39462c fp 0x000000016afd7520 dart::Assert::Fail(char const*, ...) const+0x28
  pc 0x000000010b466810 fp 0x000000016afd75a0 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x148
  pc 0x000000010b499be4 fp 0x000000016afd7630 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xcc
  pc 0x000000010b49a048 fp 0x000000016afd7670 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x40
  pc 0x000000010b570528 fp 0x000000016afd77a0 dart::StubCode::Generate(char const*, dart::compiler::ObjectPoolBuilder*, void (*)(dart::compiler::Assembler*))+0xb0
  pc 0x000000010b5703dc fp 0x000000016afd7860 dart::StubCode::Init()+0xa8
  pc 0x000000010b3e3b58 fp 0x000000016afd7ec0 dart::Dart::DartInit(Dart_InitializeParams const*)+0x43c
  pc 0x000000010b3e3df0 fp 0x000000016afd7ef0 dart::Dart::Init(Dart_InitializeParams const*)+0x40
  pc 0x000000010b3485d0 fp 0x000000016afd8060 DartVMInitializer::Initialize(Dart_InitializeParams*, bool, bool)+0x34
  pc 0x000000010b3471cc fp 0x000000016afd8260 flutter::DartVM::DartVM(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::DartVMData const> const&, std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::IsolateNameServer>)+0x884
  pc 0x000000010b34684c fp 0x000000016afd83f0 flutter::DartVM::Create(flutter::Settings const&, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>, std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::IsolateNameServer>)+0xc4
  pc 0x000000010b34913c fp 0x000000016afd85c0 flutter::DartVMRef::Create(flutter::Settings const&, fml::RefPtr<flutter::DartSnapshot const>, fml::RefPtr<flutter::DartSnapshot const>)+0x1cc
  pc 0x000000010b11ac44 fp 0x000000016afd8c90 flutter::Shell::Create(flutter::PlatformData const&, flutter::TaskRunners const&, flutter::Settings, std::_LIBCPP_ABI_NAMESPACE::function<std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::PlatformView, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::PlatformView>> (flutter::Shell&)> const&, std::_LIBCPP_ABI_NAMESPACE::function<std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::Rasterizer, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::Rasterizer>> (flutter::Shell&)> const&, bool)+0x118
  pc 0x000000010b3712a8 fp 0x000000016afd9300 flutter::EmbedderEngine::LaunchShell()+0x6c
  pc 0x000000010b35d2a0 fp 0x000000016afd9470 FlutterEngineRunInitialized+0xd8
  pc 0x000000010aadb17c fp 0x000000016afd97f0 -[FlutterEngine runWithEntrypoint:]+0x534
  pc 0x0000000104e26424 fp 0x000000016afd98f0 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVF+0x110
  pc 0x0000000104e26820 fp 0x000000016afd9970 $s17weatherMacOSSwift11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVFTo+0x8c
  pc 0x0000000189f5e58c fp 0x000000016afd99c0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__+0x94
  pc 0xc934800189ffc074 fp 0x000000016afd9a00 ___CFXRegistrationPost_block_invoke+0xc934800000000058
  pc 0xa865000189ffbfbc fp 0x000000016afd9ae0 _CFXRegistrationPost+0xa8650000000001b8
  pc 0xbe5b800189f2fbac fp 0x000000016afda490 _CFXNotificationPost+0xbe5b8000000002c4
  pc 0xf67880018ae1c72c fp 0x000000016afda4c0 -[NSNotificationCenter postNotificationName:object:userInfo:]+0xf678800000000058
  pc 0x503700018d1c7a1c fp 0x000000016afda520 -[NSApplication _postDidFinishNotification]+0x503700000000011c
  pc 0xbb7c00018d1c77cc fp 0x000000016afda550 -[NSApplication _sendFinishLaunchingNotification]+0xbb7c0000000000ac
  pc 0x4e5f00018d1c5860 fp 0x000000016afda5f0 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]+0x4e5f0000000001e8
  pc 0xce4f00018d1c546c fp 0x000000016afda640 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]+0xce4f0000000001ec
  pc 0x932b80018ae469d8 fp 0x000000016afda680 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]+0x932b80000000013c
  pc 0x0a1100018ae46838 fp 0x000000016afda6c0 _NSAppleEventManagerGenericHandler+0xa11000000000050
  pc 0x523980019027c874 fp 0x000000016afda9a0 _AppleEventsCheckInAppWithBlock+0x52398000000039d4
  pc 0x886700019027c1a0 fp 0x000000016afda9d0 _AppleEventsCheckInAppWithBlock+0x8867000000003300
  pc 0x5f26800190275240 fp 0x000000016afdaa40 aeProcessAppleEvent+0x5f268000000001e8
  pc 0xc74c0001935ec928 fp 0x000000016afdaa80 AEProcessAppleEvent+0xc74c000000000044
  pc 0xbf5300018d1c093c fp 0x000000016afdae30 _DPSNextEvent+0xbf53000000000584
  pc 0x8e4f80018d1bf7c0 fp 0x000000016afdaf10 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0x8e4f8000000002d8
  pc 0x491d00018d1b3bf0 fp 0x000000016afdaf80 -[NSApplication run]+0x491d0000000001d0
  pc 0x662c00018d18b058 fp 0x000000016afdafe0 NSApplicationMain+0x662c000000000370
  pc 0x0f19000104e26b28 fp 0x000000016afdb000 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ+0xf19000000000028
  pc 0x0000000104e26af0 fp 0x000000016afdb030 $s17weatherMacOSSwift11AppDelegateC5$mainyyFZ+0x2c
  pc 0x0000000104e26bc0 fp 0x000000016afdb050 main+0x1c
  pc 0x0000000189b5fe50 fp 0x000000016afdb340 start+0x9f0
-- End of DumpStackTrace
(lldb) 
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-arm, locale en-GB)
    • Flutter version 3.3.8 on channel stable at /Users/nexus/dev/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (2 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

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

[!] Android Studio
    • Android Studio at /Applications/Android Studio Preview.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] 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)

[!] Android Studio
    • Android Studio at /Applications/Android Studio Preview 2.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/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.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • M2007J20CG (mobile) • 5dd3be00 • android-arm64  • Android 12 (API 31)
    • macOS (desktop)     • macos    • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm
    • Chrome (web)        • chrome   • web-javascript • Google Chrome 107.0.5304.110

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

! Doctor found issues in 2 categories.
[!] Flutter (Channel master, 3.6.0-7.0.pre.34, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
    • Flutter version 3.6.0-7.0.pre.34 on channel master at /Users/nexus/dev/sdks/flutters
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a780a007e4 (8 hours ago), 2022-11-23 00:31:49 -0500
    • Engine revision a43142d77a
    • Dart version 2.19.0 (build 2.19.0-421.0.dev)
    • DevTools version 2.19.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

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

[!] Android Studio
    • Android Studio at /Applications/Android Studio Preview.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] 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)

[!] Android Studio
    • Android Studio at /Applications/Android Studio Preview 2.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/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.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • M2007J20CG (mobile) • 5dd3be00 • android-arm64  • Android 12 (API 31)
    • macOS (desktop)     • macos    • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
    • Chrome (web)        • chrome   • web-javascript • Google Chrome 107.0.5304.110

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

! Doctor found issues in 3 categories.

chinmaygarde wrote this answer on 2022-11-28

This is happening during shell launch. The VM reports that it cannot allocate any memory. Nothing particularly expensive has happened till this point. cc @rmacnak-google @a-siva, could the VM fail to allocate memory for reason other than malloc failures?

a-siva wrote this answer on 2022-11-28

In this case it is clear that the failure is happening while trying to allocate an object in the Dart heap. Can we get some additional information about this

  • was a parameter passed in to limit the maximum dart heap size ?
  • can we get information about the current resident set size of the process
dubik wrote this answer on 2022-11-29

I don't know where to find parameters for the dart's heap size, but I compiled debug version of flutter (master) and found the failing function. It looks like mmap fails, which leads to an "out of memory" exception.

I guess at this time it tries to allocate memory for instructions.
image

Before that, there is another call, with almost the same parameters to mmap which succeeds (and this time it tries to allocate memory for some data):
image

Does this help?

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-10
Star Count 147243
Watcher Count 3561
Fork Count 23950
Issue Count 11325

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Cannot send notifications on the boot method of a service provider 7 2022-10-22 2022-12-09
IWrite allow StringBuilder type of parameter 9 2021-01-15 2022-11-17
[Bug] `crypto/dd/twitter` errors 0 2022-10-30 2022-10-27
Helm: include HA dedup deduplication tracker 2 2022-06-16 2022-11-18
Persist Array in React Native 0 2021-05-07 2022-10-12
Revit wall by profile wrong elevation 0 2022-03-22 2022-07-18
at_client-3.0.4 Storage Manager argument issue 5 2021-11-13 2022-10-25
Native code cannot be serialized. 1 2019-06-29 2022-10-28
Kitchen converge fails on Windows 10 syncing initial cookbooks 1 2019-08-08 2022-11-10
model doc set default save path for vmdl that was opened via "Create model for X" from the asset browser 1 2021-12-08 2022-10-01
get_filetype should check for the existence of file command 0 2022-11-01 2022-11-19
Crash report 0 2021-11-17 2022-01-12
Font size can't be changed! 3 2019-08-31 2022-11-28
Slash command member Option does not return user ID for external users when the option is optional 3 2021-11-12 2022-10-30
In-word formatting does not appear to parse 8 2020-07-02 2022-12-09
SABnzbd DARK Theme issue 1 2022-05-08 2022-12-08
[Bug] Sometimes telemetry data pushed via Rest /api/v1/token/telemetry is not treated by backend in a micro-service deployment 1 2022-09-14 2022-10-03
[Lenovo Xiaoxin Pad Pro 2021] AutoRotation - screen always 270° in wrong direction 3 2021-10-14 2022-11-24
Memory sanitizing 2 2021-10-04 2022-01-03
How to execute several subcommands/commands with options? 2 2020-03-19 2022-11-03
Delivering a golang-based operator in an Helm chart best-practice 7 2022-03-01 2022-11-21
Type: authentication.pp - Add ldap 0 2021-06-07 2022-12-09
dataURL is undefined when call in addedfile 5 2018-04-21 2022-11-27
investigate why ConflictingJsonCreator fails with Scala 2.13.6 2 2021-06-22 2022-12-02
Redundant OptionalParameterFilter::filter calls 2 2021-02-08 2022-12-01
FileUploader `add`, `remove` comparison logic is faulty 1 2022-02-21 2022-10-08
how to build my own heterogeneous graph? 1 2021-08-01 2022-10-10
Task list for VK_KHR_shader_integer_dot_product release 0 2021-09-03 2022-11-10
[4.0] Certain icons are shrunken (SVG scale not taken into account) 9 2022-01-24 2022-10-28
clang-format improperly formats concept definitions with Clang builtins 3 2022-02-27 2022-07-11
std.mem.bytesAsValue does not work for non-standard integer sizes 1 2022-09-24 2022-10-02
zig cc on macOS takes abnormally long due to panic 4 2022-09-23 2022-10-02
Profile form loses focus while typing the "." character on Windows 6 2021-03-03 2022-12-02
CI: K8sDemosTest Tests Star Wars Demo: DNS entry is not ready after timeout 0 2021-09-09 2022-12-05
Generate features, multiple umbrella dependency versions 3 2022-02-14 2022-12-09
[Feature] Creating a GitHub release with plugin assets 7 2019-04-02 2022-12-03
I test it in sandbox with calling putTransportDetails(PUT /fba/inbound/v0/shipments/{shipmentId}/transport) method, but return 500 error.[BUG] Documentation 1 2021-11-24 2022-08-19
Block blobs are not supported 10 2021-06-02 2022-10-25
Using Zustand in WebWorker? 2 2021-09-20 2022-10-28
Migrate from TSLint to ESLint 0 2021-03-16 2022-09-28
ppstructure识别表格类型为figure 2 2021-09-27 2022-12-04
EventStore.ClientAPI library 21.2.1 has been built with architecture=AMD64 3 2021-10-07 2022-10-11
Add PHP source snippet 1 2022-08-24 2022-11-20
The security rating exceeds the maximum value 1 2022-04-09 2022-11-24
Compatibility issue with touchpad++ 4 2021-11-23 2022-12-07
[PNI] - Subcategories - add all the subcategories 2 2021-10-14 2022-08-13
[PNI] - Subcategories - admin interface UX for product cat/subcat selection 2 2021-10-14 2022-12-09
@id attribute of case class without Option 6 2018-11-30 2022-11-28
Update README file 0 2020-03-22 2022-01-07
[Windows] The draw method doesn't trigger when changing flow direction to the GraphicsView 0 2022-01-13 2022-11-18