Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8038142

[macosx] Graphics2d.drawImage is failing when printing for mac only

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 7u25, 8, 9
    • Fix Version/s: tbd_major
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      JDK 7u51 - is found also in JDK 7u25

      ADDITIONAL OS VERSION INFORMATION :
      Mac OSX 10.9.1

      A DESCRIPTION OF THE PROBLEM :
      When printing with a mac if Graphics2D.drawImage is called an error is thrown in sun.java2d.CRenderer.doImage. This does not appear running the same code on a windows machine. This has been seen since upgrading to Java 7 for macs, and was previously working in Java 6. Also tried on a RC version of Java 8 and the problem still seems to be there.

      REGRESSION. Last worked in version 6u45

      ADDITIONAL REGRESSION INFORMATION:
      JDK 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a program that shows a print screen on a mac and select PDF -> Open PDF in Preview. In the print method of the class that implements Printable call graphics.drawImage and it will cause an error. This same code will work fine on a Windows machine.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Was expecting a PDF to show with the preview of what was to be printed.
      ACTUAL -
      Just got an error message.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      2014-03-12 09:48:20.427 java[9531:1903] Cocoa AWT: Not running on AppKit thread 0 when expected. (
      0 libosxapp.dylib 0x00000001543b895f +[ThreadUtilities getJNIEnv] + 34
      1 liblwawt.dylib 0x000000015434550f syncFromJavaPixels + 1842
      2 liblwawt.dylib 0x000000015434590b LockImage + 75
      3 liblwawt.dylib 0x000000015433fe46 Java_sun_java2d_CRenderer_doImage + 170
      4 ??? 0x00000001062114b9 0x0 + 4397798585
      5 ??? 0x00000001061ff0d8 0x0 + 4397723864
      )
      2014-03-12 09:48:20.427 java[9531:1903] Please file a bug report at http://java.net/jira/browse/MACOSX_PORT with this message and a reproducible test case.
      2014-03-12 09:48:20.432 java[9531:1903] java.lang.StackOverflowError
      at sun.java2d.CRenderer.doImage(Native Method)
      at sun.java2d.OSXSurfaceData.blitImage(OSXSurfaceData.java:1025)
      at sun.java2d.CRenderer.blitImage(CRenderer.java:461)
      at sun.java2d.CRenderer.copyImage(CRenderer.java:479)
      at sun.java2d.CRenderer.copyImage(CRenderer.java:545)
      at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:196)
      at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:3080)
      at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3121)
      at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3065)
      at sun.print.ProxyGraphics2D.drawImage(ProxyGraphics2D.java:856)
      at PrintTest.print(PrintTest.java:25)
      at sun.lwawt.macosx.CPrinterJob$4.run(CPrinterJob.java:593)
      at sun.lwawt.macosx.CPrinterJob.printToPathGraphics(CPrinterJob.java:607)
      at sun.lwawt.macosx.CPrinterJob.printLoop(Native Method)
      at sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:261)
      at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1277)
      at SimplePrint.main(SimplePrint.java:16)
      2014-03-12 09:48:20.540 java[9531:1903] NSAlert is being used from a background thread, which is not safe. This is probably going to crash sometimes. Break on void _NSAlertWarnUnsafeBackgroundThreadUsage() to debug. This will be logged only once. This may break in the future.
      2014-03-12 09:48:22.253 java[9531:1903] An uncaught exception was raised
      2014-03-12 09:48:22.253 java[9531:1903] Printing failed because PMSessionEndDocumentNoDialog() returned -30871.
      2014-03-12 09:48:22.254 java[9531:1903] (
      0 CoreFoundation 0x00007fff8a25a41c __exceptionPreprocess + 172
      1 libobjc.A.dylib 0x00007fff8baeee75 objc_exception_throw + 43
      2 CoreFoundation 0x00007fff8a25a2cc +[NSException raise:format:] + 204
      3 AppKit 0x00007fff8608761e -[NSPrintSpoolingGraphicsContext dealloc] + 43
      4 libobjc.A.dylib 0x00007fff8bae865a _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 502
      5 CoreFoundation 0x00007fff8a144d72 _CFAutoreleasePoolPop + 50
      6 liblwawt.dylib 0x000000015433cb11 Java_sun_lwawt_macosx_CPrinterJob_printLoop + 165
      7 ??? 0x00000001062114b9 0x0 + 4397798585
      )
      2014-03-12 09:48:22.254 java[9531:1903] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Printing failed because PMSessionEndDocumentNoDialog() returned -30871.'
      *** First throw call stack:
      (
      0 CoreFoundation 0x00007fff8a25a41c __exceptionPreprocess + 172
      1 libobjc.A.dylib 0x00007fff8baeee75 objc_exception_throw + 43
      2 CoreFoundation 0x00007fff8a25a2cc +[NSException raise:format:] + 204
      3 AppKit 0x00007fff8608761e -[NSPrintSpoolingGraphicsContext dealloc] + 43
      4 libobjc.A.dylib 0x00007fff8bae865a _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 502
      5 CoreFoundation 0x00007fff8a144d72 _CFAutoreleasePoolPop + 50
      6 liblwawt.dylib 0x000000015433cb11 Java_sun_lwawt_macosx_CPrinterJob_printLoop + 165
      7 ??? 0x00000001062114b9 0x0 + 4397798585
      )
      libc++abi.dylib: terminating with uncaught exception of type NSException


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.applet.Applet;
      import java.awt.print.PrinterException;
      import java.awt.print.PrinterJob;


      public class SimplePrint extends Applet
      {
      public static void main(String[] args)
      {
      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(new PrintTest());
      if (job.printDialog())
      {
      try
      {
      job.print();
      }
      catch (PrinterException e)
      {
      System.out.println("exception - " + e);
      }
      }
      else
      {
      System.out.println("else");
      }
      }
      }





      import java.awt.Graphics;
      import java.awt.GraphicsEnvironment;
      import java.awt.Rectangle;
      import java.awt.Shape;
      import java.awt.Transparency;
      import java.awt.image.BufferedImage;
      import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException;

      public class PrintTest implements Printable
      {
      @Override
      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
      {
      if (pageIndex != 0)
      return NO_SUCH_PAGE;

      Shape shape = new Rectangle(110, 110, 10, 10);
      Rectangle rect = shape.getBounds();

      BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(rect.width,
      rect.height,
      Transparency.BITMASK);
      graphics.drawImage(image, rect.x, rect.y, rect.width, rect.height, null);

      return PAGE_EXISTS;
      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found at this time.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vadim Vadim Pakhnushev
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: