Ticket #1662 (closed enhancement: fixed)
Opened 2013-03-07T10:43:25-06:00
Last modified 2013-07-16T13:42:17-05:00
Fiji to include ImageJ2
Reported by: | bdezonia | Owned by: | dscho |
---|---|---|---|
Priority: | blocker | Milestone: | imagej2-b8-analysis |
Component: | Legacy Compatibility | Version: | |
Severity: | critical | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #1914 |
Description
We should ship all of ImageJ2 with Fiji. Users would work in IJ1 as usual but the switch to modern mode plugin would be operational in the menu and would switch to IJ2. Of course users can go back to IJ1 with the same legacy mode menu toggle.
Change History
comment:1 Changed 2013-03-22T15:42:27-05:00 by dscho
- Type changed from defect to enhancement
- Component changed from Analysis Plugins to Legacy Compatibility
comment:2 Changed 2013-03-22T18:12:57-05:00 by dscho
The idea is to provide support in Fiji to start up in legacy mode and switch to the modern mode via "Help>Switch to Modern Mode".
A couple of things need to be done for that:
- fiji-compat's Javassist hacking needs to be aware of, and needs to call, ij-legacy's Javassist hacking. This is required because we want to run ij-legacy basically in legacy mode, i.e. accumulating information such as which files have been opened, to be processed properly when ImageJ2 is turned on.
- an ImageJ2 context needs to be constructed upon start-up. This might have to be done in the background if it turns out that ImageJ2's context construction slows down Fiji's start-up too much.
- Once switched to modern mode (which might really be a start-up of ImageJ2, rather than making a previously invisible ImageJ2 instance visible), there must not be two Help>Switch to Legacy Mode entries (i.e. Fiji probably needs to remove its Switch to Modern Mode menu item and let ij-legacy add its own version).
comment:3 Changed 2013-03-26T10:36:03-05:00 by dscho
Current progress:
- on ImageJ's ij-legacy-fiji-compat branch and Fiji's ij-legacy branch, the current state of affairs can be inspected.
- Fiji is aware of ij-legacy and gives its LegacyInjector a chance.
- It is possible to hide the IJ1 UI and initialize ImageJ2 and show it, then switch back, already.
Things still to be done:
- ClassLoader problems to address: since fiji-compat now depends on ij-app, we cannot hope to update ImageJ2 stuff via Help>Refresh Menus. To be able to update without a full restart of the JVM, we introduced the imagej.ClassLoaderPlus class, but for the moment this has a subtle bug: in its endeavor to try to avoid an overbounding ClassLoader proliferation, it tries to reuse URLClassLoaders. But the default AppClassLoader *is* a URLClassLoader, and therefore the ClassLoaderPlus adds the new URLs to its own ClassLoader, effectively preventing any reloading via ClassLauncher#restart(). This issue probably needs to be split out into its own ticket, as it is not critical to add Switch To Modern Mode to Fiji.
- At the time of writing, there is a problem in that definition of the CompositeImage class is attempted twice. This is due to the non-transitivity of ClassPool#toClass() (it only marks modified CtClass instances as frozen when they are defined directly via toClass() or when they are direct dependencies of other modified CtClass instances that have been defined via toClass(), but not if they are dependencies of *unmodified* dependencies of other modified CtClass instances).
- The CompositeImage problem points out that it is *required* to merge IJ1Patcher online patching into the LegacyInjector.
- As ImageJ2 is not yet tuned for speed, initializing the Context can take quite a bit of time, at least more than this developer wants to suffer upon clicking Switch To Modern Mode. We should therefore initialize the ImageJ2 Context earlier (and make it a singleton). This will also help running ImageJ2 plugins in Fiji.
- replace Fiji's Switch To Modern Mode with ImageJ2's as soon as Fiji initialized ImageJ2.
comment:4 Changed 2013-03-26T16:55:25-05:00 by dscho
Better than replacing Fiji's Switch To Modern Mode would be to simply add SwitchToModernMode as plugin. This requires SwitchToModernMode to know about the ImageJ Context singleton and reuse it if it is available, initialize if it is not.
The best way to accomplish this would be to add another field to the ij.IJ class (in addition to the _legacyService) that holds the context, creating one if none is yet available.
Unfortunately, there is no elegant way to do it via an interface that would be Javassist'ed onto ij.IJ because interfaces cannot define static methods. So it seems we have to use reflection.
comment:5 Changed 2013-04-15T00:33:07-05:00 by dscho
- Priority changed from major to blocker
- Severity changed from serious to critical
Bumping up the priority.
As to the problem how to access the LegacyService: we could add special-handling for IJ.runPlugIn("imagej.legacy.LegacyService", null) to return _legacyService.
comment:6 Changed 2013-04-26T01:35:39-05:00 by dscho
Progress. Pretty good progress, even. You can now obtain the legacy service using
LegacyService legacyService = (LegacyService) IJ.runPlugIn(LegacyService.class.getName(), null);
and the Context using
Context context = (Context)IJ.runPlugIn(Context.class.getName(), null);
This is a slight abuse of the API, but I think a quite okay one, given that neither LegacyService nor Context will ever be ImageJ 1.x plugins.
On ImageJ2's ij-legacy-fiji-compat and Fiji's ij-legacy branch, the current state already uses ij-legacy's SwitchToModernMode to activate said mode.
Things to be done still:
- ij.Composite does not get initialized properly because Fiji's IJ1Patcher patches it but ImageJ2's LegacyInjector does not. We probably should move most of Fiji's patching over to ij-legacy (with the notable exception of Fiji's Script Editor grafting; we'll leave that in fiji-compat until ImageJ2's Script Editor is used by Fiji).
- Images that have been opened before the LegacyService was initialized are not picked
- Probably the same holds true for ROI Manager and the Results Table
- The same windows, plus Brightness/Contrast, Color Picker, Command Launcher, etc, need to be toggled by toggleLegacyMode, too. In general, every window that was registered with ij.WindowManager.
comment:7 Changed 2013-04-26T17:31:06-05:00 by dscho
I got rid of the clunky branch name ij-legacy-fiji-compat in favor of fiji-compat. An early part is already merged to master (triggering my fixing a long-standing bug that was only apparent on Windows: thanks, Jenkins!).
Current state:
- ij.Composite gets initialized properly because that handling moved to ij-legacy.
- Images that have been opened before the LegacyService was initialized are properly picked up by the modern mode.
- The ROI Manager has been fixed both by Curtis and me (independently; I was working on a branch).
- Most of the fiji-compat stuff still needs to move to ij-legacy.
- Results Table, B/C, Color Picker, Command Launcher (and what else?) still need to be fixed.
Having said that, we could already merge these branches to their respective master and give people a preview today. Let's polish things a bit before that, though.
comment:8 Changed 2013-06-05T15:40:22-05:00 by bdezonia
- Blocking 1914 added; 1661 removed
- Milestone changed from imagej2-b7-ndim-data to imagej2-b8-analysis
comment:9 Changed 2013-07-11T15:03:34-05:00 by dscho
I worked really hard on this issue and finally am very, very close to merging it all.
The fiji-compat branch of imagej.git has now all the legacy patches fiji-compat had, but in a much better form: the LegacyExtensions class has a function using the CodeHacker to insert extension points that call back into LegacyExtensions to obtain settings the application can change easily by calling yet other functions of the same class (e.g. LegacyExtensions.setIcon(File) to change the icon of all the windows registered with ImageJ 1.x' WindowManager class).
The ij-legacy branch of fiji.git has the changes required to make use of the changes in the fiji-compat branch.
All that is needed now is a review of the fiji-compat branch, and then we need to decide how to go forward with Fiji. There are a couple of options:
- release a new beta of ImageJ2 just for that purpose.
- upload a temporary ImageJ2 onto the Fiji update site.
- merge into ImageJ2's master, bu wait until the next beta of ImageJ2 is released until merging into Fiji's master.
In any case, we will need to make a beautiful announcement because there might be disruptions with regard to the patches, i.e. some bugs introduced by that separation.
comment:10 Changed 2013-07-13T14:29:35-05:00 by dscho
So after discussing this with Curtis Rueden, the roadmap is clear:
- we will release an intermediate beta called "7.1" probably this coming Monday.
- we'll upload that to the ImageJ update site.
- we'll edit fiji.git's ij-legacy branch to have that version as dependency (rather than -SNAPSHOT) and merge to master.
- we'll send an announcement about the upcoming changes (and that users relying on a stable system should hold off from updating for a while)
- we'll upload a new fiji-compat.jar to the Fiji update site.
comment:11 Changed 2013-07-16T13:01:22-05:00 by dscho
Steps 1 through 4 have been accomplished (although I postponed step 2 -- the upload to the update site -- to Tuesday to leave users time after reading the mail sent on Monday -- which was step 4).
Step 5 will be performed now.
comment:12 Changed 2013-07-16T13:30:13-05:00 by dscho
Bah. I forgot to make sure that the new ImageJ launcher was uploaded to the update site. So for a couple of minutes, everybody who updated got a non-functional Fiji because of class path issues. But now everything should be cozy again.
comment:13 Changed 2013-07-16T13:42:17-05:00 by dscho
- Status changed from new to closed
- Resolution set to fixed
Looks like it.