-
Notifications
You must be signed in to change notification settings - Fork 30
feat: implement generic interface for plugins #460
Conversation
|
Hi! I am not sure to understand. Did you not manage to have the OpenVino into its own plug-in snap? Only G'MIC? So that means the OpenVino plug-in is dropped? |
|
@Jehan Yes. From my understanding of the patches OpenVino, GMIC (and any other 3P plug-in) will "mount" on Actually, it was mostly separated but the initialization of some OpenVino things like GPU etc was being done hardcoded in GIMP Snap files. Now, it is done by And I request your security opinion about such enable-plugins Shell file because it allows to run anything the 3P plugin want before GIMP command is run? |
|
@Jehan I ported this MR to our Nightly snap so you can understand the diff easier: https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/2452/diffs |
|
Please note I just added a small commit to add back a few plugs to the GIMP app section. I initially removed these when I began the work and forgot to re-add them. The plug definition was in the original PR but they were not actually being used. |
|
@brunvonlope Yes, I think that captures it well.
OpenVINO is already in its own plug-in snap called The only parts I was unable to remove were the following plugs:
|
I am definitely open to enhancing the script if security is a concern. I purposefully kept it simple to reduce maintenance and make it easy to understand for future plugin packagers. |
|
@frenchwr Regarding |
They are both provided by the |
|
Yeah, I'm fine with these two from |
I see. For For The other option is to only allow users to install models from GIMP, and not from this command that is distributed with the |
Would be nice. On GIMP we normally point user data to |
Well sure, from a security standpoint, it does mean that these third-party snaps can run anything they want. Now I guess it's still within the main sandbox, and yeah when you add code from various sources, you do weaken security. You have to somehow trust the sources for all the code you run. It's not that different from any other system. That's all the more reasons why we want this code separated. We don't want to be responsible for it. We will provide the "entry point" for third-party plug-ins to plug into the GIMP snap, but in the end, it's the people's job (the ones who install GIMP and these third-party plug-ins) to decide if they trust all the software source (us, but also the third-party plug-in developers). So I don't see more of a problem than that. Ideally though if the only use of this all is just to add some environment variables (at least, that's what I see in the .env in the G'MIC snap, though I could not find a But if it really needs to be random shell commands, then I guess… 🤷 |
|
Overall I like the approach. It still seems like we have more than we might need like As for |
It will open a precedent to list plugin specific plugs etc in an upstream manifest. I see that for a downstreamer this is easy and fun but for us (upstreamers) that maintain official packages used by many people this is not acceptable. We can't maintain a manifest with plugin developers reporting to add plugin-specific plugs: etc to privilege specific plugins. We need to stay neutral. |
Ok - let me work on removing these later (hopefully today). We'll lose some convenient features but nothing essential. |
That's the one (well, a slight re-named variation of it is in a PR). It's mostly just setting environment vars but there is a python script that gets run and is needed to do device detection (i.e. CPU, GPU, NPU) at runtime. |
|
The I managed this by (i) installing the |
|
Nice! Thanks Will! @Jehan & @brunvonlope this must be getting pretty close for you? :) |
|
@jnsgruk Seems fine 👍. I will just wait for Jehan final word. I didn't totally understand what he said in this comment #460 (comment) about the wrapper concept: gimp/command-chain/enable-plugins Line 9 in 4157064
|
|
@brunvonlope I mostly said that it's not ideal, but well… I was a bit fatalistic, but maybe we should strive for the best Snap interface. If we settle for "meh", we'll regret it later and it will be hard to change once all plug-ins will start using this.
Why isn't this device detection code in the plug-in itself? In fact, could someone tell me exactly when these If it's to generate some data which needs to be in the Snap, couldn't it be run during the Snap creation? And if it needs absolutely to be run at the start of GIMP, each time the plug-in is updated, this code can be run inside the |
The issue is that the plugins rely on device detection at install-time (you can see the logic here, if you're interested), which is not ideal as generally the snap build environment and snap runtime environment can be very different. I've raised this with the plugin developers but at the moment the snap overcomes this by re-running their logic for device detection each time GIMP is run.
Yes, exactly. Btw, I realize that file naming is a bit unusual. I was looking for a unique naming pattern and I thought |
|
@Jehan @brunvonlope What do you think about the state of this work? Any other feedback or suggestions? |
|
@Jehan Ping to see #460 (comment) |
|
I was planning on suggesting a MR to https://github.com/intel/openvino-ai-plugins-gimp/ I just haven't had the time to look at it yet. But anyway moving their hardware-detection code to My idea is that if we are lax now, then later it's too late because we have created the interface allowing plug-ins to just run random code out of GIMP control. And once the interface is there, it will be hard to remove. P.S.: if anyone gets what I suggest — it should really not be hard to implement at all! —, feel free to make the MR to OpenVino plug-in developers. I don't need to be the one doing it and I've already zillions of things to do. |
|
@frenchwr Now I think things are clearer. What is blocking this MR is the implementation of all the initialization in the plug-in itself. There is the Python reference of GIMP API: https://lazka.github.io/pgi-docs/#Gimp-3.0. Then, without the wrapping concept, we can merge this MR. |
|
If anyone wants to do the MRs, it's pretty easy. Search for On the OpenVino side, I see there are 3 such plug-ins. Then move the Well it's probably not needed in all 3 plug-ins. According to the comments I see in the I was mentioning possibly switching to The whole patch should take just a few minutes to make. That's the testing which is currently blocking me as it means I'd have to install the plug-in, test it, make it sure everything works fine how it should (while I never used it until now) with the patch, etc. It would not take hours, yet still more than someone who already has it all set up. So really anyone, feel free to make this patch before I do. 🤗 |
|
Thanks for the suggestions, @Jehan . I'm open to proposing something to the maintainers, I expect they will be open to it but it may take some weeks for them to test, merge, release, etc. In the meantime we can maintain a patch in the snap package of the plugins. I will take a closer look later this week. You hinted before that you are ok with plugin snaps exporting environment variables within a wrapper that gets called before running GIMP - just making sure that is still the case? If so, I can make changes in this PR that enforces this, where we accept only shell variables expressed as key-value pairs from the |
|
@frenchwr That would be a lesser evil, but is it absolutely needed even? I mean, this is not needed in system packages. This is not needed on Flatpak. Why would this be needed in Snaps? GIMP plug-ins should just have their environment straight when GIMP calls them. It's not very complicated (and it works with the same plug-ins on any other system I know). |
|
@brunvonlope I have pushed another fix (see the commit message for details): f777258 I was seeing a crash on one of the NPU systems before deploying this fix. I have now tested this on two different generations of NPU and everything looks good, but just with my local build. If you could generate a new gitlab build with this fix I will do one last (hopefully!) round of testing. |
|
@frenchwr @Jehan I wonder if f777258 will not make GIMP load the libraries from the plug-in snap first. From my understanding RUNPATH don't have precedente over LD_LIBRARY_PATH. So, this would conflict with the way flatpak behaves? #460 (comment)
|
Yes, that was my intention, but as I've thought more about it I suppose this is too dangerous, as it means a plug-in could break GIMP if it introduces a conflicting lib that GIMP depends on. The reason I need the change is that the OpenVINO plugin snap ships some bleeding edge graphics libs for supporting newer Intel hardware. The plugins do not run at all on Intel Lunar Lake CPUs (which have a GPU and NPU built-int) when using the stock graphical libs that ship with GIMP (actually these are delivered via a different content producer snap). I will re-visit tomorrow. Most likely I will revert f777258 and manage LD_LIBRARY_PATH from the plugin code so that it picks up the newer graphics libs only from its process space without impacting GIMP itself. |
|
Ok, I indeed reverted the last commit, so I'm back to appending to LD_LIBRARY_PATH instead of prepending. This took some refactoring work on the OpenVINO plugins (it's amazing how such a seemingly simple change can complicate things...) but I now have it working on the Lunar Lake system that gave me some problems before. I expect the other two systems should also work fine but let me test those (first thing Monday) just to be sure then we can merge. Hope everyone has a nice weekend. :) |
|
@frenchwr Did the last upstream .snap I linked (which is the same as yours after the revert) worked with OpenVINO? |
Yes, I just need to test on a few more machines on Monday. |
In case plugins ship .so's that are already present inside GIMP, prefer the ones that come with the plugins. This puts the maintenance responsibility on the plugin maintainer for ensuring compatability.
This reverts commit f777258.
|
Success! I've now tested the GIMP 3.1.5 snap from the most recent Gitlab build on three different machines spanning different generations of hardware and Ubuntu releases: both the G'MIC and OpenVINO plugins work across the board. I also rebased against the tip of |
|
Okay, great! I'll take one final look and merge this once the CI passes! Thank you, Will! One thing we probably need to figure out is where to put the docs for adding the OpenVINO and GMIX plugins when using the Snap - perhaps there is somewhere in the upstream docs we can do that @Jehan? |
The binaries will be stored in /snap. Are you talking about the gimp-plugins interface? |
Yeh, I'm talking about a brief docs entry we can send existing users of the snap to, so they know how to get GMIC back, or get OpenVINO back - where previously it was installed as part of the snap, they now need to add extra snaps that place content in the new plugins interface :) |
|
@jnsgruk I think that, for now, we need to mention in the Snap Store description. Ideally, Snap Store itself should do that. See: canonical/snapcraft.io#5240 and ubuntu/app-center#1954 |
|
Oh that's easy enough - just needs adding to the |
I don't think we want to favor specific plug-ins in the documentation. But we can put down command lines to install these in the news which we'll probably publish to announce our new Snap. Ideally though, Snap should have an internal logic to "discover" extensions for another package. That's what they did in Flatpak so that on GNOME Software or other installer GUI, the "GIMP" page has a list of all extensions which can optionally be installed. |
@Jehan Yeah, I filled two issues for this. For the short term, we need to mention these two plugins to not disrupt greatly users expectations. @jnsgruk But in the future I should set a ETA to remove the mentions. Then, we will need collaboration of Cannonical guys with the issues I linked. |
|
Just to make it clearer, the reason why this should not be maintained manually is:
|
Yes, I can work on that - not immediately - but I can start some discussions on how we solve that problem going forward! |
|
@Jehan Just to clarify too: I don't pretend to maintain manually new plugins in a list. What I mean is that we need to mention just these two historic plugins that were being shipped before the generic interface. Otherwise, will be mostly impossible to find them until it is not implemented on Snap Store frontend 😅 |
This PR is motivated by the request in #447 for the upstream GIMP packaging team to take over ownership of this snap.
What has changed
$SNAP/gimp-pluginsWhat has not changed
openvino-ai-plugins-gimpsnap as GIMP itself needs access to the host resources or libs provided by these plugs.Testing
I have tested on my laptop with the following commands.
Note the last command is only needed because the GIMP snap was built and installed locally. Normally this would auto-connect when installed from the Snap Store. We could also pursue auto-connections for the
gimp-plugins-gmicandopenvino-ai-plugins-gimpsnaps.Related work