diff --git a/platform/platform-impl/src/com/intellij/ide/bootstrap/appPreInit.kt b/platform/platform-impl/src/com/intellij/ide/bootstrap/appPreInit.kt index e3f0168024c8..e5547ee53713 100644 --- a/platform/platform-impl/src/com/intellij/ide/bootstrap/appPreInit.kt +++ b/platform/platform-impl/src/com/intellij/ide/bootstrap/appPreInit.kt @@ -140,11 +140,11 @@ private suspend fun initServiceContainer(app: ApplicationImpl, pluginSetDeferred } private suspend fun preInitApp(app: ApplicationImpl, - asyncScope: CoroutineScope, - log: Logger, - initLafJob: Job, - appRegisteredJob: Job, - euaTaskDeferred: Deferred<(suspend () -> Boolean)?>?) { + asyncScope: CoroutineScope, + log: Logger, + initLafJob: Job, + appRegisteredJob: Job, + euaTaskDeferred: Deferred<(suspend () -> Boolean)?>?) { coroutineScope { launch(CoroutineName("critical services preloading")) { preloadCriticalServices(app = app, asyncScope = asyncScope, appRegistered = appRegisteredJob, initLafJob = initLafJob) @@ -176,18 +176,8 @@ private suspend fun preInitApp(app: ApplicationImpl, euaTaskDeferred?.await()?.invoke() - asyncScope.launch { - if (!app.isHeadlessEnvironment) { - launch(CoroutineName("icons preloading") + Dispatchers.IO) { - AsyncProcessIcon.createBig(this) - AsyncProcessIcon(this) - AnimatedIcon.Blinking(AllIcons.Ide.FatalError) - AnimatedIcon.FS() - } - } - + launch { coroutineScope { - loadIconMapping?.join() launch { // used by LafManager app.serviceAsync() @@ -197,16 +187,28 @@ private suspend fun preInitApp(app: ApplicationImpl, } } + loadIconMapping?.join() + span("laf initialization", RawSwingDispatcher) { app.serviceAsync() } + if (!app.isHeadlessEnvironment) { // preload only when LafManager is ready - launch { + asyncScope.launch { app.serviceAsync() } } } + + if (!app.isHeadlessEnvironment) { + asyncScope.launch(CoroutineName("icons preloading") + Dispatchers.IO) { + AsyncProcessIcon.createBig(this) + AsyncProcessIcon(this) + AnimatedIcon.Blinking(AllIcons.Ide.FatalError) + AnimatedIcon.FS() + } + } } }