Can't open iCloud UIDocument when Files.App has SMB server connection and no network.

Normally iCloud documents can be opened when off-line. However, with ios 13, if you have an active SMB server connection in the Files App, and then the network is disabled, calls to UIDocument initWithFileURL: block indefinitely while attempting to lookup file attributes.


Note calls to [UIDocument openWithCompletionHandler:], [NSURL getResourceValue:forKey:error:] and ExternalProviderPrepareValues.


Backtrace:


Thread 1 name:  Dispatch queue: UIDocument File Access
Thread 1:
0   libsystem_kernel.dylib        0x00000001b493a784 mach_msg_trap + 8
1   libsystem_kernel.dylib        0x00000001b4939ba8 mach_msg + 76
2   libdispatch.dylib             0x00000001b482bf10 _dispatch_mach_send_and_wait_for_reply + 552
3   libdispatch.dylib             0x00000001b482c304 dispatch_mach_send_with_result_and_wait_for_reply + 56
4   libxpc.dylib                  0x00000001b476b96c xpc_connection_send_message_with_reply_sync + 240
5   Foundation                    0x00000001b507a398 __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16
6   Foundation                    0x00000001b4e40834 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2668
7   Foundation                    0x00000001b4e6faa8 -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:arg3:] + 148
8   Foundation                    0x00000001b50814a4 _NSXPCDistantObjectSimpleMessageSend3 + 48
9   FileProvider                  0x00000001c93b6ba4 -[FPDaemonConnection valuesForAttributes:forItemAtURL:error:] + 428
10  FileProviderOverride          0x000000010e5b9f14 0x10e5b8000 + 7956
11  CoreFoundation                0x00000001b4b7cf14 __invoking___ + 148
12  CoreFoundation                0x00000001b4a46098 -[NSInvocation invoke] + 400
13  CoreFoundation                0x00000001b4a46cc0 -[NSInvocation invokeWithTarget:] + 80
14  FileProvider                  0x00000001c9374db8 -[FPFrameworkOverridesIterator callNextOverrides] + 468
15  FileProvider                  0x00000001c9374f58 -[FPFrameworkOverridesIterator forwardInvocation:] + 96
16  CoreFoundation                0x00000001b4b7a7d8 ___forwarding___ + 680
17  CoreFoundation                0x00000001b4b7cd60 _CF_forwarding_prep_0 + 96
18  FileProvider                  0x00000001c9394cc0 FPCFCopyAttributeValuesForItem + 300
19  CoreServicesInternal          0x00000001b5ebba98 CopyFromFileProvider+ 154264 (__CFURL const*, void const*, void const**, __CFError**) + 88
20  CoreServicesInternal          0x00000001b5ebbe40 ExternalProviderPrepareValues+ 155200 (__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 376
21  CoreServicesInternal          0x00000001b5ea8cc0 prepareValuesForBitmap+ 76992 (__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 376
22  CoreServicesInternal          0x00000001b5ea69d4 _FSURLCopyResourcePropertyForKeyInternal+ 68052 (__CFURL const*, __CFString const*, void*, void*, __CFError**, unsigned char) + 220
23  CoreFoundation                0x00000001b4b40768 CFURLCopyResourcePropertyForKey + 140
24  CoreFoundation                0x00000001b4a4d190 -[NSURL getResourceValue:forKey:error:] + 120
25  Foundation                    0x00000001b4ec43a0 +[NSFileVersion unresolvedConflictVersionsOfItemAtURL:] + 124
26  UIKitCore                     0x00000001b86fcc90 -[UIDocument _setOpen:] + 144
27  UIKitCore                     0x00000001b86fbb8c __40-[UIDocument openWithCompletionHandler:]_block_invoke + 676
28  libdispatch.dylib             0x00000001b4814ec4 _dispatch_call_block_and_release + 32
29  libdispatch.dylib             0x00000001b481633c _dispatch_client_callout + 20
30  libdispatch.dylib             0x00000001b481c85c _dispatch_lane_serial_drain + 568
31  libdispatch.dylib             0x00000001b481d290 _dispatch_lane_invoke + 400
32  libdispatch.dylib             0x00000001b4826928 _dispatch_workloop_worker_thread + 584
33  libsystem_pthread.dylib       0x00000001b487d714 _pthread_wqthread + 276
34  libsystem_pthread.dylib       0x00000001b48839c8 start_wqthread + 8


Note the app doesn't use a Document Browser:

UISupportsDocumentBrowser = FALSE.

LSSupportsOpeningDocumentsInPlace = FALSE

Using a single NSUbiquitousContainer with NSUbiquitousContainerIsDocumentScopePublic = FALSE

Replies

This occurred with iOS 13.5. Can no longer demonstrate with 13.5.1

Now seen with iOS 14. App locks while attempting to open file. [NSURL getResourceValue:forKey:error:] seems to be the culprit again.

Code Block Hardware Model: iPad8,1
Process: SamuraiSafe [14700]
Path: /private/var/containers/Bundle/Application/01EA18D0-8D34-4B67-BAE2-F6711BA92927/SamuraiSafe.app/SamuraiSafe
Identifier: net.samarama.SamuraiSafe
Version: 360 (1.6.13)
AppStoreTools: 12A7604b
AppVariant: 1:iPad8,1:14
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: net.samarama.SamuraiSafe [8789]
Date/Time: 2020-11-02 08:11:58.8415 +1100
Launch Time: 2020-11-02 08:10:50.2517 +1100
OS Version: iPhone OS 14.1 (18A8395)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: application<net.samarama.SamuraiSafe>:14700 exhausted real (wall clock) time allowance of 10.00 seconds | ProcessVisibility: Foreground | ProcessState: Running | WatchdogEvent: scene-update | WatchdogVisibility: Background | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 6.830 (user 6.830, system 0.000), 9% CPU", | "Elapsed application CPU time (seconds): 0.099, 0% CPU" | ) reportType:CrashLog maxTerminationResistance:Interactive>
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001d52ac3d0 ulock_wait + 8
1 libsystem_platform.dylib 0x00000001f0a240e8 _os_unfair_lock_lock_slow + 196
2 CoreServicesInternal 0x00000001bf5e8444 _FSURLBeginResourcePropertyCacheAccess + 52
3 CoreFoundation 0x00000001a971a120 -[NSURL getResourceValue:forKey:error:] + 100
4 UIKitCore 0x00000001abb18bd8 +[UIDocument+ 5508056 (UIDocumentInternal) _fileModificationDateForURL:] + 96
5 UIKitCore 0x00000001abb0ee80 40-[UIDocument openWithCompletionHandler:]_block_invoke.418 + 176
6 libdispatch.dylib 0x00000001a9432ac8 _dispatch_client_callout + 20
7 libdispatch.dylib 0x00000001a9440d68 _dispatch_async_and_wait_invoke + 96
8 libdispatch.dylib 0x00000001a9432ac8 _dispatch_client_callout + 20
9 libdispatch.dylib 0x00000001a944004c _dispatch_main_queue_callback_4CF + 836
10 CoreFoundation 0x00000001a97b11e4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
11 CoreFoundation 0x00000001a97ab3b4 __CFRunLoopRun + 2508
12 CoreFoundation 0x00000001a97aa4bc CFRunLoopRunSpecific + 600
13 GraphicsServices 0x00000001c02bc820 GSEventRunModal + 164
14 UIKitCore 0x00000001ac157164 -[UIApplication _run] + 1072
15 UIKitCore 0x00000001ac15c840 UIApplicationMain + 168
16 SamuraiSafe 0x00000001041624c8 0x10415c000 + 25800
17 libdyld.dylib 0x00000001a9471e40 start + 4


I am seeing the same issue (and it took a looong while to narrow it down to unresponsive SMB server). Michael, did you file a bug report to Apple, by any chance?

I did submit a big report with iOS 13 in 2020, but then was unable to recreate with iOS 13.5.1 to provide additional debug data. I have not seen the issue manifest itself recently (iOS 15). So sorry, didn’t have the energy to do so for the above incident.