Skip to content

Fix freeze when double-clicking timeline with a midi track present - #11696

Merged
kryksyh merged 2 commits into
audacity:audacity3from
kryksyh:fix_a_midi_track_freeze
Aug 19, 2026
Merged

kryksyh merged 2 commits into
audacity:audacity3from
kryksyh:fix_a_midi_track_freeze

Conversation

@kryksyh

@kryksyh kryksyh commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Resolves: #11664
Resolves: #2359

When the playback is restarted with a click on a timeline, it stops all streams first. During stop we wait for all midi events to be drained.

But if the playback is restarted twice in quick succession, the first midi playback doesnt have time to fully initialize which results in a 1000s wait. Introduced in #1637

Call stack:

(anonymous namespace)::MIDIPlay::MidiTime() (libraries/lib-note-track/MIDIPlay.cpp:1059)
(anonymous namespace)::MIDIPlay::StopOtherStream() (libraries/lib-note-track/MIDIPlay.cpp:760)
AudioIO::StopStream() (libraries/lib-audio-io/AudioIO.cpp:1535)
ProjectAudioManager::Stop(bool) (src/ProjectAudioManager.cpp:531)
AdornedRulerPanel::StartQPPlay(bool, bool, double const*) (src/AdornedRulerPanel.cpp:2111)
AdornedRulerPanel::CommonRulerHandle::StartPlay(AudacityProject&, wxMouseEvent const&) (src/AdornedRulerPanel.cpp:192)
AdornedRulerPanel::PlayRegionAdjustingHandle::Release(TrackPanelMouseEvent const&, AudacityProject*, wxWindow*) (src/AdornedRulerPanel.cpp:296)
CellularPanel::OnMouseEvent(wxMouseEvent&) (src/CellularPanel.cpp:814)
wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const (.conan2/p/b/wxwid222b45a67b428/b/src/src/common/appbase.cpp:657)
wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const 
  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@kryksyh kryksyh self-assigned this Aug 17, 2026
@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 360a1217-b8bb-4bfc-99f6-383dc56411c3

📥 Commits

Reviewing files that changed from the base of the PR and between 36b8596125ecc250d8a3e4db725649c30ea8b582 and 4007058.

📒 Files selected for processing (1)
  • libraries/lib-audio-io/AudioIO.cpp

📝 Walkthrough

Walkthrough

AudioIO::StartStream passes the requested start time to extensions, or t0 when no start time is provided. MIDIPlay uses this value for warped timing, iterator initialization, audio-time calculation, and initial callback timing. StopOtherStream sends all-notes-off and waits for queued MIDI messages only after an audio callback occurs. AudioIO::GetBestRate checks the current ASIO device rate before cached or supported rates. A blank line was added in Iterator::OutputEvent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AudioIO
  participant MIDIPlay
  participant MIDIIterator
  AudioIO->>MIDIPlay: Pass requested start time
  MIDIPlay->>MIDIPlay: Compute warped start time
  MIDIPlay->>MIDIIterator: Initialize at requested start time
  MIDIPlay->>MIDIPlay: Use warped time for callback timing
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the freeze fix caused by double-clicking the timeline with a MIDI track present.
Description check ✅ Passed The description includes linked issues, motivation, change summary, checklist completion, and QA status.
Linked Issues check ✅ Passed The changes address the freeze in #11664 and pass the requested start position to fix MIDI playback in #2359.
Out of Scope Changes check ✅ Passed The changes are limited to MIDI startup timing, stream initialization, and safe stopping behavior related to the linked issues.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ianalarina ianalarina linked an issue Aug 17, 2026 that may be closed by this pull request
@kryksyh
kryksyh force-pushed the fix_a_midi_track_freeze branch from dce9d6a to f5f82a4 Compare August 18, 2026 16:11
@kryksyh kryksyh linked an issue Aug 18, 2026 that may be closed by this pull request
@kryksyh
kryksyh force-pushed the fix_a_midi_track_freeze branch from f5f82a4 to 36b8596 Compare August 18, 2026 21:25
@kryksyh
kryksyh force-pushed the fix_a_midi_track_freeze branch from 36b8596 to 4007058 Compare August 19, 2026 08:20
@kryksyh
kryksyh merged commit d320f6f into audacity:audacity3 Aug 19, 2026
7 of 8 checks passed
@kryksyh
kryksyh deleted the fix_a_midi_track_freeze branch August 19, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash upon double-clicking the timeline (Zeitliste) MIDI playback starts from beginning regardless of cursor position

2 participants