-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dev-compiler-sdkweb-dev-compiler
Milestone
Description
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).
Repro
- Run the flutter app below.
- Click the text field and type "aaa".
- Immediately go back to the terminal and see "Timer started" printed.
- Trigger a hot restart by clicking "R" in the terminal.
- Wait for a few seconds and see "Timer triggered" printed in the terminal.
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatefulWidget {
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
@override
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.
gustavovitor
Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dev-compiler-sdkweb-dev-compiler