Run Configuration shows up late in context menu

Answered

I created a run configuration for my plugin, implemented a RunConfigurationProducer and everything else that is needed to invoke my run action in the context menu when I right-click in a file.

This works fine, however I noticed that many times it takes quite long before my action appears as one of the choices in the context menu. After I restart Idea I have to right click a couple of times until my option appears between the others. And also I have noticed that even when it is finally there, it sometimes happens when I don't use the context menu for a long time, that my action has disappeared again. Then it again takes a few right clicks before it's back.

My RunConfigurationProducer does not contain any complex initialisation logic so the slow appearing must come from somewhere else. Do you know how I could make my action appear faster in the context menu after starting IntelliJ?

0
22 comments

Could you please link your plugin's sources?

0

The sources are here: https://github.com/misja-alma/livy-plugin
Sorry that the code is a bit messy, it is still a lot under development.
The file you're interested in is probably src/main/kotlin/org/tera/plugins/livy/run/LivyRunConfigurationProducer.kt

0

Please use passed in parameter com.intellij.execution.actions.ConfigurationContext#getLocation/getPsiLocation() to obtain information about "current element/position".  All the usages of FileEditorManager and any other calls to obtain "current element" should be removed completely. I suspect this should fix inconsistent performance.

0

Thanks for checking my code!

I removed all usages of FileEditorManager fromdoSetupConfigurationFromContext but it doesn't help .. It still takes a long time and many right-clicks before my context action shows up.
And also still it disappears again when I leave IntelliJ alone for a while.

0

Good catch! However, I removed those lines as well and the behaviour is still the same ..

0

By the way, I don't know if it's relevant, but the slow populating of the popup happens only when I really install my plugin in IntelliJ. When I run the plugin from the plugin SDK, most of the time my action it is immediately visible.

0

Do you use the same test project to verify behavior? Try disabling some plugins in real IDE installation to see how they influence performance.

0

No I was verifying on another (much larger) project.

Disabling all plugins except the one I'm testing seems to help.

0

However after having left Idea alone for a while, my menu option has again disappeared when I right click. It takes a few clicks again before it is back. This is after disabling all plugins except the Scala plugin.

0

I also notice this behaviour in other smaller projects. It seems that the action menu items are swapped out of memory when the menu has not been used for a while, and only loaded back upon request, which takes considerable time.
I would really appreciate if there is some way to prevent this behaviour for my plugin, because at some point I intend to roll it out and I expect this will generate many support calls from users.

0

Ok. I installed the Performance Testing plugin as suggested on that page and ran CPU profiling while I was trying to get my 'Livy' plugin action to show up in the context menu. It appeared after the 9th right-click, then I stopped profiling.
I have a cpu snapshot zip file that I could upload if you like, how should I send it to you?

0

Upload to https://uploads.services.jetbrains.com/ or any other file hosting and share link here

 

0

Done: Upload id: 2021_03_04_QfqobgfPZWDorpxk (file: IC-203.7148.57_misja_04.03.2021_12.43.32.zip)

0

Sorry, I don't see any trace of your plugin in that snapshot at all.

0

My plugin hardly contains any initialisation logic so I can well imagine that there is no trace of it.
And for this trace I didn't even invoke it, all I did was right-click a number of times to make the context menu appear.
It seems to be the logic of IntelliJ's lazy context menu loading/unloading that is the cause of my disappearing context action. I'm of course not an expert in how IntelliJ populates the popup menu but to me it seems that the fact that there is no trace of my plugin in the cpu profile, is a clear sign that the cause of the problem is not in the plugin but somewhere else.

0

What should I do to resolve this? Would you advise me to file a bug report for this?

0

Please try re-taking another CPU snapshot. I simply couldn't find anything obvious in it.

0

Here you go: Upload id: 2021_03_08_Vk9vYnqmAs5axmPV (file: IC-203.7148.57_misja_08.03.2021_13.16.14.zip)

What I did was:
- close and re-open intelliJ
- wait until 'indexing files' has finished
- start cpu profiling
- right click a couple of times until my action 'Run New Livy Session' appears in the context dialog
- stop cpu profiling

0

I also see this problem. My run config producer sometimes takes a significant amount of time to appear (20-30 seconds). It also doesn't do anything significant - it uses ProjectFileIndex but that's it. I've never managed to figure out what causes it but I'd love to know.

0

Thanks. Unfortunately I couldn't again find anything relevant in the 2nd snapshot.

Please watch/vote these related issues https://youtrack.jetbrains.com/issue/IDEA-206889 https://youtrack.jetbrains.com/issue/IDEA-220145

0

Please sign in to leave a comment.