From acc777c2678746681de37c06df617bd9f5f29f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Cs=C3=A1sz=C3=A1r?= Date: Sun, 1 Sep 2024 09:41:41 +0200 Subject: [PATCH] Unclamp setTimeout in Safari Fixes #2008 wrapping setTimeout in postMessage is a trade-off between * slowdown due to postMessage (slow on Safari) * speedup due to no setTimeout clamping (can be severe on Safari) --- src/core/ClearStack.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ClearStack.js b/src/core/ClearStack.js index 29ec3688..3ae237f0 100644 --- a/src/core/ClearStack.js +++ b/src/core/ClearStack.js @@ -2,7 +2,8 @@ getJasmineRequireObj().clearStack = function(j$) { const maxInlineCallCount = 10; function browserQueueMicrotaskImpl(global) { - const { setTimeout, queueMicrotask } = global; + const unclampedSetTimeout = getUnclampedSetTimeout(global); + const { queueMicrotask } = global; let currentCallCount = 0; return function clearStack(fn) { currentCallCount++; @@ -11,7 +12,7 @@ getJasmineRequireObj().clearStack = function(j$) { queueMicrotask(fn); } else { currentCallCount = 0; - setTimeout(fn); + unclampedSetTimeout(fn); } }; }