Skip to content

Crash on iOS when using multiple engines spawned from FlutterEngineGroup #79335

Description

@sroddy

Steps to Reproduce

  1. Use the multiple_flutter sample
  2. Update the main.dart file, by adding this code inside the _MyHomePageState initState:
    Timer.periodic(const Duration(milliseconds: 50), (timer) {
      _incrementCounter();
    });
  1. Run in release mode
  2. tap next until you see the double flutter view controllers (3 times)
  3. go back and forth a couple of times.
  4. the app will crash
Logs
multiple-flutters.1.1.ui (9)#0	0x0000000105c48e88 in dart::Thread::top_exit_frame_info() const [inlined] at /opt/s/w/ir/cache/builder/src/third_party/dart/runtime/vm/thread.h:522
#1	0x0000000105c48e88 in dart::IsolateGroup::IncreaseMutatorCount(dart::Isolate*) [inlined] at /opt/s/w/ir/cache/builder/src/third_party/dart/runtime/vm/isolate.cc:683
#2	0x0000000105c48e80 in dart::Isolate::ScheduleThread(bool, bool) at /opt/s/w/ir/cache/builder/src/third_party/dart/runtime/vm/isolate.cc:3594
#3	0x0000000105d09d1c in dart::Thread::EnterIsolate(dart::Isolate*) [inlined] at /opt/s/w/ir/cache/builder/src/third_party/dart/runtime/vm/thread.cc:277
#4	0x0000000105d09d0c in ::Dart_EnterIsolate(Dart_Isolate) at /opt/s/w/ir/cache/builder/src/third_party/dart/runtime/vm/dart_api_impl.cc:1531
#5	0x0000000105a797fc in tonic::DartIsolateScope::DartIsolateScope(_Dart_Isolate*) [inlined] at /opt/s/w/ir/cache/builder/src/flutter/third_party/tonic/scopes/dart_isolate_scope.cc:16
#6	0x0000000105a797b4 in tonic::DartIsolateScope::DartIsolateScope(_Dart_Isolate*) at /opt/s/w/ir/cache/builder/src/flutter/third_party/tonic/scopes/dart_isolate_scope.cc:9
#7	0x0000000105a76f6c in tonic::DartPersistentValue::Clear() at /opt/s/w/ir/cache/builder/src/flutter/third_party/tonic/dart_persistent_value.cc:49
#8	0x0000000105a01d94 in std::__1::__function::__value_func<void ()>::operator()() const [inlined] at /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1860
#9	0x0000000105a01d88 in std::__1::function<void ()>::operator()() const [inlined] at /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:2419
#10	0x0000000105a01d88 in fml::MessageLoopImpl::FlushTasks(fml::FlushType) at /opt/s/w/ir/cache/builder/src/flutter/fml/message_loop_impl.cc:130
#11	0x0000000105a03bf4 in fml::MessageLoopImpl::RunExpiredTasksNow() [inlined] at /opt/s/w/ir/cache/builder/src/flutter/fml/message_loop_impl.cc:143
#12	0x0000000105a03bec in fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) at /opt/s/w/ir/cache/builder/src/flutter/fml/platform/darwin/message_loop_darwin.mm:75
#13	0x000000018044dfa0 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#14	0x000000018044dba0 in __CFRunLoopDoTimer ()
#15	0x000000018044cffc in __CFRunLoopDoTimers ()
#16	0x0000000180446ee4 in __CFRunLoopRun ()
#17	0x000000018044621c in CFRunLoopRunSpecific ()
#18	0x0000000105a03ad0 in fml::MessageLoopDarwin::Run() at /opt/s/w/ir/cache/builder/src/flutter/fml/platform/darwin/message_loop_darwin.mm:46
#19	0x0000000105a034d4 in fml::MessageLoopImpl::DoRun() [inlined] at /opt/s/w/ir/cache/builder/src/flutter/fml/message_loop_impl.cc:96
#20	0x0000000105a034b8 in fml::MessageLoop::Run() [inlined] at /opt/s/w/ir/cache/builder/src/flutter/fml/message_loop.cc:49
#21	0x0000000105a034b4 in fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0::operator()() const [inlined] at /opt/s/w/ir/cache/builder/src/flutter/fml/thread.cc:35
#22	0x0000000105a03444 in decltype(std::__1::forward<fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(fp)()) std::__1::__invoke<fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&&) [inlined] at /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:4425
#23	0x0000000105a03444 in void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>&, std::__1::__tuple_indices<>) [inlined] at /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:341
#24	0x0000000105a03444 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0> >(void*) at /opt/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:351
#25	0x00000001cbf7fcb0 in _pthread_start ()

Tested on current stable and current dev builds

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.0.3, on macOS 11.2.3 20D91 darwin-arm, locale it)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
[✓] VS Code (version 1.54.3)
[✓] Connected device (3 available)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processdependency: dartDart team may need to help usengineflutter/engine related. See also e: labels.found in release: 2.0Found to occur in 2.0has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specifically

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions