adwaita-swift
adwaita-swift copied to clipboard
UI function isMiniaturized called in non-main thread :)
Describe the bug
Main Thread Checker: UI API called on a background thread: -[NSWindow isMiniaturized]
PID: 29621, TID: 8817659, Thread name: (none), Queue name: com.apple.root.user-initiated-qos.cooperative, QoS: 25
Backtrace:
4 libgtk-4.1.dylib 0x000000010199f410 _gdk_macos_toplevel_surface_present + 344
5 libgtk-4.1.dylib 0x000000010184a1ec gtk_window_update_toplevel + 52
6 Demo 0x00000001001a4844 $s7Adwaita6WindowV13setProperties6window8templateyAA015GTUIApplicationB0C_ACtF + 516
7 Demo 0x00000001001a58ac $s7Adwaita6WindowV6update_3app5forceyAA0B7StorageC_AA7GTUIAppCSbtF + 816
8 Demo 0x00000001001aaa44 $s7Adwaita6WindowVAA0B5SceneA2aDP6update_3app5forceyAA0B7StorageC_AA7GTUIAppCSbtFTW + 72
9 Demo 0x000000010003d5e4 $s7Adwaita3AppPAAE05setupB0AA7GTUIAppCyFZySbcfU0_ + 1724
10 Demo 0x000000010001faf8 $sSbytIegnr_SbIegy_TR + 36
11 Demo 0x000000010001fa08 $s7Adwaita13UpdateManagerO11updateViews5forceySb_tFZ + 516
12 Demo 0x0000000100019d18 $s7Adwaita5StateV11updateViews5forceySb_tFZ + 40
13 Demo 0x0000000100019ba0 $s7Adwaita5StateV12wrappedValuexvs + 252
14 Demo 0x000000010000424c $s4Demo5ModelC5itemsSayAA12NewsListItemVGvs + 160
15 Demo 0x00000001000030f0 $s4Demo5ModelC5fetch6beforeySSSg_tYaKFTY2_ + 332
16 libswift_Concurrency.dylib 0x0000000261dab2e0 _ZN5swift34runJobInEstablishedExecutorContextEPNS_3JobE + 436
17 libswift_Concurrency.dylib 0x0000000261dac470 _ZL17swift_job_runImplPN5swift3JobENS_11ExecutorRefE + 72
18 libdispatch.dylib 0x000000010133eac0 _dispatch_root_queue_drain + 404
19 libdispatch.dylib 0x000000010133f6d0 _dispatch_worker_thread2 + 188
20 libsystem_pthread.dylib 0x00000001013cfd04 _pthread_wqthread + 228
21 libsystem_pthread.dylib 0x00000001013d7a94 start_wqthread + 8
To Reproduce
Expected behavior
Update UI should be main thread :)
Additional context
Workaround :)
It is interesting that your workaround works on macOS as the code items = response.items never gets executed on Linux. What should be used to update the UI from an asynchronous context is Idle which is based on GLib.idle_add. It seems to solve your problem with NSWindow on macOS as well.
Idle {
items = response.items
}
It is interesting that your workaround works on macOS as the code
items = response.itemsnever gets executed on Linux. What should be used to update the UI from an asynchronous context is Idle which is based on GLib.idle_add. It seems to solve your problem withNSWindowon macOS as well.Idle { items = response.items }
Yes, it is also work :)
From version 1.0.0 on (which is not yet released, it's being developed in https://github.com/AparokshaUI/adwaita-swift/pull/46), calling Idle explicitly won't be required. If the update system detects an update not being executed on the main thread, it will automatically wrap with Idle. You can still call it explicitly, but it might be more convenient to omit it for new code once you build on version 1.0.0.