live-plugin
live-plugin copied to clipboard
Bug: AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay
The timer stays loaded in the context of the LivePlugin. Even when you reload (or stop) the plugin, it will still continue in the background.
If you start it several times you'll have mulitple of those timers running on the old code.
This is expected. You have to manually free the resources between plug-in reloads. I find it most convenient to use Disposables, for example see “pluginDisposable” in the hello world example bundled with LivePlugin.
On Wed, 19 Oct 2022 at 16:13, John @.***> wrote:
The timer stays loaded in the context of the LivePlugin. Even when you reload (or stop) the plugin, it will still continue in the background.
If you start it several times you'll have mulitple of those timers running on the old code.
— Reply to this email directly, view it on GitHub https://github.com/dkandalov/live-plugin/issues/149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAG5V7A6ZHRPMQGM7VOOYTWEAF2FANCNFSM6AAAAAARJHMCDY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thanks for the update, I tried and didn't work for me. Though I'm not a java developer ;) It would be nice if there was a liveplugin callback that can be registered which is called on load, reload and on unload.
This is not specific to Java.
- On plugin load the code in
plugin.kts
is executed - On unload
pluginDisposable
is disposed (which is basically a callback for unload, e.g. withpluginDisposable.whenDisposed { ... }
; see also https://plugins.jetbrains.com/docs/intellij/disposers.html) - Reload is unload followed by load
It might be useful to add to LivePlugin a wrapper API for AppExecutorUtil
which will require pluginDisposable
and will cancel scheduled tasks on plugin reload. There're many other areas in IJ or Java API which don't use Disposables though so it's hard to draw a line 🤔
Imho it doesn't fit to the idea of "unloading" a plugin that it keeps 'lost' background tasks in the IDE context. I understand it's normal behavior and not a bug, I'd still try to prevent it from happening. A wrapper that handles it on LivePlugin's side would be probably the best.
Your LivePlugin is the only thing I found that actually is well working, comes with samples and is not a total pain to implement. I was one step from giving up when I wrote 2 days ago, today my plugin is working :)