| Index: sdk/lib/html/dart2js/html_dart2js.dart
|
| diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
|
| index 018b8aa93a10c2ead94f064616a433dc50934513..06214ba0e495c06983329e4ede952ecc08942a29 100644
|
| --- a/sdk/lib/html/dart2js/html_dart2js.dart
|
| +++ b/sdk/lib/html/dart2js/html_dart2js.dart
|
| @@ -32785,29 +32785,45 @@ class _PureIsolateTimer implements Timer {
|
| final ReceivePort _port = new ReceivePort();
|
| SendPort _sendPort; // Effectively final.
|
|
|
| + static SendPort _SEND_PORT;
|
| +
|
| _PureIsolateTimer(int milliSeconds, callback, repeating) {
|
| _sendPort = _port.toSendPort();
|
| _port.receive((msg, replyTo) {
|
| assert(msg == _TIMER_PING);
|
| - assert(replyTo == _HELPER_ISOLATE_PORT);
|
| callback(this);
|
| if (!repeating) _cancel();
|
| });
|
| - _HELPER_ISOLATE_PORT.then((port) {
|
| - port.send([_NEW_TIMER, milliSeconds, repeating], _sendPort);
|
| - });
|
| +
|
| + _send([_NEW_TIMER, milliSeconds, repeating]);
|
| }
|
|
|
| void cancel() {
|
| _cancel();
|
| - _HELPER_ISOLATE_PORT.then((port) {
|
| - port.send([_CANCEL_TIMER], _sendPort);
|
| - });
|
| + _send([_CANCEL_TIMER]);
|
| }
|
|
|
| void _cancel() {
|
| _port.close();
|
| }
|
| +
|
| + // Tricky part.
|
| + // Once _HELPER_ISOLATE_PORT gets resolved, it will still delay in .then
|
| + // and to delay Timer.run is used. However, Timer.run will try to register
|
| + // another Timer and here we got stuck: event cannot be posted as then
|
| + // callback is not executed because it's delayed with timer.
|
| + // Therefore once future is resolved, it's unsafe to call .then on it
|
| + // in Timer code.
|
| + _send(msg) {
|
| + if (_SEND_PORT != null) {
|
| + _SEND_PORT.send(msg, _sendPort);
|
| + } else {
|
| + _HELPER_ISOLATE_PORT.then((port) {
|
| + _SEND_PORT = port;
|
| + _SEND_PORT.send(msg, _sendPort);
|
| + });
|
| + }
|
| + }
|
| }
|
|
|
| get _pureIsolateTimerFactoryClosure =>
|
|
|