Skip to content

ImageJ/FIJI freezes when having a slider-styled input @parameter on top of a script #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
haesleinhuepf opened this issue Jan 11, 2017 · 7 comments

Comments

@haesleinhuepf
Copy link
Member

Hey guys,

I just discovered that Fiji freezes, when I run the following macro. The input dialog opens but it shows no input elements, no buttons and the dialog cannot be closed. Furthermore the CPU goes up to 100%.

// @int(style="slider") channelToAnalyse
print(channelToAnalyse);

E.g. this python script causes the same issue:

# @double(style="slider") channelToAnalyse
print(channelToAnalyse)

As it is language independent, I guess it has something to do with scijavas input widgets.

I'm using a recently downloaded Fiji on MacOS 10.12 (ImageJ 2.0.0-rc-54/1.51h; Java 1.8.0_66 [64 bit])

If you need any other information, I'd be happy to help.

Thanks a lot in advance!

Best,
Robert

@ctrueden
Copy link
Member

I am guessing it is a macOS-specific bug with showing JOptionPane dialogs, which I have seen before. Please try with the latest version of Java. If it still happens, please diagnose the hang.

@haesleinhuepf
Copy link
Member Author

Hi Curtis,

thanks for answering so quickly.

I downloaded the No-JRE FIJI version, which runs then on my current Java (Java 1.8.0_112). The issue persists.

Here comes the stack trace:
https://gist.github.com/haesleinhuepf/08608fc561e7e0c901682fbea01b3a2c

You could be right, the issue may be a deadlock deep inside JWhatever or AquaSliderUI...

Maybe it's just better avoiding the slider at the moment?

Thanks anyway!

Best,
Robert

@ctrueden
Copy link
Member

ctrueden commented Jan 11, 2017

I downloaded the No-JRE FIJI version, which runs then on my current Java (Java 1.8.0_112).

Alternately, you can simply rename the Fiji.app/java to something else, and the launcher will stop using it by default.

Here comes the stack trace:

Relevant parts are:

"AWT-EventQueue-0" #14 prio=6 os_prio=31 tid=0x00000001250e5000 nid=0xf30b in Object.wait() [0x0000700003b31000]
   java.lang.Thread.State: WAITING (on object monitor)
...
	- locked <0x00000005772e36d0> (a java.awt.Component$AWTTreeLock)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)

And:

"SciJava-4eaa679b-Thread-0" #19 prio=5 os_prio=31 tid=0x0000000100ef4000 nid=0xfe07 in Object.wait() [0x0000700003e3f000]
   java.lang.Thread.State: WAITING (on object monitor)
...
	- locked <0x00000005772e36d0> (a java.awt.Component$AWTTreeLock)
	at java.awt.Dialog.show(Dialog.java:1084)
	at java.awt.Component.show(Component.java:1671)
	at java.awt.Component.setVisible(Component.java:1623)
	at java.awt.Window.setVisible(Window.java:1014)
	at java.awt.Dialog.setVisible(Dialog.java:1005)
	at org.scijava.ui.swing.SwingDialog.show(SwingDialog.java:268)
	at org.scijava.ui.swing.widget.SwingInputHarvester.harvestInputs(SwingInputHarvester.java:87)

So yeah, calling show() on the JDialog hangs the EDT for some reason.

There was something similar with JFileChooser with showOpenDialog and showSaveDialog calls, which creates a JDialog and shows it internally. There is a branch with an attempt at fixing itj by using ThreadService.invoke (which uses EventQueue.invokeAndWait internally) but IIRC, that approach does not work, still ending up with the same deadlock.

You could attempt a similar fix in SwingDialog in the show() method. Alternately, you could try commenting out portions of the SwingDialog configuration in between pack() and setVisible(true), and see whether that makes a difference.

I did some google searches looking for reported macOS openjdk bugs along these lines, but did not immediately find anything except this one from 3.5 years ago which I am not sure is the same issue.

I do not have time to dig anymore this month, unfortunately. In the meantime, if you learn more, or find a fix, that would be awesome.

In any case, this is not a scijava-common bug. Any fix/workaround would need to live in scijava-ui-swing or possibly scijava-ui-awt.

@imagejan
Copy link
Member

@haesleinhuepf wrote:

// @int(style="slider") channelToAnalyse

Does adding min=0, max=1 solve the issue for you?

See scijava/scijava-ui-swing#32.

@imagejan
Copy link
Member

imagejan commented Nov 4, 2017

This should be fixed now, with scijava/scijava-ui-swing@32ddc3c by @ctrueden.

@haesleinhuepf
Copy link
Member Author

Thanks @ctrueden and @imagejan for your efforts! Unfortunately, I cannot test this as I don't have MacOS anymore :-/

@imagejan
Copy link
Member

imagejan commented Jan 3, 2018

To be sure, I quickly tested on Mac OSX Sierra (10.12.6). As expected, using your script displays a warning in the console, but doesn't freeze Fiji, so I'm closing this issue.

@imagejan imagejan closed this as completed Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants