Skip to content

[Metronome] MainActor in conductor latency path causes UI-induced jitter #25

Description

@hakaru

問題

指揮モードのレイテンシパスが複数の MainActor hop を経由しており、UI 負荷で音声・配信が遅れる可能性がある。

現状のパス

Local path:

CMMotion queue
  → Task hop → ConductorMotionActor
  → AsyncStream consumer
  → ConductorService actor
  → MetronomeViewModel (@MainActor)  ← handleLocalBeat
  → MetronomeEngine actor
  → PeerMetronomeService (@MainActor) ← broadcastBeat
  → pc.broadcast

Remote receive path:

pc.commands
  → PeerMetronomeService (@MainActor) ← handleBeatCommand
  → decode
  → onBeatReceived callback
  → MetronomeViewModel (@MainActor) ← handleExternalBeat
  → MetronomeEngine actor

影響

  • MainActor は 1 フレーム 16.7ms が基準
  • UI 更新、レイアウト、ログ等で 50ms 以上詰まると 200ms リードタイム予算を大幅に圧迫
  • JSON encode/decode よりもこちらが実質的なボトルネック
  • 通常時は 200ms で足りるが、保証可能な hard budget ではなくなる

改善方針

  • BeatEvent の生成・送受信・エンジン投入は 非 MainActor パスに分離
  • UI 更新(conductorState 変更、currentBeat 等)のみ MainActor
  • PeerMetronomeService から MainActor 依存を外す、または Beat 経路だけ nonisolated で処理する

重要度

High

関連 issue

#22(hostTime 基準の修正と併せて対応すべき)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions