Hang risk thread warning on Xcode

Hi,

I have been discovering the RealmSwift SDK these past few days for a personal project. Currently, I am working on an iOS 16.0 app (SwiftUI) with Xcode 14.0 beta 4 and RealmSwift 10.28.2.

Right now, I am on a simple use case where I want to let users create lists, which are synced to their account with Realm Sync. I followed the quickstart on SwiftUI guide to manage the authentication flow. So in my models, I have a “NeoList” and “NeoListGroup” that has List (so similar to items/itemsGroup in the guide).

For a quick test to see if I can manage CRUD operations, I created first a main view that shows all the created lists by the user (with the new NavigationStack API in iOS 16.0):

var body: some View {
		
		NavigationStack(path: $navigationPath) {
			VStack {
				List {
					ForEach(neoListGroup.items) { item in
						Text(item.title)
					}
				}
				.navigationDestination(for: NeoListGroup.self) { group in
					AddListView(group: group)
				}
			}
			.toolbar {
				ToolbarItem(placement: .navigationBarTrailing) {
					Button(action: {
						navigationPath.append(neoListGroup)
					}, label:  {Image(systemName: "plus")})
				}
			}
			.navigationTitle("My Lists")
		}
    }

When tapping on the + sign, the next view (AddListView) is pushed along with the group object so that I can append a new item:

struct AddListView: View {
		
	@ObservedRealmObject var group: NeoListGroup
	@State var title = "Title"
	
    var body: some View {
		VStack {
			TextField("Title", text: $title)
			Button("Send") {
				$group.items.append(NeoList(title: self.title))
			}
		}
    }
}

The code actually works, but I am getting a warning on Xcode related to a hang risk with one of the thread:

[…]/checkouts/realm-core/src/realm/util/interprocess_mutex.cpp:44: warning run: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions

Thread Performance Checker: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions

So my question is: is there an issue with my code or is that somehow linked to the beta situation with Xcode/iOS 16?

Thanks a lot.

No one with an idea of what’s happening? :sweat_smile:

Did you read Apple Developer Diagnosing Performance Issues Early? Will explain what’s happening, if not entirely why. Possibly a bug in Realm itself?

Thank you for your reply.
Yes I briefly came across this page. The warning is directly redirecting me to a specific line in the SDK linked to the semaphores, that’s where I’m lost.
I should maybe file an issue directly on Realm’s repo…

Yes, I think that’s the way to go, @Sonisan

When is the warning presented? App start? After you hit +?

Right after hitting the button ‘Send’ on the second View and thus executing $group.items.append(...)

I would suggest some troubleshooting - it may or may not provide any insight but it’s a place to start

I would temporarily replace this

Button("Send") {
   $group.items.append(NeoList(title: self.title))
}

with

Button("Send") {
   let x = $group
   print(x)
   let y = NeoList(title: self.title)
   print(y)
}

and inspect the console. Ensure the objects are what you expect.

The code itself is working as intended, correct objects are showing up.
By the way, I have also opened an issue on the repository: https://github.com/realm/realm-swift/issues/7902