First Save always freezes IDE

Issue #1612 resolved
Xander Victory created an issue

After opening a project (for the first time after opening IDEA), the first save (or perhaps ctrl-S Save all reflex action) on apex code freezes the whole IDE. (my sfdx org list is long)

SFDX projects on Sandbox orgs, neither deploy on save nor overwrite save all action are turned on.

Freeze in EDT for 52 seconds
Sampled time: 46400ms, sampling rate: 100ms, GC time: 22ms (0%), Class loading: 0%

com.intellij.diagnostic.Freeze
    at java.base@11.0.6/java.lang.Thread.sleep(Native Method)
    at com.illuminatedcloud.util.CommandLineUtil.runCommandLine(SourceFile:134)
    at com.illuminatedcloud.intellij.sfdx.SfdxUtil.runSfdx(SourceFile:209)
    at com.illuminatedcloud.intellij.sfdx.SfdxUtil.runSfdx(SourceFile:316)
    at com.illuminatedcloud.intellij.sfdx.SfdxUtil.runSfdx(SourceFile:293)
    at com.illuminatedcloud.intellij.sfdx.SfdxUtil.runSfdx(SourceFile:257)
    at com.illuminatedcloud.intellij.sfdx.SfdxUtil.runSfdxForceOrgDisplay(SourceFile:526)
    at com.illuminatedcloud.client.ForceComApiClient.doGetForceOrgDisplayResponse(SourceFile:969)
    at com.illuminatedcloud.client.ForceComApiClient.access$000(SourceFile:120)
    at com.illuminatedcloud.client.ForceComApiClient$1.run(SourceFile:918)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:930)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:480)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
    at com.intellij.openapi.progress.impl.CoreProgressManager$$Lambda$342/0x00000008004d5440.run(Unknown Source)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:625)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:570)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
    at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:408)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:492)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:84)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runSynchronously(CoreProgressManager.java:343)
    at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:328)
    at com.illuminatedcloud.client.ForceComApiClient.getForceOrgDisplayResponse(SourceFile:913)
    at com.illuminatedcloud.client.ForceComApiClient.doLoginWithSfdx(SourceFile:793)
    at com.illuminatedcloud.client.ForceComApiClient.loginWithSfdx(SourceFile:755)
    at com.illuminatedcloud.client.ForceComApiClient.lambda$login$1(SourceFile:584)
    at com.illuminatedcloud.client.ForceComApiClient$$Lambda$4186/0x00000008029ec840.compute(Unknown Source)
    at com.illuminatedcloud.client.ForceComApiClient.runWithClientClassLoader(SourceFile:569)
    at com.illuminatedcloud.client.ForceComApiClient.login(SourceFile:582)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.getClient(SourceFile:996)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.runWithClient(SourceFile:809)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.getDescribeMetadataResult(SourceFile:1032)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.getMetadataDescribesByDirectoryName(SourceFile:1063)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.getMetadataDescribeIndex(SourceFile:1094)
    at com.illuminatedcloud.intellij.builder.ForceComBuilderUtil.toBuildSelections(SourceFile:1635)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.buildForSave(SourceFile:1714)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder.buildForSave(SourceFile:1704)
    at com.illuminatedcloud.intellij.builder.ForceComBuilder$1.contentsChanged(SourceFile:330)
    at jdk.internal.reflect.GeneratedMethodAccessor169.invoke(Unknown Source)
    at java.base@11.0.6/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base@11.0.6/java.lang.reflect.Method.invoke(Method.java:566)
    at com.intellij.util.EventDispatcher.dispatchVoidMethod(EventDispatcher.java:127)
    at com.intellij.util.EventDispatcher.access$000(EventDispatcher.java:21)
    at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:85)
    at com.sun.proxy.$Proxy19.contentsChanged(Unknown Source)
    at com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter.fireAfter(BulkVirtualFileListenerAdapter.java:51)
    at com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter.after(BulkVirtualFileListenerAdapter.java:42)
    at jdk.internal.reflect.GeneratedMethodAccessor171.invoke(Unknown Source)
    at java.base@11.0.6/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base@11.0.6/java.lang.reflect.Method.invoke(Method.java:566)
    at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:549)
    at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:143)
    at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:472)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:432)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:420)
    at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:404)
    at com.intellij.util.messages.impl.MessageBusImpl.lambda$createTopicHandler$3(MessageBusImpl.java:243)
    at com.intellij.util.messages.impl.MessageBusImpl$$Lambda$347/0x00000008004d3440.invoke(Unknown Source)
    at com.sun.proxy.$Proxy133.after(Unknown Source)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl$2.close(PersistentFSImpl.java:668)
    at com.intellij.openapi.vfs.VirtualFile.setBinaryContent(VirtualFile.java:549)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualFileImpl.setBinaryContent(VirtualFileImpl.java:149)
    at com.intellij.openapi.fileEditor.impl.LoadTextUtil.write(LoadTextUtil.java:384)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocumentInWriteAction$4(FileDocumentManagerImpl.java:453)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl$$Lambda$4170/0x00000008029ea040.run(Unknown Source)
    at com.intellij.pom.core.impl.PomModelImpl.guardPsiModificationsIn(PomModelImpl.java:379)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocumentInWriteAction(FileDocumentManagerImpl.java:442)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocument$2(FileDocumentManagerImpl.java:404)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl$$Lambda$4169/0x00000008029e9c40.run(Unknown Source)
    at com.intellij.openapi.application.WriteAction.run(WriteAction.java:102)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocument(FileDocumentManagerImpl.java:404)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveAllDocuments(FileDocumentManagerImpl.java:324)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveAllDocuments(FileDocumentManagerImpl.java:302)
    at com.intellij.ide.actions.SaveAllAction.actionPerformed(SaveAllAction.kt:21)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:280)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:609)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$3(IdeKeyEventDispatcher.java:670)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$$Lambda$3588/0x0000000802767440.run(Unknown Source)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:669)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:619)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:516)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:470)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:219)
    at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:896)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:841)
    at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
    at com.intellij.ide.IdeEventQueue$$Lambda$509/0x000000080067a840.compute(Unknown Source)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:739)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
    at com.intellij.ide.IdeEventQueue$$Lambda$508/0x0000000800679040.run(Unknown Source)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:502)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop@11.0.6/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Comments (10)

  1. Scott Wells repo owner

    Xander, how long does it take for you to run sfdx force:org:display -u <connectionAlias> from the command-line? Similarly, how long does it take to run sfdx force:org:list? Have you tried cleaning out stale entries using sfdx force:org:list --clean?

  2. Kostas Vorilas

    I am experiencing something similar (after upgrade to 2020.1) scrolling up/down freezes IDE for 3-4 seconds. I am not sure if it is related to this issue.

  3. Scott Wells repo owner

    Is that happening to you frequently or just once as with Xander? Is it in conjunction with some action or just while trying to use the IDE normally? How much memory is allocated to the IDE? GC pauses are the only thing that comes to mind immediately. I'm happy to review some logs/thread dumps from when this is occurring for you as well.

  4. Xander Victory reporter

    List takes 20-30 seconds, display took ~4 seconds - though that was after the list, so the token would have been valid already. Round trip time to the login server is 175ms, so logins are always slow.

    Yes I keep the list clear of stale entries.

    Can I ask what this section of code is doing (in general) & why it’s not a background task on its own if there’s the potential to take more than a few milliseconds?
    The closest I can work out is that it’s to do with deployment - though I’ve not got any of those options turned on.

  5. Scott Wells repo owner

    Thanks, Xander. This stack trace in particular is getting the metadata information from the server in preparation for a deployment. To do that, it needs the connection information, specifically the access token. That must all happen synchronously on the thread of execution, though it shouldn't necessarily be on the EDT. I'll look into that.

    The good news is that there are two improvements coming up shortly for this. First, I'm testing a build right now that AGGRESSIVELY caches that metadata information whenever possible to minimize server interactions required to get it. The metadata cache is shared among all consumers whereas before there were 2-3 shared-nothing copies of that floating around.

    Additionally in their latest CLI updates, Salesforce has improved the performance of sfdx force:org:list, and once I incorporate a new command-line flag (probably another release or two from now), it won't even need to contact the server to get status except when you explicitly tell it to hard-refresh the connection list.

    Before I make any changes for this in particular, let me get the next build of IC out that includes the metadata cache and let's see if that doesn't pretty much address this for you.

  6. Xander Victory reporter

    This stack trace in particular is getting the metadata information from the server in preparation for a deployment

    It shouldn’t be deploying anything at this time with my configuration though?

  7. Scott Wells repo owner

    Xander, I believe that the latest build will largely address this, but I'm not resolving it yet because I agree that in your situation, it's still doing something it shouldn't be doing. I'll continue to investigate that to eliminate the corner case in which this could still occur.

  8. Scott Wells repo owner

    Xander, I've made changes so that when deploy-on-save is disabled, the server metadata is never needed (until you actually perform an explicit deployment). I've also made sure that when that setting is disabled, no attempts are made to deploy-on-file-operation, not just save. This will all be in the next build.

  9. Scott Wells repo owner

    Delivered in 2.1.2.7. Please let me know if you see this type of behavior again as IC shouldn't be doing anything of substance when you type Ctrl+S/Cmd+S if you've disabled deploy-on-save.

  10. Log in to comment