MusicLibraryRequests are much slower on macOS/Mac Catalyst than on iOS

I'm experiencing this issue on Sonoma beta 7 and Xcode 15 beta 8:

FB13094612 -- MusicLibraryRequests are way slower on macOS than iOS

The following code has massive speed differences on macOS than iOS, with macOS taking 3-7 seconds for each request and iOS taking 0.1 seconds or less.

  let start = Date()
        
        var artistAlbumRequest = MusicLibraryRequest<Album>.init()
        artistAlbumRequest.filter(matching: \.artistName, equalTo: "Ratboys")
        
        print("Searching artist Ratboys")

        
        let artistAlbums = try! await artistAlbumRequest.response()
        
        let name = artistAlbums.items.first!.title
        let id = artistAlbums.items.first!.id
        
        let end = Date()
    
        print("It took \(end.timeIntervalSince1970 - start.timeIntervalSince1970) to complete the artist request. \(artistAlbums.items.count) returned")
        print(artistAlbums.items)


        let start2 = Date()
        

        
        print("Searching by title: \(name)")
        
        var albumNameRequest = MusicLibraryRequest<Album>.init()
        albumNameRequest.filter(matching: \.title, equalTo: name)
        
        let nameAlbum = try! await albumNameRequest.response()
     
        
        let end2 = Date()
        
        print("It took \(end2.timeIntervalSince1970 - start2.timeIntervalSince1970) to complete this request")
        print(nameAlbum.items)
        
        
        print("Searching by ID")
        
        let start3 = Date()
        
        
        var albumIDRequest = MusicLibraryRequest<Album>.init()
        albumIDRequest.filter(matching: \.id, equalTo: id)
        
        let idalbum = try! await albumIDRequest.response()

        
        let end3 = Date()
        
        print("It took \(end3.timeIntervalSince1970 - start3.timeIntervalSince1970) to complete this request")
        
        print(idalbum.items)

Awaiting the three requests takes 0.085, 0.019, and 0.102 seconds respectively on iOS. However, they take 7.10, 0.1, and 3.3 seconds on macOS. The second one only returns so quickly because of a bug where matching on title returns no results (see FB13094588)

This makes it very difficult to provide a good experience when starting music playback, because it takes several seconds between the user selecting an album and it starting.

MusicLibraryRequests are much slower on macOS/Mac Catalyst than on iOS
 
 
Q