openplanet-nl / plugin-manager

In-game plugin manager, installer, and updater.
6 stars 5 forks source link

Updating a plugin dependency unloads dependents but doesn't reload them #12

Closed XertroV closed 2 years ago

XertroV commented 2 years ago

Probably low-priority (easy for me to workaround / low impact).

The situation is:

I am not actually sure if any plugins were that were unloaded as being dependent on betterchat were deliberately reloaded since the other 2 (MXRandom and ManiaExchange) were also updated, so maybe they were just reloaded as part of their own update.

this screenshot shows:

image

codecat commented 2 years ago

You are indeed seeing ManiaExchange and MXRandom being loaded because they were also being updated by the plugin manager.

This is happening because the plugin manager doesn't keep an index of unloaded plugins like Openplanet itself does. I'll look into this 👍

XertroV commented 2 years ago

Cool. BTW I noticed that reloading a dependency via ctrl+r does reload the dependent plugins (which is v useful for dev, particularly when importing stuff between two plugins you're actively working on).

codecat commented 2 years ago

Correct, because that is from within Openplanet itself which does index dependencies on reloading. The plugin manager "reloads" plugins in a different way:

  1. Queue the plugin for unload
  2. yield() since the unload is queued and takes 1 frame to complete
  3. Load the plugin

In Openplanet itself, the process is more direct:

  1. Unload the plugin and at the same time create a dependency index
  2. Load the plugin and also reload all dependencies in the index

I'm working on making it so the plugin manager will work in the following way:

  1. Build a sorted dependency index for the plugin we're updating
  2. Queue the plugin for unload
  3. yield() since the unload is queued and takes 1 frame to complete
  4. Load all plugins in the dependency index built earlier (this also includes the updated plugin itself)

I might also have to look into optimizing this process so when multiple plugins are being updated, a singular index is built for all of those plugins rather than an index for each, followed by dependents reloading multiple times.