Dart-code: Crashing during hot reload when --track-widget-creation is enabled

Created on 3 Aug 2018  Â·  11Comments  Â·  Source: Dart-Code/Dart-Code

vscode extension Dart was upgraded to 2.17.0. Running with "Start Debugging F5". Using iOS simulator, iPhone X, iOS 11.1. Any minor change, even adding in whitespace, and Saving (cmd-s), causing a hot reload, results in the following

../../third_party/dart/runtime/vm/object.h: 8847: error: Handle check failed: saw Instance of 'HomePage' expected Closure
Dumping native stack trace for thread 5c03
[0x00000001008ac0d4] dart::Profiler::DumpStackTrace(void*)
[0x00000001008ac0d4] dart::Profiler::DumpStackTrace(void*)
[0x0000000100b20142] dart::Assert::Fail(char const*, ...)
[0x0000000100903f3b] dart::DRT_InvokeClosureNoSuchMethod(dart::NativeArguments)
[0x000000011678085b] [Stub] CallToRuntime
[0x0000000116782dc4] [Stub] CallClosureNoSuchMethod
[0x000000011f3be9cb] new HomePage
[0x000000011f3be69a] MyApp.build
[0x000000011c179714] StatelessElement.build
[0x000000011c178a5e] ComponentElement.performRebuild
[0x000000011c177bc1] Element.rebuild
[0x000000011c16b1d0] BuildOwner.buildScope
[0x00000001169c1370] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame
[0x00000001169c0f68] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback
[0x00000001169c0d7f] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback
[0x00000001188e68b5] _Closure.call
[0x00000001169c0796] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
[0x000000011c480b28] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
[0x000000011ca2680b] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
[0x00000001188c0512] _Closure.call
[0x000000011cf7f96d] Timer._createTimer.<anonymous closure>
[0x00000001188e68b5] _Closure.call
[0x000000011cf7ea75] _Timer._runTimers
[0x00000001169bdc32] _Timer._handleMessage
[0x00000001169bd73b] _Timer._handleMessage
[0x00000001188e68b5] _Closure.call
[0x00000001188e67bc] _RawReceivePortImpl._handleMessage
[0x0000000116780ce3] [Stub] InvokeDartCode
[0x00000001007637c9] dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
[0x0000000100766f0e] dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
[0x0000000100792ed6] dart::IsolateMessageHandler::HandleMessage(dart::Message*)
[0x00000001007bdfee] dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
[0x00000001007be0f0] dart::MessageHandler::HandleNextMessage()
[0x0000000100aa0175] Dart_HandleMessage
[0x00000001005ef285] tonic::DartMessageHandler::OnHandleMessage(tonic::DartState*)
[0x000000010027c222] fml::MessageLoopImpl::RunExpiredTasks()
[0x000000010027ef1a] fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*)
[0x00000001028832a4] __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
[0x0000000102882f62] __CFRunLoopDoTimer
[0x0000000102882b1a] __CFRunLoopDoTimers
[0x000000010287a534] __CFRunLoopRun
[0x00000001028799b9] CFRunLoopRunSpecific
[0x000000010027f06b] fml::MessageLoopDarwin::Run()
[0x000000010027c359] fml::MessageLoopImpl::DoRun()
[0x000000010027ea70] 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*, void*)
[0x0000000107ec8661] _pthread_body
[0x0000000107ec850d] _pthread_body
[0x0000000107ec7bf9] thread_start
Lost connection to device.
-- End of DumpStackTrace
Exited (sigterm)

Also logged here https://github.com/flutter/flutter/issues/20191. Could this be related to the "Inspect Flutter Widget" feature added?

fixed in dart / flutter

Most helpful comment

That's the only thing I could think could have caused this to appear in this version, since there's not really anything else that'd affect how flutter run behaves.

Can you try setting "dart.flutterTrackWidgetCreation": false in your VS Code settings and see if that fixes things?

All 11 comments

That's the only thing I could think could have caused this to appear in this version, since there's not really anything else that'd affect how flutter run behaves.

Can you try setting "dart.flutterTrackWidgetCreation": false in your VS Code settings and see if that fixes things?

The "dart.flutterTrackWidgetCreation": false setting fixed it. Thanks @DanTup

Yes, this happens in a new project too.

VSCode: 1.25.1
Dart extension: 2.17.0

Flutter doctor

I haven't set this machine up for Android dev yet.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale en-ZA)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    ✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] iOS toolchain - develop for iOS devices (Xcode 9.1)
[✓] Android Studio (version 3.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.25.1)
[✓] Connected devices (2 available)

! Doctor found issues in 2 categories.

Thanks; I'll try and repro in the morning. If you're able to check if it happens on dev or master channels, that'd be useful to know too.

I'm going to disable this by default (#1138) while this is investigated. It's possible a flutter clean will fix it if you want to try that.

I've pushed out v2.17.1 which disables this by default while it's investigated. You may wish to try turning it on and doing flutter clean. I'll re-enable by default once it works reliably.

Leaving this issue open to track the proper fix.

@DanTup The same problem occurs in Android studio 3 (macOS). I wonder how I set "dart.flutterTrackWidgetCreation": false in Android Studio 3.

@Narumikun Thanks for the info. I believe there is a way to disable track-widget-creation in IntelliJ but I'm not sure where it is but I'd guess somewhere in the Flutter settings in IntelliJ - I don't know if it's called "Track Widget Creation" or just something related to enabling the Widget Inspector. @devoncarew or @jacob314 may be able to confirm.

Yup, there is a way - from the preferences, Languages and frameworks, Flutter, you can disable the flag to track widget creation.

@Narumikun The same problem occurs in Android studio 3 (macOS). I wonder how I set "dart.flutterTrackWidgetCreation": false in Android Studio 3.

The same problem occurs in Android studio 3 (macOS). I wonder how I set "dart.flutterTrackWidgetCreation": false in Android Studio 3.
halo you solve it?The same problem occurs.

@LJame the crash that this is case referred to was actually fixed prior to Flutter 1.0 (so we re-enabled it by default in #1277) though I forgot to resolve this. If you're on Flutter >= 1.0 and seeing crashes only when track-widget-creation is enabled, would you mind opening at https://github.com/flutter/flutter?

If you do need to disable it, the instructions Devon gave above apply to both IntelliJ and Android Studio:

screenshot 2019-01-09 at 9 45 27 am

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings