mgziminsky / Minimap-for-Jetbrains

Intelij IDEA plugin for displaying a code mini-map similar to the one found in Sublime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in PHPstorm 2020.3.3

remcokalf opened this issue · comments

After updating PHPStorm to 2020.3.3 (I think, did not notice it before), this plugin gives me this IDE error:

Worker exited due to exception

java.util.ConcurrentModificationException
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
	at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.getAttributesKeys(LexerEditorHighlighter.java:492)
	at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter.getAttributes(LexerEditorHighlighter.java:484)
	at com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$HighlighterIteratorImpl.getTextAttributes(LexerEditorHighlighter.java:647)
	at com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter$LayeredHighlighterIteratorImpl.getTextAttributes(LayeredLexerEditorHighlighter.java:587)
	at net.vektah.codeglance.render.Minimap.update(Minimap.kt:117)
	at net.vektah.codeglance.GlancePanel$7.computeInReadAction(GlancePanel.kt:144)
	at com.intellij.openapi.progress.util.ReadTask.performInReadAction(ReadTask.java:49)
	at com.intellij.openapi.progress.util.ReadTask.lambda$runBackgroundProcess$0(ReadTask.java:66)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61)
	at com.intellij.openapi.progress.util.ReadTask.runBackgroundProcess(ReadTask.java:66)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runUnderProgress$5(ProgressIndicatorUtils.java:259)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:59)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:59)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runUnderProgress(ProgressIndicatorUtils.java:257)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils$4.run(ProgressIndicatorUtils.java:207)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:834)

Does this always happen or only sometimes? I haven't tried in PHPStorm specifically, but it's not happening for me in Intellij. I have a theory as to what might be happening, and i'll look into it, but more details on exactly what you are doing when it happens for you would help

I saw an exclamation mark icon in the bottom right of the editor window (on the bar way at the bottom), clicked it and these errors were there.
But now, that icon is not there anymore. So maybe it was a one time thing.
So I am not sure if it was something I was doing at the moment, or a certain file open. Except that I just had upgraded to PHPStorm 2020.3. If I see it again I will note what I was doing or other circumstances and report back.

FYI:I had the error again today. Was in a large javascript file, then when/after running a gulp task for compiling, I noticed the error button again. See attached screenshot. I cannot trigger the error though, it was once and then not again after I cleared it.

Schermafbeelding 2021-03-22 om 16 09 59

Sorry for the slow reply. I am unable to reproduce, but I am confident I have identified the issue based on the stacktrace you provided. Unfortunately, I didn't see any simple solution, and I just don't have the motivation for this project right now to work out a full proper fix.

If you wanted to look into fixing it yourself, I would be happy to accept a Pull Request. I have one easy idea that I'll describe below, but since I haven't been able to reproduce, there's no easy way for me to verify it actually helps.

As far as I can tell, the issue is with the call hlIter.textAttributes at

(hlIter.textAttributes.foregroundColor ?: defaultForeground).getRGBComponents(colorBuffer)

Apparently, that method is only meant to be called from the GUI thread, but the entire update method that contains it is run from a background thread, leading to a race condition. That being the case, it makes sense that it would be more likely to trigger the issue for large files where the editor spends extended amounts of time processing syntax and highlighting information.

A possible quick fix off the top of my head would be to add indicator?.checkCanceled() immediately before the call to hlIter.textAttributes. This wouldn't address the underlying issue, but I suspect the GUI thread should be cancelling the minimap update before it starts its work, so placing a check closer to the problematic call should hopefully fix things.

I understand, I wish I could help but my Java knowledge is zero..
If I can help by testing out a possible fix, let me know.

For me it is not a big issue though, I have seen the error a couple of times, but it does not seem to prevent the plugin from working as far as I can tell.