Jay
(Jason Wooten)
August 6, 2023, 4:22pm
1
We recently starting getting a crash while working on our project, which is macOS Realm Partition based (currently).
I created a new XCode project which only two functions (outside of authenticating) and the issue duplicates but is somewhat intermittent.
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
There is a git on a similar issue
opened 01:30AM - 04 Aug 22 UTC
T-Bug
O-Community
Frequency:Always
Repro:Always
Encryption:Off
SDK-Use:Sync
### How frequently does the bug occur?
All the time
### Description
Currently… , I am working on an **iOS 16.0 app (SwiftUI)** with **Xcode 14.0 beta 4** and **RealmSwift 10.28.3**.
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. In my models, I have a “NeoList” and “NeoListGroup” that has a List<NeoList> property (so similar to items/itemsGroup in the guide).
When adding an item to the List, Xcode triggers a warning from the Thread Performance Checker.
Despite the warning, the code is working as intended.
### Stacktrace & log output
```shell
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
PID: 1494, TID: 18792
Backtrace
=================================================================
3 List Creator 0x00000001056410b0 _ZN5realm4util14SemaphoreMutex4lockEv + 32
4 List Creator 0x0000000104e9abf8 _ZNSt3__111unique_lockIN5realm4util14SemaphoreMutexEEC2ERS3_ + 60
5 List Creator 0x0000000104e9ab78 _ZNSt3__111unique_lockIN5realm4util14SemaphoreMutexEEC1ERS3_ + 36
6 List Creator 0x0000000104e8dd0c _ZN5realm4util17InterprocessMutex4lockEv + 48
7 List Creator 0x0000000104e8c364 _ZN5realm2DB14do_begin_writeEv + 80
8 List Creator 0x0000000104e90860 _ZN5realm2DB17AsyncCommitHelper20blocking_begin_writeEv + 288
9 List Creator 0x0000000104e90724 _ZN5realm2DB29do_begin_possibly_async_writeEv + 56
10 List Creator 0x00000001055c349c _ZN5realm11Transaction18acquire_write_lockEv + 116
11 List Creator 0x00000001050a9104 _ZN5realm11Transaction16promote_to_writeIN12_GLOBAL__N_122KVOTransactLogObserverEEEbPT_b + 228
12 List Creator 0x00000001050a8d10 _ZZN5realm5_impl11transaction5beginERKNSt3__110shared_ptrINS_11TransactionEEEPNS_14BindingContextERNS0_15NotifierPackageEENK3$_2clIJPN12_GLOBAL__N_122KVOTransactLogObserverEEEEDaDpOT_ + 68
13 List Creator 0x0000000105093ff4 _ZN12_GLOBAL__N_126advance_with_notificationsIZN5realm5_impl11transaction5beginERKNSt3__110shared_ptrINS1_11TransactionEEEPNS1_14BindingContextERNS2_15NotifierPackageEE3$_2EEvSB_S9_OT_SD_ + 764
14 List Creator 0x0000000105093cec _ZN5realm5_impl11transaction5beginERKNSt3__110shared_ptrINS_11TransactionEEEPNS_14BindingContextERNS0_15NotifierPackageE + 52
15 List Creator 0x0000000105063f24 _ZN5realm5_impl16RealmCoordinator16promote_to_writeERNS_5RealmE + 236
16 List Creator 0x0000000105194e64 _ZN5realm5Realm20do_begin_transactionEv + 56
17 List Creator 0x000000010519662c _ZN5realm5Realm17begin_transactionEv + 260
18 List Creator 0x0000000104c3647c -[RLMRealm beginWriteTransactionWithError:] + 40
19 List Creator 0x0000000104c36448 -[RLMRealm beginWriteTransaction] + 36
20 List Creator 0x0000000104d80a3c $s10RealmSwift0A0V10beginWriteyyF + 48
21 List Creator 0x0000000104d807a8 $s10RealmSwift0A0V5write16withoutNotifying_xSaySo20RLMNotificationTokenCG_xyKXEtKlF + 268
22 List Creator 0x0000000104da0378 $s10RealmSwift9safeWrite33_06F2B43D1E2DA64D3C5AC1DADA9F5BA7LLyyx_yxXEtAA14ThreadConfinedRzlF + 1024
23 List Creator 0x0000000104dafcb8 $s10RealmSwift15BoundCollectionPAASo13RLMObjectBaseC7ElementRczAA14ThreadConfinedAGRQAA4ListCyAGG5ValueRtzrlE6appendyyAGF + 1508
24 List Creator 0x000000010495c318 $s12List_Creator03AddA4ViewV4bodyQrvg7SwiftUI05TupleD0VyAE9TextFieldVyAE0I0VG_AE6ToggleVyAKGAE6ButtonVyAKGArE10AsyncImageVyAE0N0VGSgtGyXEfU_yycfU0_ + 1084
25 SwiftUI 0x000000010d204ed4 OUTLINED_FUNCTION_39 + 3916
26 SwiftUI 0x000000010d1b632c OUTLINED_FUNCTION_30 + 4452
27 SwiftUI 0x000000010d11716c OUTLINED_FUNCTION_86 + 6436
28 SwiftUI 0x000000010d2b2710 OUTLINED_FUNCTION_6 + 11616
29 SwiftUI 0x000000010d2b430c OUTLINED_FUNCTION_6 + 18780
30 UIKitCore 0x00000001092ac150 -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:deselectPrevious:performCustomSelectionAction:] + 1056
31 UIKitCore 0x00000001092d6f24 -[UICollectionView touchesEnded:withEvent:] + 476
32 UIKitCore 0x0000000109ac8714 forwardTouchMethod + 264
33 UIKitCore 0x0000000109ac8714 forwardTouchMethod + 264
34 UIKitCore 0x0000000109ac8714 forwardTouchMethod + 264
35 UIKitCore 0x000000010965289c _UIGestureEnvironmentUpdate + 5876
36 UIKitCore 0x0000000109650ec8 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 276
37 UIKitCore 0x0000000109650c44 -[UIGestureEnvironment _updateForEvent:window:] + 156
38 UIKitCore 0x0000000109ad76b8 -[UIWindow sendEvent:] + 3168
39 UIKitCore 0x0000000109ab58ac -[UIApplication sendEvent:] + 692
40 UIKitCore 0x0000000109b314ac __dispatchPreprocessedEventFromEventQueue + 6824
41 UIKitCore 0x0000000109b33110 __processEventQueue + 5612
42 UIKitCore 0x0000000109b2c0b0 __eventFetcherSourceCallback + 220
43 CoreFoundation 0x00000001803719b8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
44 CoreFoundation 0x0000000180371900 __CFRunLoopDoSource0 + 172
45 CoreFoundation 0x0000000180371070 __CFRunLoopDoSources0 + 232
46 CoreFoundation 0x000000018036b7b0 __CFRunLoopRun + 756
47 CoreFoundation 0x000000018036b0a4 CFRunLoopRunSpecific + 584
48 GraphicsServices 0x00000001892dcc8c GSEventRunModal + 160
49 UIKitCore 0x0000000109a9be80 -[UIApplication _run] + 868
50 UIKitCore 0x0000000109a9fe28 UIApplicationMain + 124
51 SwiftUI 0x000000010d6effdc OUTLINED_FUNCTION_51 + 496
52 SwiftUI 0x000000010d6efe84 OUTLINED_FUNCTION_51 + 152
53 SwiftUI 0x000000010cee44c4 OUTLINED_FUNCTION_6 + 92
54 List Creator 0x0000000104930f58 $s12List_Creator0a1_B3AppV5$mainyyFZ + 40
55 List Creator 0x0000000104931000 main + 12
```
### Can you reproduce the bug?
Yes, always
### Reproduction Steps
Create a first view displaying the items in the list:
```
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")
}
}
```
The + button will lead to a second view where a new item can be appended to the list:
```
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 warning triggers exactly when hitting the button Send.
### Version
10.28.3
### What SDK flavour are you using?
MongoDB Realm (i.e. Sync, auth, functions)
### Are you using encryption?
No, not using encryption
### Platform OS and version(s)
macOS 12.5
### Build environment
Xcode version: Xcode 14 (beta 4)
Dependency manager and version: Realm 10.28.3, RealmDatabase 12.3.0
My total code in the app is straight from the Partition Documentation
@MainActor
func getRealm() async throws -> Realm {
let user = try await getUser()
let partitionValue = "my_partition"
let config = user.configuration(partitionValue: partitionValue)
let realm = try await Realm(configuration: config)
return realm
}
and then a button to write a TaskClass object
func handleTestButton0() {
let t = TaskClass()
t.name = "some random task"
t._partitionKey = "my_partition"
Task {
let realm = try await getRealm()
try! realm.write {
realm.add(t)
}
}
}
The end result is the data is written to Realm and Sync’s but crashes add the realm.add(t) line.
The git issue has not been touched in over a year and is still open and unresolved - is this still the appropriate “fix”?
What you need to do is go to Product > Scheme > Edit Scheme to display the scheme editor. Select the Run schemes, navigate to the Diagnostics section, and unselect the Thread Performance Checker tool checkbox
XCode 14.3.1
macOS 13.4.1
Realm 10.41.0
pods/cocoapods fully updated, deintegrated, pod install all successful
project cleaned, Mac Studio restarted tried again
… problem persists
Jay