From b2c354a32c661e78cb7761aeab1d8489c875201c Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 22 Jun 2022 19:11:06 -0700 Subject: [PATCH] Serialize persistent store update to main thread This needs to be called on the main thread, as something may or may not be enumerating over the data while this thread decides to call it. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistLoader.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index ea4108518..3cc326f23 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -751,7 +751,9 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); }); } - [playlistController commitPersistentStore]; + dispatch_sync_reentrant(dispatch_get_main_queue(), ^{ + [self->playlistController commitPersistentStore]; + }); [playlistController performSelectorOnMainThread:@selector(updateTotalTime) withObject:nil waitUntilDone:NO];