Make rig saves non-blocking (background disk I/O)
Save/delete/eraseAll now update the in-memory entries on the main actor immediately and run the file write/delete — including NSFileCoordinator — on a serial background queue, removing the UI stall the synchronous coordinated write caused (especially on the iCloud path). - Encoding stays synchronous so encode errors still surface to the caller; only the disk write is deferred (logs on failure). - File-system helpers and coordinated I/O are now nonisolated static so the background queue can call them without touching actor state. - Add flushPendingWrites() to drain the queue; called by tests asserting on-disk state and by both app shells at termination / background. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,9 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
/// Persists the current rig. Call when the app moves to the background.
|
||||
func save() {
|
||||
RigStore.save(shoeGaze)
|
||||
// Flush any in-flight background rig-library writes while we still have time in the
|
||||
// background.
|
||||
library.flushPendingWrites()
|
||||
}
|
||||
|
||||
// MARK: - Audio session / engine construction
|
||||
|
||||
Reference in New Issue
Block a user