Skip to content

fix: guard Transport scheduling against stopped clock and stale time#7759

Draft
ssz2605 wants to merge 2 commits into
sugarlabs:masterfrom
ssz2605:fix/transport-state-check-clean
Draft

fix: guard Transport scheduling against stopped clock and stale time#7759
ssz2605 wants to merge 2 commits into
sugarlabs:masterfrom
ssz2605:fix/transport-state-check-clean

Conversation

@ssz2605

@ssz2605 ssz2605 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

PR Category

  • Bug fix

What does this PR do?

This PR fixes three edge cases found after the Tone.Transport scheduling changes introduced in #7703.

Fixes

  • Guard against stopped Tone.Transport

    • Some widget code paths stop Tone.Transport, causing scheduled callbacks to never execute.
    • This PR checks that the transport is running before using Tone.Transport.schedule(). If not, it falls back to the existing setTimeout scheduling path.
  • Guard against suspended AudioContext

    • Tone.Transport.state returns "started" even when the AudioContext is suspended (the frozen context time still shows "started").
    • This PR adds an isClockRunning getter that checks Tone.context.state === "running" to distinguish a truly running Transport from a stuck one.
  • Prevent scheduling in the past

    • In some cases, the computed transport timestamp could be slightly behind the current transport time.
    • This PR clamps the scheduled time to the current transport position before scheduling.

These are follow-up fixes to #7703 that improve robustness without changing the scheduling improvements introduced there.

@github-actions github-actions Bot added bug fix Fixes a bug or incorrect behavior size/S Small: 10-49 lines changed area/javascript Changes to JS source files area/tests Changes to test files labels Jul 8, 2026
@ssz2605 ssz2605 force-pushed the fix/transport-state-check-clean branch from 7a6ef44 to 60cf2f7 Compare July 8, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/javascript Changes to JS source files area/tests Changes to test files bug fix Fixes a bug or incorrect behavior size/S Small: 10-49 lines changed

Projects

Development

Successfully merging this pull request may close these issues.

1 participant