Other | Other |
---|---|
1.4.1_02 02Fixed | 1.4.2Fixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
Name: jk109818 Date: 07/10/2002 FULL PRODUCT VERSION : java version "1.4.1-beta" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14) Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode) FULL OPERATING SYSTEM VERSION : Microsoft Windows XP [Version 5.1.2600] EXTRA RELEVANT SYSTEM CONFIGURATION : ATI Radeon AGP graphics card 7200 Driver: ati2dvag.dll ver: 6.13.10.6071 (English) DirectX 8.1 (4.08.01.0810) A DESCRIPTION OF THE PROBLEM : Windows XP freezes (hangs) on Java application exit. I experience this consistantly on all applications that take advantage of image drawing functions. I have not been able to reproduce on other Java applications. Application runs fine but Windows XP freezes indefinitely on exit. Once while running an application using drawImage() to a panel I entered a Windows blue screen complaining of an infinite loop in the video driver. Sometimes the program will exit normally if you simply start and exit with small drawing activity, but a reasonable amount of image drawing activity seems to cause Windows XP to hang on exit. While difficult to pinpoint (since you are left with no errors while your machine reboots), it is probably due to a new incompatibility between the java runtime and video driver. I do not have this problem with any JDK previous to the 1.4.1 beta release. REGRESSION. Last worked in version 1.4 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Compile and run attached program (or any other java application with sufficient image placement activity). 2. Select "Open Image..." from the File menu and select a *.jpg format image that would fit onscreen at full size. For example, a 640 x 480 image is fine. 3. Click on different locations of the loaded image to scramble the 'pieces', observing that the draw functionality is working. Scramble the image pieces, as this seems to be the source of the freeze on application exit. 4. Exit the application and watch Windows freeze. EXPECTED VERSUS ACTUAL BEHAVIOR : Java runtime should gracefully exit, as it almost always has on previous releases of the JVM. Instead, Java appears to be the cause of Windows freezing on exit. ERROR MESSAGES/STACK TRACES THAT OCCUR : There are no error messages, nor output from the JVM. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package scratch; // Freeze.java William Dubel June 30, 2003 import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.util.ArrayList; import java.util.Collections; import javax.swing.border.TitledBorder; public class Freeze extends JFrame { private JMenuItem newGame, quit, about; private JMenu fileMenu; private JPanel puzzleArea, puzzleGrid; private JMenuBar bar; private JFileChooser fileChooser = new JFileChooser(); private Container c; private int tiles = 25; private ArrayList pieces = new ArrayList(); private Game currentGame; private MouseHandler mouseHandler = new MouseHandler(); private ItemHandler itemHandler = new ItemHandler(); public Freeze() { super("ImageTest"); c = getContentPane(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); setJMenuBar(bar = new JMenuBar()); (fileMenu = new JMenu("File")).setMnemonic('F'); (newGame = new JMenuItem("Open Image...",'N')).addActionListener(itemHandler); (quit = new JMenuItem("Exit",'x')).addActionListener (itemHandler); fileMenu.add(newGame); fileMenu.add(quit); bar.add(fileMenu); (puzzleGrid = new JPanel()).setLayout(new GridLayout(1, 1)); puzzleGrid.setSize(300,300); (puzzleArea = new JPanel()).setLayout(new FlowLayout()); puzzleArea.add(puzzleGrid); puzzleArea.setBorder(new TitledBorder("Click on image to scramble")); c.add(puzzleArea,BorderLayout.CENTER); setSize(500,400); addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); } private class MouseHandler extends MouseAdapter { private int first = -1; public void mousePressed(MouseEvent e) { if (first<0 || first >= tiles) { for (int n=0; n<tiles; n++) if (e.getSource() ==pieces.get(n)) { ((Piece)pieces.get(first = n)).setSelected(true); ((Piece)pieces.get(first)).repaint(); } } else { for (int n=0; n<tiles; n++) if (e.getSource()==pieces.get(n)) { ((Piece)pieces.get(n)).repaint (); ((Piece)pieces.get (first)).setSelected(false); puzzleGrid.removeAll(); Collections.swap(pieces, first, n); for (int i=0; i<tiles; i++) puzzleGrid.add((Piece)pieces.get(i)); puzzleGrid.validate(); } first = -1; } } } private class ItemHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { if (e.getSource()==newGame) { int answer = -1; if (answer!=JOptionPane.CANCEL_OPTION) { int result = fileChooser.showOpenDialog (c); if (result! =JFileChooser.CANCEL_OPTION) { File filename = fileChooser.getSelectedFile(); currentGame = new Game ((filename), tiles); puzzleArea.remove(puzzleGrid); puzzleGrid = new JPanel(); puzzleGrid.setLayout(new GridLayout(currentGame.getRows(), currentGame.getCols())); pieces = new ArrayList(); for (int i=0; i<tiles; i++) { Piece temp = new Piece (currentGame, i+1); temp.addMouseListener (mouseHandler); pieces.add(temp); puzzleGrid.add(temp); } puzzleGrid.setSize( (int) currentGame.getSize().getWidth(), (int)currentGame.getSize().getHeight() ); puzzleArea.add(puzzleGrid); pack(); puzzleGrid.validate(); } } } if (e.getSource()==quit) { System.exit (0); } } } public static void main(String [] args) { JFrame puzzlegame = new Freeze(); puzzlegame.setVisible(true); } } class Game { private ImageIcon imageObject; private int complexity; public Game(File filename, int complexity) { this.complexity = complexity; imageObject = new ImageIcon(filename.getPath()); try { while (imageObject.getImageLoadStatus() ==MediaTracker.LOADING) Thread.sleep(10); } catch(InterruptedException ie) { ie.printStackTrace(); } } public Image getImage() { return imageObject.getImage(); } public Dimension getSize() { return new Dimension(imageObject.getIconWidth (),imageObject.getIconHeight()); } public int getRows() { return (int)Math.sqrt(complexity); } public int getCols() { return getRows(); } } class Piece extends JPanel implements Runnable { private Dimension size; private Image mini; private int order; private MediaTracker loader; private boolean selected = false; public Piece(Game currentGame, int tile) { size = new Dimension((int)(currentGame.getSize().getWidth ()/currentGame.getCols()), (int) (currentGame.getSize().getHeight()/currentGame.getRows())); mini = currentGame.getImage(); CropImageFilter cropFilter = new CropImageFilter( (((tile%currentGame.getCols()! =0) ? tile%currentGame.getCols() : currentGame.getCols())-1)*(int)size.getWidth(), (int)((Math.ceil((double)tile/currentGame.getCols())-1)*size.getHeight ()), (int)size.getWidth(), (int)size.getHeight()); mini = createImage(new FilteredImageSource(mini.getSource (),cropFilter)); order = tile; loader = new MediaTracker(this); loader.addImage(mini, order); new Thread(this).start(); } public void run() { try { while (loader.statusID(order, true)! =MediaTracker.COMPLETE) Thread.sleep(20); } catch(InterruptedException ie) { ie.printStackTrace(); } repaint(); } public Dimension getPreferredSize() { return size; } public boolean isSelected() { return selected; } public void setSelected(boolean yes) { selected = yes; } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D)g; if (loader.statusID(order, true)!=MediaTracker.COMPLETE) { GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.lightGray, (float)size.getWidth(), (float) size.getHeight(), Color.darkGray); g2.setPaint(gp); g2.fillRect(0, 0, (int)size.getWidth()-1, (int) size.getHeight()-1); } else { g2.drawImage(mini, 0, 0, (int)size.getWidth(), (int) size.getHeight(), this); if (selected) { g2.draw3DRect(1, 1, (int)size.getWidth()-3, (int)size.getHeight()-3, false); g2.draw3DRect(0, 0, (int)size.getWidth()-1, (int)size.getHeight()-1, false); } } } } ---------- END SOURCE ---------- Release Regression From : hopper-beta The above release value was the last known release where this bug was known to work. Since then there has been a regression. (Review ID: 158715) ======================================================================
|