Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes IDEs, Version Control and other tools and the fly likes Netbeans: Problem with Platform Application- Lock-up on Restore from Minimized State Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Netbeans: Problem with Platform Application- Lock-up on Restore from Minimized State" Watch "Netbeans: Problem with Platform Application- Lock-up on Restore from Minimized State" New topic
Author

Netbeans: Problem with Platform Application- Lock-up on Restore from Minimized State

Tyler Prillaman
Greenhorn

Joined: Nov 02, 2012
Posts: 1
I apologize in advance if this question should be located elsewhere in the forum, or if this problem has already been addressed and my attempts to search for it have failed.

I am part of a team that is developing a platform application using the Netbeans 6.8 Platform. Our program has a known issue where, on certain computers, the program will lock-up or otherwise chew through resources upon being restored.

In general, the problem presents itself sporadically. It appears to happen most often when the application has been minimized, the user goes to work in other programs, and then returns to the application. There seems to be no correlation between what the application is currently doing and how often the problem occurs.

Upon the restore from minimized state, multiple things have happened: the application has rendered briefly, then gone completely black; the application fails to render altogether, but parts will appear upon mouseover; a dialog from the application will appear, but once addressed, will not dissappear.

The problem also has varying effects on the processing state of the computer, sometimes only the application is affected. Sometimes, the application and the IDE will become unresponsive. And in some cases, the entire computer locks-up, preventing even the task manager from being launched. On occassion, the application will recover from this state, but most times it will not. When the task manager can be launched, it appears that the process running the application generally takes more than 50% cpu power.

About the application: It is multi-threaded, multi-windowed (using TopComponent), and makes a number of network calls in addition to managing the user interface. We have been unable to make a connection between any of these windows being open and the problem occuring.

The problem has occurred on three machines, an XP 64-bit 2GHz 8GB RAM Dell machine (experienced complete computer lockup), an XP 64-bit 2GHz dual-core Dell laptop (locked-up with dialog but Netbeans IDE recovered), and a Windows 7 64-bit 2.8GHz dual core Dell laptop (experiences the problem most often). A fourth machine has never seen the problem, Windows 7 64-bit 2.67Ghz quad-core 4GB RAM.

The problem has occurred from within the IDE in both Run and Debug mode, and outside of the IDE as a zip distribution.
It is hard to replicate this issue, and no method we have tried yet can do so reliably. I appreciate any help or insight that can be given.
David Irving
Greenhorn

Joined: Jan 28, 2015
Posts: 1
Solution:

I sorted this by creating a tiny window (temporarily) in the corner of the screen that appeared for 1 second, every few minutes and also load the file i/o to create a temp file on disk at the same time.
I have since left Netbeans apps minimised for over 2 hours now and they come back to life with no problems.

This is the class I produced to do the work. You need to pass it the encapsulating frame to recognise when it is minimised or restored.

/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Crispin licence can be seen at http://www.crispindynamics.com/Licences/general-licence.txt.
*/
package com.crispin.icost;

import com.crispin.icadcore.ICadFileSystem;
import com.crispin.icost.gui.CostSummaryTopComponent;
import com.crispin.nbutils.NBUtils;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import org.openide.util.Exceptions;
import org.openide.windows.WindowManager;

/**
*
* @author dirving
*/
public class MinimisedChecker implements Runnable, WindowListener
{

private static MinimisedChecker checker = null;
boolean minimised = true;
JFrame frame;
boolean running = false;
long ticks = 0L;
SimpleDateFormat format;

public static MinimisedChecker getDefault()
{
if (checker == null)
{
checker = new MinimisedChecker();
Thread checkThread = new Thread(checker);
checkThread.start();
}
return checker;
}

private MinimisedChecker(JFrame frame)
{
frame.addWindowListener(checker);
minimised = findInstance.isShowing();
ticks = new Date().getTime();
format = new SimpleDateFormat("HH:mm:ss");
}


public void run()
{
running = true;
int oneMinute = 60000; // 60000; // 1 minute.
int refreshPeriod = 3 * oneMinute;
int cnt = refreshPeriod;
while (running)
{
synchronized (this)
{
try
{
wait(oneMinute);// 1 sec.
cnt -= oneMinute;
}
catch (InterruptedException ex)
{

}
}
if (!minimised)
{
cnt = refreshPeriod;
}
else
{
if (cnt < 0)
{
loadFunction();
cnt = refreshPeriod;
}
}
}
}

public void loadFunction()
{
Date date = new Date();
long time = date.getTime();
long period = time - ticks;
period /= 1000;// seconds
period /= 60; // minutes.
String timeStr = format.format(date);
String minStr = "Costing : minimised for ... " + period + " mins @ " + timeStr;

JWindow win = new JWindow();
JPanel panel = new JPanel();
win.add(panel);
panel.add(new JLabel(minStr));
win.pack();
win.setVisible(true);
synchronized (this)
{
try
{
wait(1000);// 1 sec.
}
catch (InterruptedException ex)
{

}
}
win.setVisible(false);
// access io.
String workingPath = "c:/tmp"; // create a temporary area to place a temp file
workingPath += File.separator + "minimised.txt";
FileWriter fWriter;
try
{
fWriter = new FileWriter(workingPath);
PrintWriter writer = new PrintWriter(fWriter);
String buffer = "0123456789abcdefghijklmnopqrstuvwxyz";
writer.println(minStr);
writer.println(timeStr);
for (int i=0; i<1024; i++)
{
writer.println(buffer);
}
writer.flush();
writer.close();
buffer = buffer.substring(1) + buffer.charAt(0);
}
catch (IOException ex)
{
Exceptions.printStackTrace(ex);
}

}

@Override
public void windowOpened(WindowEvent e)
{
}

@Override
public void windowClosing(WindowEvent e)
{
running = false;
}

@Override
public void windowClosed(WindowEvent e)
{
}

@Override
public void windowIconified(WindowEvent e)
{
minimised = true;
}

@Override
public void windowDeiconified(WindowEvent e)
{
minimised = false;
}

@Override
public void windowActivated(WindowEvent e)
{
}

@Override
public void windowDeactivated(WindowEvent e)
{
}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Netbeans: Problem with Platform Application- Lock-up on Restore from Minimized State