intellij locks up follwoed by many cancel UnindexedFilesUpdater messages




Still working on my custom external system plugin. It's starting to work pretty well now, but this problem has been annoying me. It's always sort-of been there, but sometimes just doesn't show up. Getting it regularly now.

There are a ton of messages like the following:

2020-01-23 16:52:42,720 [ 915025] INFO - penapi.project.DumbServiceImpl - cancel com.intellij.util.indexing.UnindexedFilesUpdater@2a0a9514

If it helps any, I'm seeing it log a lot of threadDump files, top places seem to be:


OrderRootsCache.disposePointers -> ObjectTree.executeAll (which creates a Throwable and calls fillInStackTrace),

ProjectFileIndexImpl.isUnderIgnored -> DirectoryIndexImpl.getRootIndex





After a fair amount of tracing and debugging, it appears that the UnindexedFilesUpdater's are being canceled when a Project Roots event is fired, which seems to be fired once for each module (not 100% sure about that) even if the project roots haven't changed at all. Oddly when the event is fired, the handler for UnindexedFilesUpdater calls cancelTask on the updater task for each time this has happened. So each time this happens it attempts to cancel all UnindexedFilesUpdaer's, then creates a new one. but then they never seem to actually cancel. which means eventually it's trying to cancel thousands of them and not apparently succeeding.


On a side note, this will happen when the IDE window is unfocused and it tries to save the project. I think it will also happen if my custom Facet is enabled even without the window activation/change (not 100% sure on that).


After even more work, it appears it's related to having a ton of duplicate source roots and ALSO trying to place the .iml files in .idea/modules/ rather than each one in the module's root. intellij seems to treat the iml file creation in .idea/modules as a change to all modules and spawns off a full reindex which never seemingly gets successfully canceled and they just pile up and slow things down.


I would really like to hide the iml files if at all possible. How can I do that?