Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 29ba52d

Browse files
TedSandernshahan
authored andcommitted
Bring back the re-entry flag for DomService since performance problems have been encountered with the value flipped. We won't be flipping any other values, but will give the flag back to unblock them.
PiperOrigin-RevId: 208876710
1 parent 85cf0a3 commit 29ba52d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/utils/browser/dom_service/dom_service.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ typedef Future<num> RequestAnimationFrame();
2323
/// Utility class to synchronize DOM operations across components, e.g. to check
2424
/// changes in the layout after a UI update or application event.
2525
class DomService {
26+
/// Whether to execute functions scheduled within [Zone.current].
27+
///
28+
/// This is the expected behavior and contract of Dart applications, but is
29+
/// not applied automatically to every callback (only to Futures and Streams).
30+
/// Eventually, this flag will be flipped to `true`, and deleted (all code
31+
/// must use this behavior).
32+
///
33+
/// By flipping this to `false`, it means:
34+
/// * [Zone.current] will be not be restored when the callbacks are executed.
35+
/// * AngularDart (or any parent zone) will not know about the change.
36+
@Deprecated('For legacy reasons. DO NOT USE unless you talk to AngularDart.')
37+
static bool maintainZoneOnCallbacks = true;
38+
2639
static const _TURN_DONE_EVENT_TYPE = 'doms-turn';
2740

2841
/// The maximum time the idle scheduler waits between events.
@@ -241,7 +254,9 @@ class DomService {
241254
}
242255

243256
void _scheduleInQueue(DomReadWriteFn fn, List<DomReadWriteFn> queue) {
244-
fn = Zone.current.bindCallback(fn);
257+
if (maintainZoneOnCallbacks) {
258+
fn = Zone.current.bindCallback(fn);
259+
}
245260
queue.add(fn);
246261
_scheduleProcessQueue();
247262
}

0 commit comments

Comments
 (0)