Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable plugin loading/unloading without restart #60

Open
duemir opened this issue Aug 10, 2021 · 9 comments
Open

Enable plugin loading/unloading without restart #60

duemir opened this issue Aug 10, 2021 · 9 comments

Comments

@duemir
Copy link
Member

duemir commented Aug 10, 2021

Dependencies

Feature Request

According to https://plugins.jetbrains.com/plugin/1885-stapler-framework-support/versions following is what is blocking it:

Plugin Stapler Framework Support 2.0.0 cannot be enabled nor disabled without IDE restart because the following requirements are not satisfied: Plugin cannot be loaded/unloaded without IDE restart because it declares non-dynamic extensions: com.intellij.fileTypeFactory

@duemir
Copy link
Member Author

duemir commented Oct 1, 2021

It requires a newer IntelliJ baseline. com.intellij.fileTypeFactory was deprecated in 2019.2.

@duemir
Copy link
Member Author

duemir commented Apr 26, 2022

@jgreffe
Copy link
Contributor

jgreffe commented Nov 2, 2022

Hello @duemir ,

with last master, I tried following this: https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#restrictions

But IDEA states nothing to report (?)
Monosnap hacktoberfest – plugin xml (Stapler plugin for IntelliJ IDEA) 2022-11-02 09-21-48

And running locally:

$ gradle runPluginVerifier -PideaVersion=2022.2.3
...
Plugin Stapler plugin for IntelliJ IDEA:2.1.0 against IC-222.4345.14: Compatible
    Plugin can probably be enabled or disabled without IDE restart

Plugin Stapler plugin for IntelliJ IDEA:2.1.0 against IC-223.6160.11: Compatible
    Plugin can probably be enabled or disabled without IDE restart
...

But it seems it's still not dynamic, as when installed, trying to uninstall -> requires IDE restart :/

@duemir
Copy link
Member Author

duemir commented Nov 2, 2022

Check https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#code

Do not store references to PSI elements in objects which can survive plugin loading or unloading; use SmartPsiElementPointer instead.

A bunch of XmlTag-s and XmlAttributes are stored around directly, I believe. Something to look into as far as this feature goes.

@duemir
Copy link
Member Author

duemir commented Nov 4, 2022

I don't know how much of a clue it is, but when I updated the plugin in IntelliJ Community Edition, dynamic reload worked.

@jgreffe
Copy link
Contributor

jgreffe commented Nov 7, 2022

I'm my side, can't make it reload dynamically :/
In a terminal:

$ gradle runIde -PrunIde.jvmArgs+="-XX:+UnlockDiagnosticVMOptions" -PideaVersion=2022.1

In the opened sandbox:

  • change Registry... configuration with ide.plugins.snapshot.on.unload.fail to true
  • open a jelly file

In another terminal:

$ gradle buildPlugin -xbuildSearchableOptions

Switch focus back to sandbox:

  • plugin will try to reload dynamically
  • a popin will show stating dynamic reload failed
  • look at build/idea-sandbox/system/log/idea.log:
2022-11-07 08:41:28,176 [  44771]   INFO - #c.i.i.p.DynamicPlugins - Snapshot analysis result: Root 1:
  ROOT: Global JNI
  com.intellij.openapi.wm.impl.IdeFrameImpl.myFrameHelper
  com.intellij.openapi.wm.impl.ProjectFrameHelper$1.this$0
  com.intellij.openapi.wm.impl.ProjectFrameHelper.project
  com.intellij.openapi.project.impl.ProjectExImpl.componentKeyToAdapter
  java.util.concurrent.ConcurrentHashMap.table
  java.util.concurrent.ConcurrentHashMap$Node[]
  java.util.concurrent.ConcurrentHashMap$Node.val
  com.intellij.serviceContainer.ServiceComponentAdapter.initializedInstance
  com.intellij.ide.structureView.impl.StructureViewFactoryImpl.myImplExtensions
  java.util.concurrent.ConcurrentHashMap.table
  java.util.concurrent.ConcurrentHashMap$Node[]
  java.util.concurrent.ConcurrentHashMap$Node.key
  org.kohsuke.stapler.idea.psi.JellyFileImpl.<loader>
* com.intellij.ide.plugins.cl.PluginClassLoader


2022-11-07 08:41:28,213 [  44808]   INFO - #c.i.i.p.DynamicPlugins - Plugin Stapler plugin for IntelliJ IDEA is not unload-safe because class loader cannot be unloaded. Memory snapshot created at /Users/xxx/unload-Stapler plugin for IntelliJ IDEA-07.11.2022_08.41.21.hprof

@duemir
Copy link
Member Author

duemir commented Nov 8, 2022

That looks like the new PSI class that you introduced, which appears to be used as a key in the map somewhere inside IntelliJ.
Other than asking in Jetbrains Slack and reporting to their YouTrack if that's what they suggest on Slack, I have no ideas.

To be honest this is nice to have category in my head, so I personally would not be spending much time on this.

@jgreffe
Copy link
Contributor

jgreffe commented Nov 14, 2022

Same issue with standard simple language demo from JetBrains.
Created https://youtrack.jetbrains.com/issue/IDEA-305958/simplelanguageplugin-not-dynamic

@duemir duemir added the blocked label Nov 22, 2022
@jgreffe
Copy link
Contributor

jgreffe commented Nov 24, 2022

Created issue is a duplicate of https://youtrack.jetbrains.com/issue/IDEA-263300 (unresolved yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants