imagej / imagej-legacy

ImageJ+ImageJ2 compatibility layer
https://imagej.net/libs/imagej-legacy
BSD 2-Clause "Simplified" License
16 stars 25 forks source link

Fiji freeze when switching to Macro language #227

Closed frauzufall closed 3 years ago

frauzufall commented 4 years ago

Hi,

in a fresh Fiji, clicking New > Script and then Language > IJ1 Macro freezes Fiji. If I debug the Fiji session with Intellij and make a Thread Dump, I get this:

"AWT-EventQueue-0@7141" prio=6 tid=0x15 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at java.lang.String$CaseInsensitiveComparator.compare(String.java:1186)
      at java.lang.String.compareToIgnoreCase(String.java:1239)
      at org.fife.ui.autocomplete.AbstractCompletion.compareTo(AbstractCompletion.java:83)
      at org.fife.ui.autocomplete.AbstractCompletion.compareTo(AbstractCompletion.java:31)
      at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:325)
      at java.util.ComparableTimSort.sort(ComparableTimSort.java:202)
      at java.util.Arrays.sort(Arrays.java:1312)
      at java.util.Arrays.sort(Arrays.java:1506)
      at java.util.ArrayList.sort(ArrayList.java:1462)
      at java.util.Collections.sort(Collections.java:141)
      at org.fife.ui.autocomplete.AbstractCompletionProvider.addCompletion(AbstractCompletionProvider.java:68)
      at net.imagej.legacy.plugin.MacroAutoCompletionProvider.addModuleCompletions(MacroAutoCompletionProvider.java:161)
      at net.imagej.legacy.plugin.MacroLanguageSupportPlugin.getMacroAutoCompletionProvider(MacroLanguageSupportPlugin.java:114)
      at net.imagej.legacy.plugin.MacroLanguageSupportPlugin.getCompletionProvider(MacroLanguageSupportPlugin.java:94)
      at net.imagej.legacy.plugin.MacroLanguageSupportPlugin.install(MacroLanguageSupportPlugin.java:80)
      at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:518)
      at org.scijava.ui.swing.script.TextEditor.setLanguage(TextEditor.java:1795)
      at org.scijava.ui.swing.script.TextEditor.lambda$new$3(TextEditor.java:425)
      at org.scijava.ui.swing.script.TextEditor$$Lambda$94.336010166.actionPerformed(Unknown Source:-1)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
      at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
      at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
      at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
      at java.awt.Component.processMouseEvent(Component.java:6539)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
      at java.awt.Component.processEvent(Component.java:6304)
      at java.awt.Container.processEvent(Container.java:2239)
      at java.awt.Component.dispatchEventImpl(Component.java:4889)
      at java.awt.Container.dispatchEventImpl(Container.java:2297)
      at java.awt.Component.dispatchEvent(Component.java:4711)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
      at java.awt.Container.dispatchEventImpl(Container.java:2283)
      at java.awt.Window.dispatchEventImpl(Window.java:2746)
      at java.awt.Component.dispatchEvent(Component.java:4711)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(AccessController.java:-1)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
      at java.awt.EventQueue$4.run(EventQueue.java:733)
      at java.awt.EventQueue$4.run(EventQueue.java:731)
      at java.security.AccessController.doPrivileged(AccessController.java:-1)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I don't have time to debug this further, but just a guess, is it maybe wrong that the autocompletion provider installing is happening in the AWT thread?

EDIT so maybe that's actually a scijava-ui-swing issue in EditorPane.setLanguage...

ndefrancesco commented 4 years ago

Hi Deborah @frauzufall!

I can't reproduce the issue in Windows 10. You are using Mac OS, right?

frauzufall commented 4 years ago

I'm using Xubuntu 19.04

ctrueden commented 4 years ago

Doesn't happen on my macOS 10.14 system either. @frauzufall If this is still a problem in a couple of weeks, I'm happy to help debug it during the hackathon.

frauzufall commented 4 years ago

Turns out it does not freeze, it just takes minutes until it is done. Not reproducible on other machines, but the autocomplete library sorting mechanism is problematic. @haesleinhuepf is on it.

imagejan commented 3 years ago

I assume this was fixed by merging #233, so I'm closing it. Please feel free to reopen if the issue persists.