DynamicPluginListener doesn't detect updates correctly

Planned

Hello all,

I'm Yoni from Tabnine, we're developing a plugin for JetBrains IDEs and would appreciate your help with the following:

I want to know when the plugin is being uninstalled, but I'm getting the event on plugin updates as well - I want to distinguish between updates and uninstalls.

Some details:

SDK version: 2021.3

My Intellij details:

IntelliJ IDEA 2021.3.2 (Ultimate Edition)
Build #IU-213.6777.52, built on January 28, 2022
Licensed to Codota / Yoni Peleg
Subscription is active until August 3, 2022.
Runtime version: 11.0.13+7-b1751.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.13.0-30-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Registry:
    ide.balloon.shadow.size=0

Non-Bundled Plugins:
    org.toml.lang (213.5744.224)
    name.kropp.intellij.makefile (213.5744.224)
    li.barlog.oceanic-primal (0.0.11)
    com.tabnine.TabNine (0.5.22-alpha.20220224121954)
    com.intellij.nativeDebug (213.6461.6)
    org.jetbrains.kotlin (213-1.6.10-release-961-IJ6777.52)
    google-java-format (1.14.0.0)
    com.github.jef.forest-night (1.3.0)
    org.rust.lang (0.4.165.4438-213)
    intellij.prettierJS (213.6461.6)
    Pythonid (213.6777.52)
    ru.adelf.idea.dotenv (2022.1)
    com.chrisrm.idea.MaterialThemeUI (6.13.0)

Kotlin: 213-1.6.10-release-961-IJ6777.52
Current Desktop: ubuntu:GNOME

 

Attempts

I tried implementing `PluginStateListener`:

public class TabNinePluginStateListener implements PluginStateListener {
// ...
 @Override
  public void uninstall(@NotNull IdeaPluginDescriptor descriptor) {
// ...
}
}

But it seems like the `uninstall` method is being called upon plugin updates as well, and there's no way to distinguish between the 2 events.

 

Then, I tried `DynamicPluginListener`:

public class TabNineDynamicListener implements DynamicPluginListener {
// ...
 @Override
  public void beforePluginUnload(@NotNull IdeaPluginDescriptor descriptor, boolean isUpdate) {
// ...
}
}

But it appears that `isUpdate` is always false - even when I update the plugin.

To check that, I'm running a local plugin repository like described in this readme from our repo: https://github.com/codota/tabnine-intellij/blob/37db20fe8f8f242709ebec21be4885e504549c45/local-repo/README.md

I also made sure that the plugin is indeed dynamic while testing, using the `runPluginVerifier` gradle task.

If you need any more details I'll be happy to answer,

Kind regards

5 comments
Comment actions Permalink

Could you please clarify how exactly you "update" the plugin?

0
Comment actions Permalink

Sorry for the huge delay, I didn't get any notification and gave up refreshing this page after a week or so :(

"update" == the local plugin repository I'm running has newer version than installed, so I click the upgrade button in the `Plugins` view (just like any normal plugin update)

0
Comment actions Permalink

Could you please provide the thread dump at the moment, when `isUpdate` is false?
A screenshot of debugging session, as well ideally? Thanks

0
Comment actions Permalink

Sadly not atm, when I opened this issue I tried to play around with a mock plugin which I don't have right now.

Our plugin is not dynamic and we currently don't plan on making it dynamic anytime soon, so I think its better to focus on the `PluginStateListener` API - which is firing an uninstall event upon update as well.

When you uninstall the plugin, the code which calls the `PluginStateListener` is:

com.tabnine.UninstallListener.uninstall(UninstallListener.kt:33)
com.intellij.ide.plugins.PluginStateManager.lambda$fireState$0(PluginStateManager.java:31)
com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:101)
com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2125)
com.intellij.ide.plugins.PluginStateManager.fireState(PluginStateManager.java:25)
com.intellij.ide.plugins.PluginInstaller.prepareToUninstall(PluginInstaller.java:83)
com.intellij.ide.plugins.newui.MyPluginModel.performUninstall(MyPluginModel.java:1021)
com.intellij.ide.plugins.newui.MyPluginModel.uninstallAndUpdateUi(MyPluginModel.java:996)
...

And when you update the plugin, its called from:

com.tabnine.UninstallListener.uninstall(UninstallListener.kt:33)
com.intellij.ide.plugins.PluginStateManager.lambda$fireState$0(PluginStateManager.java:31)
com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:101)
com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2125)
com.intellij.ide.plugins.PluginStateManager.fireState(PluginStateManager.java:25)
com.intellij.ide.plugins.PluginInstaller.prepareToUninstall(PluginInstaller.java:83)
com.intellij.ide.plugins.newui.MyPluginModel.performUninstall(MyPluginModel.java:1021)
com.intellij.ide.plugins.newui.MyPluginModel.installOrUpdatePlugin(MyPluginModel.java:373)
...
0
Comment actions Permalink

I've asked my colleague to investigate. Please note if by now you're targeting a different IDE version than OP.

0

Please sign in to leave a comment.