Il giorno lun, 15/06/2009 alle 13.37 -0700, Jim Graham ha scritto: > Hi Mario, > > How are the drawGlyphList methods called when the loops is null? I ask > because they are only ever installed on the SunGraphics2D object by > virtue of a call to validatePipe() and all calls to validatePipe() > should set the loops. So, there is a bug somewhere that causes these > loops to be installed without a full validate process.
Hi Jim, So, I spent some time today (sorry for the delay, I had to find some free time slot for that and had to make a cake for my girl friend, which was the most difficult part :), and I debugged the Java2D demo with just the non initialised loops (so, no checks for null loops anywhere else in the code). The Demo starts fine, but after some point I get the error attached in this mail. > As I said in the email you quoted. All calls from pipelines > (GlyphListLoopPipe and AATextRenderer are both pipeline objects) should > be safe because all calls to validatePipe() should set the loops. I see that validatePipe is indeed called always, but sometimes the path that is chosen doesn't validate the rendering loop. I've seen that most of the time this is ok, because the loops are not used. I guess this is the case for all the various text rendering (LCD or AA) in swing components, for example (is this correct?). > Having said that I note that there are some pipelines that do not > require loops and it would be OK for a call to validate that only uses > such "non-loop-based" pipelines to leave the loops field uninitialized, > but all validate calls which use loop-based pipes must update the loops > field. Exactly. I'm not deep into the code yet to distinguish when they are needed or not, but... > Eliminating all of those uses of loops we then fall into the case where > the usage in checkFontInfo is the only usage that does not occur from a > pipeline... ...this is exactly the case, putting a null check here solves the NPE. For what I can see, at some point some component needs to paint to an offscreen surface (I don't think the offscreen surface is special, I think it's the application code that drives the bug, but anyway...). This is the background image from the Java2D Intro pane, I think the other pane do something similar. Once the SunGraphics2d object is created, some redering hints are set. This is the application code: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); That is, turn on antialiasing, then: g2.clearRect(0, 0, d.width, d.height); Now what? This of course goes through validatePipe: The first two if/else statements fall through but not this (SurfaceData, line 535 in OpenJDK): } else if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) { This guy sets the pipes but doesn't set the RederingLoops. Then, again application code: scene.render(d.width, d.height, g2); Which after few loops finally renders the string on screen, which causes the crash. So, in other words, everything goes fine until we draw text with the AA redering hints turned on. Of course, before it was not failing because of the rendering loops were initialised in the constructor. I'm not sure if we need to check for a null loops at the beginning of validatePipe or in checkFontoInfo. Maybe we can save something if we use checkFontInfo but I'm not so sure. I hope this helps, Mario -- Mario Torre, Software Developer, http://www.jroller.com/neugens/ aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-44 pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim Geschäftsführer: Dr. James J. Hunt Please, support open standards: http://endsoftpatents.org/ -- Mario Torre, Software Developer, http://www.jroller.com/neugens/ aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-44 pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim Geschäftsführer: Dr. James J. Hunt Please, support open standards: http://endsoftpatents.org/
In various place after some time the demo is started or when selecting the ArcsCurves panel: In Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at sun.java2d.pipe.AATextRenderer.drawGlyphList(AATextRenderer.java:40) at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:72) at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2808) at demos.Arcs_Curves.Arcs.drawDemo(Arcs.java:128) at DemoSurface.paint(DemoSurface.java:303) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5180) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:302) at javax.swing.RepaintManager.paint(RepaintManager.java:1232) at javax.swing.JComponent._paintImmediately(JComponent.java:5128) at javax.swing.JComponent.paintImmediately(JComponent.java:4938) at DemoSurface.paintImmediately(DemoSurface.java:275) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:818) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:712) at javax.swing.RepaintManager.access$700(RepaintManager.java:60) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1647) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:235) at java.awt.EventQueue.dispatchEvent(EventQueue.java:603) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:191) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:186) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178) at java.awt.EventDispatchThread.run(EventDispatchThread.java:139) After selecting the Tranform panel: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at sun.java2d.pipe.GlyphListLoopPipe.drawGlyphList(GlyphListLoopPipe.java:49) at sun.java2d.pipe.GlyphListPipe.drawGlyphVector(GlyphListPipe.java:137) at sun.java2d.pipe.ValidatePipe.drawGlyphVector(ValidatePipe.java:171) at sun.java2d.SunGraphics2D.drawGlyphVector(SunGraphics2D.java:2883) at sun.font.ExtendedTextSourceLabel.handleDraw(ExtendedTextSourceLabel.java:193) at sun.font.Decoration.drawTextAndDecorations(Decoration.java:122) at sun.font.ExtendedTextSourceLabel.draw(ExtendedTextSourceLabel.java:197) at java.awt.font.TextLine.draw(TextLine.java:774) at java.awt.font.TextLayout.draw(TextLayout.java:2638) at demos.Transforms.SelectTx.drawDemo(SelectTx.java:210) at DemoSurface.paint(DemoSurface.java:303) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5180) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:302) at javax.swing.RepaintManager.paint(RepaintManager.java:1232) at javax.swing.JComponent._paintImmediately(JComponent.java:5128) at javax.swing.JComponent.paintImmediately(JComponent.java:4938) at DemoSurface.paintImmediately(DemoSurface.java:275) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:818) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:712) at javax.swing.RepaintManager.access$700(RepaintManager.java:60) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1647) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:235) at java.awt.EventQueue.dispatchEvent(EventQueue.java:603) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:191) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:186) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178) at java.awt.EventDispatchThread.run(EventDispatchThread.java:139)