From 0254367cd5df387eeff4b4486c449886e672e9f6 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Thu, 6 Jun 2024 14:50:21 -0700 Subject: [PATCH] fix missing clock on independent time mode change --- src/api/time/IndependentTimeContext.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/api/time/IndependentTimeContext.js b/src/api/time/IndependentTimeContext.js index 5f5b3b139b..a1c8369e70 100644 --- a/src/api/time/IndependentTimeContext.js +++ b/src/api/time/IndependentTimeContext.js @@ -324,8 +324,16 @@ class IndependentTimeContext extends TimeContext { return this.upstreamTimeContext.setMode(...arguments); } - if (mode === MODES.realtime && this.activeClock === undefined) { - throw `Unknown clock. Has a clock been registered with 'addClock'?`; + if (mode === MODES.realtime) { + // TODO: This should probably happen up front in creating an independent time context + // TODO: not just in time every time setMode is called + if (this.activeClock === undefined) { + this.activeClock = this.globalTimeContext.getClock(); + } + + if (this.activeClock === undefined) { + throw `Unknown clock. Has a clock been registered with 'addClock'?`; + } } if (mode !== this.mode) {