Greetings Michael, All, Thanks for the info, albeit, I was responding to Kenneth's conundrum of why the NonBlockingGenericDialog did not show even though it sits in showDialog. The FindWindow plugin that I provided was more for fixing the problem than debugging the problem. Although FindWindow has some useful features when the main 'Window' menu is faulty(especially after Help>Refresh Menus) / limited. FindWindow will show all, and only, the windows (images / dialogs/text) that ImageJ currently knows about; especially useful if you have more plugins and/or images than vertical screen space to show them in the 'Window' menu. The main impetus for writing FindWindow was to place the 'hard to find image / dialog/text' where I can find it and see it. I added a few added benefits that I can not find using the GUI menu items. Bonus: run any plugin and pass that mysterious 'arg' parameter.
For debugging: I always run the ImageJ in a terminal window as some critical messages are only output there. If you need to run the 'kill' command from that same window and you did not start ImageJ in the background you can type Ctrl-z bg<enter> to background ImageJ. Or better yet, Ctrl-\ will send the SIGQUIT to the foreground process. 'java' is the process, not ImageJ; at least on Fedora. So; pidof java ps -C java ps alxgww | egrep ImageJ This last one I use during debugging as it gives me a lot of information, such as the actual cmdline used to start ImageJ. I have just found a webpage with useful info on getting backtraces from a JVM; even on Windows! https://stackoverflow.com/questions/10756105/how-to-get-a-complete-stack-trace-of-a-running-java-program-that-is-taking-100 I also use Plugins>Utilities>Monitor Memory..., as sometimes a plugin will mysteriously just stop and quit (or something does not do something; e.g. Copy To System) when ImageJ runs out of memory. I only use AWT stuff, as I do not want to have to debug the issue(s) that you mentioned. Kenneth, if this problem still happens and you can modify the code: Add a try/catch block around all callback methods, as exception thrown within them are mysteriously caught and ignored: try { // callback code } catch(Throwable e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); IJ.error(sw.toString()); } I seem to be very good at causing the plotting routines to throw exceptions... Enjoy, Fred On Mon, November 18, 2024 10:17 am, Michael Schmid wrote: > On 16.11.24 07:42, Fred Damen wrote: > > There is a signal that you can send to the JVM that will > > give a backtrace of each thread. This may give information > > as to if the thread with the genericdialog got hung some how??? > > Hi Fred, > > on Linux (and probably MacOs), if you start ImageJ from the command > line, you can type > kill -3 <PID> > where <PID> is the process ID of ImageJ. > This is best done in a second terminal window (not the one where you > have started ImageJ). Alternatively, start ImageJ with a trailing '&', > then you can issue the 'kill -3' in the same terminal window. > > You can get the PID of ImageJ with > ps -C ImageJ > > I don't think that Windows has anything equivalent, but you could have a > look here: > https://access.redhat.com/solutions/19170 > > Anyhow, do you see the dialog in the list of Windows in ImageJ? Then > there is some probability that it has width=height=0 or that it is > outside the visible screen. > > In this case: Create a text widndow before you start your plugin, select > Macros>Enter Interactive mode... and type > js > to enter JavaScript mode > Then start your plugin, and type > w=WindowManager.getWindow("my dialog title"); > with the dialog title as it appears in the Windows menu. > Then you can probe the properties of that dialog window, e.g. > w.getWidth(); > > Otherwise: > > If everything in ImageJ is frozen (if clicking on "Window" does not show > the menu), then it is likely that the EventQueue is stuck because of a > deadlock. > If so, do you mix SWING and AWT in your user interface? > If you use SWING, you must make sure that everything that modifies the > user interface (crating dialogs, adding/changeing components) must be > done in the EventQueue, best with EventQueue.invokeLater. > > > Michael > ________________________________________________________________ > On 16.11.24 07:42, Fred Damen wrote: >> Some of my plugins create dozens of images. After needing to see a >> particular window and can not find it, I discovered they existed but had >> 0 >> width and 0 height. After several fixes were made in ImageJ's displaying >> ImageWindow(s) they no longer showed as w0h0. Some time they show up >> with >> incorrect imagecanvas width/height, but I figured out how to fix that. >> >> I have had genericdialog(s) not display during development, although >> infrequent and not reproducible; probably coding blunders. >> >> There is a signal that you can send to the JVM that will give a >> backtrace >> of each thread. This may give information as to if the thread with the >> genericdialog got hung some how??? >> >> Fred >> >> On Fri, November 15, 2024 9:08 pm, Kenneth Sloan wrote: >>> yes - displaying the dialog box with 0 width and 0 height would explain >>> the reported symptoms. >>> >>> Any idea what causes it? >>> >>> -- >>> Kenneth Sloan >>> [email protected] >>> Vision is the art of seeing what is invisible to others. >>> >>> >>> >>> >>> >>>> On Nov 15, 2024, at 17:13, Fred Damen <[email protected]> wrote: >>>> >>>> Greetings Kenneth, >>>> >>>> I have experienced the same, but different, angst(s) in the past. I >>>> had >>>> ImageWindow(s) that were displayed with zero width and zero height, >>>> and, >>>> I >>>> created TextWindow(s) but never show(ed) them - but they stayed around >>>> after the plugin exited; both hard to see / deal with using ImageJ GUI >>>> menu commands. I wrote my FindWindow plugin to rectify these, and >>>> other, >>>> issues. Its also helpful to work around the problems with the Window >>>> menu. >>>> >>>> See attached (remove .txt extension as we can not attach .java files) >>>> >>>> Enjoy, >>>> >>>> Fred >>>> >>>> ps: On Linux you can see all the windows that exist. My naive >>>> recollection >>>> Windows / MacOS only shows the Application instances that exist, but >>>> you >>>> may find a way to find all windows? I would assume that there is some >>>> way >>>> to ask the JVM what windows it thinks exists? >>>> >>>> >>>> On Fri, November 15, 2024 12:00 am, Kenneth R Sloan wrote: >>>>> yes - it works on my machine, too. but, it fails (silently waiting, >>>>> with >>>>> no dialog displayed) on three other machines. it had been workibg on >>>>> those >>>>> machines, too, for months. >>>>> >>>>> i was hoping this had happened to someone else. i fully expect it to >>>>> work >>>>> >>>>> i ââ,ˆ "fixedââ,¬Ã it by commenting out this code, >>>>> removing the user >>>>> option to >>>>> change these patameters, and all is well - even thought there is >>>>> another >>>>> NonBlockingGenericDialog further along in the cide. I >>>>> canââ,‰"¢t >>>>> remove that >>>>> one! >>>>> >>>>> Behavior that cant be replicated is a bitch to debug! I was hoping >>>>> that >>>>> someone else had run into this and knew what it was. >>>>> >>>>> The only thing common to the failing machines seems to be the local >>>>> network. And it is 1000 miles from me. >>>>> >>>>> even on the failing machines, it was working and then failed only 5 >>>>> minutes >>>>> later, with no updates in between, as far as we know. >>>>> Iââ,‰"¢m not >>>>> sure if >>>>> they restarted FIJI in between success and failure. >>>>> >>>>> Iââ,‰"¢m baffled! >>>>> >>>>> Thanks for confirming that it works somewhere other than my personal >>>>> machine. as near as i can determine, showDialog() is called, but >>>>> dies >>>>> nothing, and never returns, never displays anything, and does not >>>>> throw >>>>> an >>>>> Exception. >>>>> >>>>> -Kenneth Sloan >>>>> >>>>> >>>>> On Thu, Nov 14, 2024 at 22:33 Wayne Rasband <[email protected] >>>>> <mailto:[email protected]>> wrote: >>>>> >>>>>> Hi Kenneth, >>>>>> >>>>>> I converted your test code to JavaScript,n fixed problems with >>>>>> missing >>>>>> variable declarations and ran the script successfully on macOS, >>>>>> Linux >>>>>> and >>>>>> Windows, on my MacBook Air.nths >>>>>> >>>>>> -wayne >>>>>> >>>>>> IJ.log("building dialog"); >>>>>> gd = new NonBlockingGenericDialog("User Paraameters"); >>>>>> IJ.log("created gd"); >>>>>> caseID = "noCaseID"; >>>>>> gd.addStringField("Case ID:",caseID); >>>>>> IJ.log("added Case ID: "+caseID); >>>>>> markerRoiRadius = 10; >>>>>> gd.addNumericField("Marker Radius(pixels):", markerRoiRadius,0); >>>>>> IJ.log("added Marker Radius"); >>>>>> dialogX = 0; >>>>>> dialogY = 0; >>>>>> gd.setLocation(dialogX,dialogY); >>>>>> IJ.log("setLocation "+dialogX+" "+dialogY); >>>>>> gd.showDialog(); >>>>>> IJ.log("gd.wasCanceled() =" + gd.wasCanceled()); >>>>>> IJ.log("getting caseID"); >>>>>> caseID = gd.getNextString(); >>>>>> IJ.log("caseID = "+caseID); >>>>>> markerRoiRadius = gd.getNextNumber(); >>>>>> IJ.log("markerRoiRadius = "+markerRoiRadius); >>>>>> >>>>>> >>>>>>> On Nov 14, 2024, at 3:43 PM, Kenneth Sloan <[email protected] >>>>>>> <mailto:[email protected]>> >>>>>> wrote: >>>>>>> >>>>>>> I have a plugin which has been working for 6 months. >>>>>>> >>>>>>> Today, I got a report that it failed, on both Windows and Mac >>>>>> machines. >>>>>>> >>>>>>> I asked for the input, and tried to replicate the problem. Its >>>>>>> works >>>>>> just fine on my MacBook Pro. >>>>>>> >>>>>>> All machines have been updated to the latest FIJI release. >>>>>>> >>>>>>> I added some logging, so the relevant code looks like this: >>>>>>> >>>>>>> // get user-specified parameters >>>>>>> IJ.log("building dialog"); >>>>>>> NonBlockingGenericDialog gdParms = new >>>>>> NonBlockingGenericDialog("User Paraameters"); >>>>>>> IJ.log("created gdParms"); >>>>>>> String caseID = "noCaseID"; >>>>>>> gdParms.addStringField("Case ID:",caseID); >>>>>>> IJ.log("added Case ID: "+caseID); >>>>>>> gdParms.addNumericField(ââ,ˆ "Marker >>>>>>> Radius(pixels):ââ,¬ÃÂ, >>>>>> markerRoiRadius,0); >>>>>>> IJ.log("added Marker Radius"); >>>>>>> gdParms.setLocation(dialogX,dialogY); >>>>>>> IJ.log("setLocation "+dialogX+" "+dialogY); >>>>>>> gdParms.showDialog(); >>>>>>> IJ.log("gdParms.wasCanceled() =" + gdParms.wasCanceled()); >>>>>>> if(gdParms.wasCanceled()) return; >>>>>>> IJ.log("getting caseID"); >>>>>>> caseID = gdParms.getNextString(); >>>>>>> IJ.log("caseID = "+caseID); >>>>>>> markerRoiRadius = (int)gdParms.getNextNumber(); >>>>>>> IJ.log("markerRoiRadius = "+markerRoiRadius); >>>>>>> >>>>>>> The Log window ends with the line: >>>>>>> >>>>>>> SetLocation 0 0 >>>>>>> Soââ,¬Ã¦ the statement: >>>>>>> >>>>>>> gdParms.showDialog(); >>>>>>> >>>>>>> Appears to have been executed, but nothing appears on the screen, >>>>>>> and >>>>>> the program stalls. >>>>>>> >>>>>>> There is no relevant output in the Console window. >>>>>>> >>>>>>> We have rebooted, updated FIJI, all to no avail. >>>>>>> >>>>>>> It fails on 3 machines (2 Windows and one Mac) in a research lab in >>>>>>> a >>>>>> medical center, but works perfectly on my MacBook Pro, at home. >>>>>>> >>>>>>> The initial report claims that they were using the plugin on a >>>>>>> series >>>>>> of >>>>>> cases. >>>>>>> It worked on a bunch of cases, and then failed on the next (and has >>>>>> failed at their location every time since). Ss soââ,¬Ã¦no >>>>>> FIJI >>>>>> update or >>>>>> OS >>>>>> update between the last success and the first failure. >>>>>>> >>>>>>> Iââ,‰"¢m baffled. Any ideas? >>>>>>> >>>>>>> Finally, the user reports that when the plugin stalls, all other >>>>>>> FIJI >>>>>> functions work properly. Itââ,‰"¢s as if >>>>>> ââ,ˆ "showDialog()ââ,¬Ã >>>>>> has either >>>>>> terminated >>>>>> the plugin (without anything in the Log or Console window), or is >>>>>> waiting >>>>>> for an input (but has not actually displayed the dialog box). I >>>>>> asked >>>>>> them >>>>>> to hit ESC, which had no effect. >>>>>>> -- >>>>>>> Kenneth Sloan >>>>>>> [email protected] >>>>>>> Vision is the art of seeing what is invisible to others. >>>>>>> >>>>>>> -- >>>>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>>>>> >>>>>> >>>>>> -- >>>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>>>>> >>>>> >>>>> -- >>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>>>> >>>> >>>> -- >>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>>> <FindWindow.java.txt> >>> >>> >>> -- >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>> >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
