Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

ASIO: TimeBase treats small backward steps in systemTime as timeGetTime wraps, so stream instants race ahead and overflow after ~10 minutes

オープン
#1,393 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@chrischaps がすでに取り組んでいます。

2026年10月11日 から。

  • #1396 @chrischaps による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
rust
領域
backend

調査の方向性

Start with TimeBase::to_stream_instant in src/host/asio/stream.rs and inspect how it distinguishes clock wraparound from backward jitter. The report includes a Focusrite ASIO reproduction and suggests checking callback timestamps for large jumps. Done means genuine wraps are handled without treating small backward steps as wraps, and callback instants avoid overflow; an open pull request is already linked.

索引モデルが issue の本文から書いたものです。

説明

host - asio platform - windows

cpal: 0.18.2, asio feature. Driver: Focusrite USB ASIO 4.150.0.432, Scarlett 2i2 1st Gen, 128-frame buffers at 48 kHz, Windows 11.

What happens

TimeBase::to_stream_instant (src/host/asio/stream.rs) treats any ns < prev as a timeGetTime() wrap, and adds TIMEGETIME_WRAP_NS (about 49.7 days) to the epoch:

let prev = self.last_ns.swap(ns, Ordering::Relaxed);
let epoch = if ns < prev {
    self.epoch_ns.fetch_add(TIMEGETIME_WRAP_NS, Ordering::Relaxed) + TIMEGETIME_WRAP_NS
} else { ... };
StreamInstant::from_nanos(epoch + ns)

Focusrite's ASIOTimeInfo::systemTime jitters: from one buffer switch to the next it sometimes steps back by tens to hundreds of microseconds. Over 10 s (3,746 callbacks) I counted 78 such steps, between 17 µs and 667 µs back. The normal step between callbacks ranged from 2.4 µs to 4.7 ms, against the nominal 2.67 ms. Each backward step adds 49.7 days, so:

  • the callback instant reaches about 10 years after 10 s;
  • epoch + ns overflows u64 after about 10 minutes. In a debug build this panics on the audio thread. In release it wraps.

Around that point, the latency an app reads as playback.checked_duration_since(callback) came out as about 1.6 × 10¹⁶ µs.

Suggested fix

Only count a wrap when the step back is large: a real timeGetTime wrap goes back by nearly 2³² ms. For example:

let epoch = if ns < prev && prev - ns > TIMEGETIME_WRAP_NS / 2 { /* wrap */ } else { /* jitter: keep epoch */ };

Optionally, clamp so the instant never runs backwards (max(prev_instant, new)) to keep instants monotonic through the jitter.

Repro

Build an output stream on the Focusrite USB ASIO driver. Log info.timestamp().callback for each callback, and look for callback-to-callback deltas of about 4.29 × 10¹⁵ ns.

主要言語
Rust
スター
4k
フォーク
554
平均マージ
3日 3時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RustAudio/cpal のほかの issue

RustAudio/cpal の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。