Xcode 12.5 very slow launch time for app in simulator

Configuration
  • Big Sur 11.3

  • Xcode 12.5

(recently updated from Catalina and Xcode 12.4)

Problem
When running app in iOS 14.5 simulator launch takes incredibly long time (more than 30 seconds). In comparison launching installed app in simulator - 2 seconds, launching app on the real device (iOS 14.4) - 6 seconds.

Additional information
When running against simulator Xcode says "launching app", "attaching to app", and then "running app", at the running app stage we get a ~30 second pause. debugserver at 100% activity at that time.

Looking for solution
Methods described here https://developer.apple.com/forums/thread/651012 (deleting the contents of ~/Library/Developer/Xcode/iOS DeviceSupport) didn't help.
If I untick Debug Executable for the scheme app starts normally but then logically debugging isn't possible so it's not a solution.

Answered by in 677508022

As others have noticed, this issue was triggered by updating a newer versions of macOS. We have a change to address this performance issue when running on newer versions of macOS available in Xcode 13 Beta, available today.

With 11.4 RC my app is starting a lot faster than 11.3.1 but still a little slower than it was a month ago. And once started it's responsive immediately, unlike before where I had to wait another 20 seconds or so.

Not perfect but at least I can leave Debug Executable checked without needing to find a way to kill time.

This is on a 13" 2017 MacBook Pro.
I got the same problem. I'm currently on Big Sur 11.3, Xcode 12.5. Start a debug session of a macOS application UE4Editor is really slow since about 3 weeks. I expect this to be solved soon. I do time profiling. If we remove time for "instruments" to profile itself, So we can see that nearly all time is spend in debugserver process. And that UE4Editor is stuck in dlopen.

Code Block
3.37 s 45.6% 0 s debugserver (37427)
3.36 s 45.6% 0 s Main Thread 0x5af1b6
3.36 s 45.6% 0 s start
3.36 s 45.6% 0 s main
3.36 s 45.6% 0 s RNBRunLoopInferiorExecuting(RNBRemote*)
3.36 s 45.5% 0 s RNBRemote::HandleReceivedPacket(RNBRemote::PacketEnum*)
3.35 s 45.4% 0 s RNBRemote::HandlePacket_jGetLoadedDynamicLibrariesInfos(char const*)
3.35 s 45.4% 0 s DNBGetLibrariesInfoForAddresses(int, std::__1::vector<unsigned long long, std::__1::allocator<unsigned long long> >&)
3.35 s 45.4% 0 s MachProcess::GetLibrariesInfoForAddresses(int, std::__1::vector<unsigned long long, std::__1::allocator<unsigned long long> >&)
3.35 s 45.4% 0 s _dyld_process_info_create
3.35 s 45.4% 0 s withRemoteBuffer(unsigned int, unsigned long long, unsigned long, bool, int*, void (void*, unsigned long) block_pointer)
3.35 s 45.4% 0 s ___dyld_process_info_create_block_invoke
3.35 s 45.4% 0 s std::__1::unique_ptr<dyld_process_info_base, dyld_process_info_deleter> dyld_process_info_base::make<dyld_all_image_infos_64, dyld_image_info_64>(unsigned int, dyld_all_image_infos_64 const&, unsigned long long, int*)
3.35 s 45.4% 0 s withRemoteBuffer(unsigned int, unsigned long long, unsigned long, bool, int*, void (void*, unsigned long) block_pointer)
3.34 s 45.2% 2.00 ms invocation function for block in std::__1::unique_ptr<dyld_process_info_base, dyld_process_info_deleter> dyld_process_info_base::make<dyld_all_image_infos_64, dyld_image_info_64>(unsigned int, dyld_all_image_infos_64 const&, unsigned long long, int*)
3.34 s 45.2% 0 s dyld_process_info_base::addImage(unsigned int, bool, unsigned long long, unsigned long long, char const*)
3.07 s 41.6% 0 s dyld_process_info_base::copyPath(unsigned int, unsigned long long)
3.07 s 41.6% 1.00 ms withRemoteBuffer(unsigned int, unsigned long long, unsigned long, bool, int*, void (void*, unsigned long) block_pointer)
3.06 s 41.5% 1.00 ms RemoteBuffer::create(unsigned int, unsigned long long, unsigned long, bool)
3.06 s 41.5% 1.00 ms RemoteBuffer::map(unsigned int, unsigned long long, unsigned long)
2.96 s 40.1% 1.00 ms mach_vm_remap_new
2.96 s 40.1% 2.00 ms _kernelrpc_mach_vm_remap_new
2.96 s 40.1% 1.00 ms mach_msg
2.96 s 40.1% 2.96 s mach_msg_trap
50.00 ms 0.6% 1.00 ms mach_vm_deallocate
38.00 ms 0.5% 38.00 ms _platform_memmove$VARIANT$Haswell
9.00 ms 0.1% 4.00 ms _malloc_zone_malloc
1.00 ms 0.0% 1.00 ms malloc
3.00 ms 0.0% 0 s invocation function for block in dyld_process_info_base::copyPath(unsigned int, unsigned long long)
1.00 ms 0.0% 0 s free_small
1.00 ms 0.0% 1.00 ms _Block_object_dispose
257.00 ms 3.4% 0 s dyld_process_info_base::addInfoFromRemoteLoadCommands(unsigned int, unsigned long long)
11.00 ms 0.1% 10.00 ms dyld_process_info_base::addInfoFromLoadCommands(mach_header const*, unsigned long long, unsigned long)
8.00 ms 0.1% 0 s RemoteBuffer::create(unsigned int, unsigned long long, unsigned long, bool)
2.00 ms 0.0% 0 s _dyld_process_info_for_each_image
1.00 ms 0.0% 0 s MachProcess::GetMachOInformationFromMemory(unsigned int, unsigned long long, int, MachProcess::mach_o_information&)
1.00 ms 0.0% 0 s free_tiny
1.00 ms 0.0% 0 s RNBRemote::SendPacket(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
3.00 ms 0.0% 0 s RNBRemote::HandlePacket_v(char const*)
2.00 ms 0.0% 0 s RNBRemote::HandlePacket_p(char const*)
1.00 ms 0.0% 0 s RNBRemote::HandlePacket_c(char const*)
1.00 ms 0.0% 1.00 ms DYLD-STUB$$__error
2.00 ms 0.0% 0 s HandleProcessStateChange(RNBRemote*, bool)
1.00 ms 0.0% 0 s PThreadEvent::WaitForSetEvents(unsigned int, timespec const*) const
1.00 ms 0.0% 0 s MachTask::ExceptionThread 0x5af1be
2.98 s 40.3% 0 s Instruments (37042)
249.00 ms 3.3% 0 s Xcode (3162)
225.00 ms 3.0% 0 s WindowServer (150)
160.00 ms 2.1% 0 s lldb-rpc-server (6834)
118.00 ms 1.5% 0 s UE4Editor (37426)
102.00 ms 1.3% 0 s -[UE4AppDelegate runGameThread:] 0x5af2f7
102.00 ms 1.3% 0 s thread_start
102.00 ms 1.3% 0 s _pthread_start
102.00 ms 1.3% 0 s __NSThread__start__
102.00 ms 1.3% 0 s -[FCocoaGameThread main]
102.00 ms 1.3% 0 s -[UE4AppDelegate runGameThread:]
102.00 ms 1.3% 0 s GuardedMain(char16_t const*)
102.00 ms 1.3% 0 s EnginePreInit(char16_t const*)
102.00 ms 1.3% 0 s FEngineLoop::PreInit(char16_t const*)
102.00 ms 1.3% 0 s FEngineLoop::PreInitPostStartupScreen(char16_t const*)
102.00 ms 1.3% 0 s FEngineLoop::LoadStartupModules()
102.00 ms 1.3% 0 s FPluginManager::LoadModulesForEnabledPlugins(ELoadingPhase::Type)
102.00 ms 1.3% 0 s FPluginManager::TryLoadModulesForPlugin(FPlugin const&, ELoadingPhase::Type) const
102.00 ms 1.3% 0 s FModuleDescriptor::LoadModulesForPhase(ELoadingPhase::Type, TArray<FModuleDescriptor, TSizedDefaultAllocator<32> > const&, TMap<FName, EModuleLoadResult, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FName, EModuleLoadResult, false> >&)
97.00 ms 1.3% 0 s FModuleManager::LoadModuleWithFailureReason(FName, EModuleLoadResult&)
92.00 ms 1.2% 0 s FMacPlatformProcess::GetDllHandle(char16_t const*)
92.00 ms 1.2% 0 s GetDllHandleImpl(NSString*, NSString*)
92.00 ms 1.2% 0 s dlopen


Problem still present with Big Sur 11.4 / Xcode 11.5 ...
Wanna try to check it out if the problem is already solved, but Apple seems has not release Xcode 12.6 yet.
Apple is releasing iOS 14.6 but not releasing Xcode 12.6. Can you run and deploy your app to iOS 14.6 directly from Xcode 12.5?

The problem seems to be related to Big Sur 11.3 and Big Sur 11.4. Not to specific Xcode version (Xcode 12.4 got about the same results that 12.5).

I do some measures for 2 applications in debug on Big Sur 11.1 and Big Sur 11.4. Here the launch time results: App1 - Big Sur 11.1 = 0m21s - Big Sur 11.4 = 1m20s App2 - Big Sur 11.1 = 0m31s - Big Sur 11.4 = 5m08s

Conclusion: Debugging Application on 11.4 is between 4 to 10 time slower than 11.1.

Note App2 have nearly 100 dylib to load while App1 have only 30.

I‘m also affected by this bug on a Mac mini i7, 2020 with 16 GB RAM.

The worst thing is the slow down in UITests because I receive so many timeouts and as a consequence the tests are not reliable anymore with Xcode 12.5 on BigSur.

I switched back to Catalina, but now I can not archive my project anymore because some external swift packages are build with 12.5. Apple, please fix it soon!

I'm also seeing this problem, but have noticed a couple of other factors which I haven't seen here yet:

  1. Running xcode simctl list takes >3.5min to give results. This is only the case with xcrun simctl commands. Other xcrun commands seem to launch in a timely fashion.
  2. Rebooting the system will give you a few minutes in which to run normally. Wait too long and the problem presents itself again.

Can someone having this issue verify xcrun simctl list is also a problem for them? This is causing my React-Native Detox tests to time out because it can't get any of the xcrun simctl commands to come back before a 3 minute timeout. Manually increasing that timeout allows the Detox tests to succeed, but they take over an hour to complete where they would take < 2 minutes before.

Accepted Answer

As others have noticed, this issue was triggered by updating a newer versions of macOS. We have a change to address this performance issue when running on newer versions of macOS available in Xcode 13 Beta, available today.

Could you clarify what when running on newer versions of macOS available in Xcode 13 Beta, available today. means?

Do we have to update both Xcode and macOS?

Is there any workaround to fix the issue on Xcode 12? The performance issue is major and unfortunately not everyone can jump to the latest version of Xcode right away.

Xcode 13 Beta seems to have addressed this issue. Having installed it, I can actually run my UI tests again in Xcode 12 as well.

Xcode 13 Beta does not solve it for me. Still really slow (BigSur 11.5 Beta 2)

I'm having the same issue and it's massively affecting my productivity. Is there anything we can do? Using Xcode 13 is not a viable solution.

For me, passing to macOS 12 beta, solve the problem. Launching time returned to normal. Unhappily I can stay on 12 beta, because there are too much problems to work with.

13b1 is definitely much faster for me. I'm going to try using it day-to-day, and then revert to 12.5 for builds to submit.

Can someone from apple (@jeremyhu) please give an update on this? This is a HUGE performance hit to our automation tests.

This needs to be solved for Xcode 12, immediately. We can't be waiting minutes at a time for an app to launch, either on device or in the Simulator. And we can't ship apps with Xcode 13 beta.

Seems Xcode 12.5.1 has largely fixed it. I've been using it for 3 hours it's improved from 15 seconds frozen to 3 seconds frozen post launch.

So initially, I didn't see any improvement in Xcode 12.5.1 - notably the iPhone 12 Pro simulator was still hanging for around 15 seconds before my app UI became responsive.

However, erasing all contents and settings in that simulator seems to have restored performance to normal. I thought I'd tried this before so maybe something has improved.

Xcode 12.5.1 seems to have fixed the issue for me: the first build and run took 30+seconds to attach, however the second and third build and run attached after around 3 seconds.

For me, 12.5.1 doesn't fix the slow debug speed. I redo my tests/measure again, but with ne Xcode 12.5.1 release. I didn't see any improvements at all: On the test machine macOS 11.2.1 with Xcode 12.5.1, Starting application in debug took 25s. macOS 11.4 with Xcode 12.5.1, it take between 85s to 135s (3.5 to 6 time slower)

Can confirm - huge improvement on Xcode 12.5.1.

Xcode 12.5.1 still slow at launching the Simulator - iPhone 11 Pro Max (iOS 14.5) but at least I can testing on Simulator

No appreciable difference in 12.5.1.

We noticed a significant performance degradation in DYLD SPI (part of Darwin Project). This causes slow launch time and application lags on every dynamic linked library load. This issue started from Big Sur 11.3. The problem is also present on iOS 14.6. I created a thread on swift.org. If you have some additional information or measurements, please, add it to the thread. Also I created a ticket at Feedback Assistant (case ID FB9349767).

@oldnpoor I am using Big Sur, but my build always fails with the Build input cannot be found. Here If I removed the product name in the build settings, Build got succeeded. But the app was not installed because the .app file was not available in the Build input file cannot be found: '/Users/name/Library/Developer/Xcode/DerivedData/App-dhdivlzaazbnhtguhlgnkkglsibo/Build/Products/Debug-iphonesimulator/Hello App.app/Hello App. Could you please let me know any workarounds.

Xcode 12.5 very slow launch time for app in simulator
 
 
Q