Fix GUI freeze on stop and prevent corrupted XDF footers - #146
Open
sappelhoff wants to merge 2 commits into
Open
Fix GUI freeze on stop and prevent corrupted XDF footers#146sappelhoff wants to merge 2 commits into
sappelhoff wants to merge 2 commits into
Conversation
sappelhoff
force-pushed
the
fix/instant-shutdown-and-cv
branch
from
August 27, 2026 08:24
01f99fe to
c5d3038
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When stopping a recording,
recording::~recording()executes synchronously on the Qt UI thread. Becauserecord_offsets()used an uninterruptible 5-second sleep (std::this_thread::sleep_for(offset_interval)) andboundary_threadjoined with a 15-second timeout, the Qt event loop blocked, causing Windows to mark the window as "(Not Responding)" for 5–15+ seconds. Forcefully terminating the application when frozen aborted before stream footers could be written, resulting in corrupted XDF footers and truncated files.Solution
std::condition_variable shutdown_cv_inrecordingand replacedstd::this_thread::sleep_for/sleep_untilacrossrecord_offsets(),record_boundaries(), andtyped_transfer_loop()with condition variable waits. When shutdown is triggered, all worker threads wake up in < 1 ms.lsl::stream_inletinstances and invokein->close_stream()on shutdown to abort any blocking TCP socket calls or unreachable remote network routes immediately.in->pull_sample()timeout from 4.0s to 0.1s so silent or late-starting streams checkshutdown_rapidly.scripts/test_recording_teardown.pyto verify thatLabRecorderCLIstops in < 0.5s and produces fully valid, uncorrupted XDF files with intact footers.Verification
.xdfparses cleanly withpyxdf.