Some system events blocking the main thread in app clip

In our app clip, we are making an API call to fetch data which will be shown on UI. We get this API response within 2 secs. While we receive the API response, we are showing loading state.

Once we get the API response, app clip takes almost 25 secs to render the data received from API.

We have added some logging to understand the time & found that until below system events are completed, main thread is blocked which prevents updating the placeholder UI with actual data.

Code Block
2020-07-29 13:10:11 +0000: Created MyViewProvider. Time taken 0.00256502628326416
2020-07-29 18:40:16.754090+0530 MyAppClip[17964:1434520] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-07-29 18:40:21.754879+0530 MyAppClip[17964:1434520] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-07-29 18:40:21.755091+0530 MyAppClip[17964:1434520] HALDefaultDevice::Initialize: couldn't add the default input device listener, Error: 268435460 (\^P)
2020-07-29 18:40:26.755403+0530 MyAppClip[17964:1434520] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-07-29 18:40:26.755745+0530 MyAppClip[17964:1434520] HALDefaultDevice::Initialize: couldn't add the default output device listener, Error: 268435460 (\^P)
2020-07-29 18:40:31.756327+0530 MyAppClip[17964:1434520] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-07-29 18:40:31.756658+0530 MyAppClip[17964:1434520] HALDefaultDevice::Initialize: couldn't add the default system output device listener, Error: 268435460 (\^P)
2020-07-29 18:40:36.757257+0530 MyAppClip[17964:1434520] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-07-29 18:40:36.757528+0530 MyAppClip[17964:1434520] HALDefaultDevice::Initialize: couldn't add the default shared output device listener, Error: 268435460 (\^P)
2020-07-29 18:40:36.758519+0530 MyAppClip[17964:1434520] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000008d8f40> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-07-29 18:40:36.759164+0530 MyAppClip[17964:1434520] AudioObjectSetPropertyData: no object with given ID 0
2020-07-29 18:40:36.759369+0530 MyAppClip[17964:1434520] 83: Failed to set processVolumeScalar on device. Error: 560947818
2020-07-29 13:10:36 +0000: Created AnotherViewProvider. Time taken 25.097121953964233

Does anybody faced this issue?



I'm seeing this in a normal app using Core Data CloudKit sync. The app seems to hang for 20 to 30 seconds and I see this in the console.
Do you initialise an audio device once your data comes back? Maybe by using an object from AVFoundation?
This is happening to me, too, and I'm not even using sound. It is from a Watch Extension, though. For me, it happens when initializing an NSAttributedString...
Code Block  
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
            .documentType: NSAttributedString.DocumentType.html,
            .characterEncoding: String.Encoding.utf8.rawValue
        ]
        
        // Try to parse input string data out as an HTML document, return input if failed
        guard let attributedString = try? NSAttributedString(data: inputStringData, options: options, documentAttributes: nil) else {
            return false
        }



Do you initialise an audio device once your data comes back? Maybe by using an object from AVFoundation?

We do not use initialise an audio device or AVFoundation.


Any update on this? It's basically brought my Xcode 12 usage to a standstill, I'm back on Xcode 11.
Having the same issue. Is this by anyway linked to UIWebview, AVSession?
We've started to see similar issue on Xcode 12 beta 4 (where on Xcode 12 beta 2 didn't happen).
And only on simulator of iOS14 device, in case of a tested game we use OpenAL for audio that crashes on alcOpenDevice()
Like ddhuntsman I am also seeing this when trying to initialize an NSAttributedString. It just hangs.

Code Block
let html = "Some HTML ..."
if let data = html.data(using: .utf8) {
let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)


Does anyone have a solution for this?
I am seeing the same with Xcode 12 beta 4 during app startup when simply trying to access AVAudioEngine().mainMixerNode.
Does the same issue reproduce with Xcode 12 beta 5?
Yeah! Just tried my app on Xcode 12.5 Beta and it's working.

On Xcode 12.4 beta the same app will show the errors posted and then crash on code that is something this:
Code Block
SKNode().run(SKAction.playSoundFileNamed(....

@DTS Engineer This issue is fixed in Xcode 12 beta 5. Now UI is rendered instantly without any delay.
@DTS Engineer Just want to highlight that I could see below error/warning in Console area when app clip is running using Xcode 12 Beta 5

Code Block
2020-08-26 15:34:38.030645+0530 MyAppClip[40692:290645] [connection] nw_proxy_resolver_create_parsed_array [C1 proxy pac] Evaluation error: NSURLErrorDomain: -1003
2020-08-26 15:34:38.072669+0530 MyAppClip[40692:290645] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2020-08-26 15:34:39.996914+0530 MyAppClip[40692:290644] [connection] nw_proxy_resolver_create_parsed_array [C2 proxy pac] Evaluation error: NSURLErrorDomain: -1003
2020-08-26 15:34:40.152378+0530 MyAppClip[40692:290123] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000132e140> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-08-26 15:34:40.338279+0530 MyAppClip[40692:290123] Metal API Validation Enabled
2020-08-26 15:34:40.813305+0530 MyAppClip[40692:290123] libMobileGestalt MobileGestalt.c:1736: Could not retrieve region info

Even though its not impacting app clip, just want to know whether we can ignore them?

Some system events blocking the main thread in app clip
 
 
Q