NSUbiquitousKeyValueStore is locking main thread on iOS 16 beta 3

Trying to access value using NSUbiquitousKeyValueStore.default.object(forKey:) locking the main thread on iOS 16 beta 3, iPhone 11 Pro.

Is that known issue or something that only happens to me? :)

#0 0x00000001e14dc0a0 in kevent_id () #1 0x0000000104b52ebc in _dispatch_kq_poll () #2 0x0000000104b538e0 in _dispatch_event_loop_wait_for_ownership () #3 0x0000000104b3fc3c in __DISPATCH_WAIT_FOR_QUEUE__ () #4 0x0000000104b3f598 in _dispatch_sync_f_slow () #5 0x00000001a280d018 in -[NSUbiquitousKeyValueStore _synchronizeForced:notificationQueue:] ()

Is that known issue or something that only happens to me? :)

Does that matter (-:

Seriously though, the purpose of testing on beta releases is to find weird problems like this, so it’s worth filing a bug about this regardless of the answer. Make sure to include a sysdiagnose log taken immediately after reproducing the problem, because it’s likely that multiple processes are involved in this deadlock.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I'm now seeing this happening in tvOS 15.6 :(

Accepted Answer

I'm calling NSUbiquitousKeyValueStore.default.synchronize on app entering foreground like its suggested in https://developer.apple.com/documentation/foundation/nsubiquitouskeyvaluestore/1415989-synchronize, and its doing it async on another thread, then I'm trying to access an object via NSUbiquitousKeyValueStore.default.object:forKey: and the app gets stuck cause I'm doing it on main thread.

@eskimo FB11037643

Stack trace

NSUbiquitousKeyValueStore is locking main thread on iOS 16 beta 3
 
 
Q