Serialize SharpWavtool cache file reads per path - #2442
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review comments remain, and the cache reads use the existing shared locking scheme.
Review effort: Lite
Findings: None
What changed in this PR
This pull request serializes SharpWavtool cache reads using the existing per-path locks to prevent concurrent WAV file-access failures.
Changes:
- Locks cached WAV existence checks and reads with
Renderers.GetCacheLock. - Aligns cache reads with existing resampler write locking.
| File | Description |
|---|---|
OpenUtau.Core/Classic/SharpWavtool.cs |
Adds per-cache-path synchronization around resampled audio reads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Two phrases with identical phones hash to the same res-*.wav cache path, and RenderInternal() can run concurrently. The resample write already runs under the per-path lock from Renderers.GetCacheLock(), but the read in SharpWavtool.Concatenate() did not, so a concurrent read could race a still-open write (or another reader) and throw "file is being used by another process". Guard the read with the same per-path lock, like 9138af6 did for WorldlineRenderer.
The local cacheFileLocks dictionary is a leftover from before Renderers.GetCacheLock() existed. Its wdl-* paths do not collide with paths locked elsewhere, so the shared per-path map is a drop-in replacement and removes the duplicate.
stakira
force-pushed
the
fix-sharpwavtool-cache-lock
branch
from
September 24, 2026 06:11
4ad618c to
f1ecc24
Compare
keirokeer
added a commit
to keirokeer/OpenUtau-lunai
that referenced
this pull request
Sep 25, 2026
Guard concurrent SharpWavtool reads with Renderers.GetCacheLock; drop local WorldlineRenderer lock map.
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.
Fixes the 'file is being used by another process' IOException from SharpWavtool.Concatenate (see error report, OpenUtau 0.1.570.3).
Same fix pattern as 9138af6 (WorldlineRenderer): guard the cache read with the per-path lock. Here it's simpler because the write side (ClassicRenderer.RenderInternal) already runs under the shared Renderers.GetCacheLock(outputFile) — the read just needs to take the same lock object, which serializes it against concurrent resample writes and against other phrases reading the same res-*.wav (NAudio opens with FileShare.None, so even read/read conflicts).
Notes: