DDC “hot restart” not clearing timers

DDC doesn’t seem to be clearing timers and microtasks on hot restart. This is causing problems in flutter web (e.g. flutter/flutter#41284).


  1. Run the flutter app below.
  2. Click the text field and type “aaa”.
  3. Immediately go back to the terminal and see “Timer started” printed.
  4. Trigger a hot restart by clicking “R” in the terminal.
  5. Wait for a few seconds and see “Timer triggered” printed in the terminal.
import 'dart:async';

import 'package:flutter/material.dart';

void main() {

class App extends StatefulWidget {
  _AppState createState() => _AppState();

class _AppState extends State<App> {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: TextField(
          onChanged: (String text) {
            if (text == 'aaa') {
              print('Timer started');
              Timer(const Duration(seconds: 10), () {
                print('Timer triggered');

Behavior on Android

In step 5, “Time triggered” won’t be printed because the timer has been canceled (or as I was told, the whole Dart isolate was torn down, so all timers are gone with it).

Behavior on web

(using flutter run -d chrome)

In step 5, “Time triggered” is printed because timers aren’t being cleared by DDC.

You’ll also notice errors like NoSuchMethodError: invalid member on null: 'findRenderObject'. These are happening because timers aren’t cleared.

cc @vsmenon @jakemac53 @jonahwilliams

Author: Fantashit

1 thought on “DDC “hot restart” not clearing timers

Comments are closed.