Hi all,

I have noticed some timing issues related to how I am using JSVGCanvas.  I am 
using Java 1.6 and Batik 1.7 on windows.

My program works by:
- Creating a JSVGCanvas 
- Loading a document in the constructor using loadSVGDocument()
- Use a GVTTreeRendererListener to wait until the document is done
- Execute JavaScript code to manipulate portions of the SVG DOM on the 
UpdateManager's RunnableQueue's thread

I see a reasonable amount of sporadic exceptions when I am running my code in a 
test environment (all listed below at the end of the email).  This doesn't 
happen when manually using the software, which makes me think it's a timing 
issue.  A typical test case looks like:

        - Setup
        -- Creates a JSVGCanvas
        -- calls loadSVGDocument()

        - <do whatever the test was going to do>

        - Cleanup
        -- calling dispose() on the JSVGCanvas


Some other things which may be relevant:

- I am invoking dispose() by calling it from the UpdateManager's 
RunnableQueue's thread.  Which thread should I be calling dispose() from?  Is 
there anything I need to check before calling dispose(), like ensuring that the 
UpdateManager is not busy?

- Does it matter which thread I call loadSVGDocument() from?  

- Some test points will call loadSVGDocument() to change the SVG file multiple 
times.  So you can potentially have a single JSVGCanvas that has multiple files 
loaded across its lifetime. 

- Should EVERY method on JSVGCanvas be treated with the idea that it is a Swing 
component, so therefore ALL method calls should be done on EDT?


The exceptions all look to have a similar failure mode where something is in 
the process of being rendered, but an NPE is hit.  It makes me think I am 
committing some updates or disposes on the wrong thread and this is crashing a 
rendering in progress.  Also, for the last two exceptions, I looked at the 
final catch block of the run() method in GVTTreeRenderer, and it is doing a 
printStackTrace().

        
http://apachecode.appspot.com/vs?c=org.apache.batik.swing.gvt.GVTTreeRenderer

This seemed strange because for all the other types of exceptions, it is either 
swallowing them or rethrowing them.  By having the code do a printStackTrace(), 
it prevents any program from ever catching the error.  I am curious if anyone 
knows why this is done.


Any help why I am seeing these exceptions would be appreciated!

Thanks!
 - Andrew



Exception in thread "RunnableQueue-11" java.lang.NullPointerException
        at java.awt.geom.RectangularShape.intersects(Unknown Source)
        at 
org.apache.batik.gvt.AbstractGraphicsNode.getBounds(AbstractGraphicsNode.java:776)
        at 
org.apache.batik.gvt.UpdateTracker.getDirtyAreas(UpdateTracker.java:93)
        at org.apache.batik.bridge.UpdateManager.repaint(UpdateManager.java:569)
        at 
org.apache.batik.bridge.UpdateManager$UpdateManagerRunHander.runnableInvoked(UpdateManager.java:870)
        at 
org.apache.batik.util.RunnableQueue.runnableInvoked(RunnableQueue.java:543)
        at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:251)
        at java.lang.Thread.run(Unknown Source)



java.util.ConcurrentModificationException
        at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
        at java.util.LinkedList$ListItr.next(Unknown Source)
        at 
org.apache.batik.swing.gvt.AbstractJGVTComponent.renderGVTTree(AbstractJGVTComponent.java:727)
        at 
org.apache.batik.swing.svg.AbstractJSVGComponent.renderGVTTree(AbstractJSVGComponent.java:1072)
        at 
org.apache.batik.swing.gvt.AbstractJGVTComponent.scheduleGVTRendering(AbstractJGVTComponent.java:791)
        at 
org.apache.batik.swing.svg.AbstractJSVGComponent.access$701(AbstractJSVGComponent.java:203)
        at 
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.svgLoadEventDispatchCompleted(AbstractJSVGComponent.java:1655)
        at 
org.apache.batik.swing.svg.SVGLoadEventDispatcher$2.dispatch(SVGLoadEventDispatcher.java:173)
        at 
org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103)
        at 
org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
        at org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)



java.lang.IllegalStateException: RunnableQueue not started or has exited
        at 
org.apache.batik.util.RunnableQueue.preemptLater(RunnableQueue.java:323)
        at 
org.apache.batik.bridge.UpdateManager.manageUpdates(UpdateManager.java:275)
        at 
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtRenderingCompleted(AbstractJSVGComponent.java:1762)
        at 
org.apache.batik.swing.gvt.GVTTreeRenderer$4.dispatch(GVTTreeRenderer.java:193)
        at 
org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103)
        at 
org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
        at org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)



java.lang.NullPointerException 
        at java.awt.geom.Rectangle2D.intersect(Unknown Source) 
        at 
org.apache.batik.gvt.AbstractGraphicsNode.getBounds(AbstractGraphicsNode.java:777)
 
        at 
org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:443) 
        at 
org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:165)
 
        at 
org.apache.batik.gvt.filter.GraphicsNodeRed8Bit.genRect(GraphicsNodeRed8Bit.java:140)
 
        at 
org.apache.batik.gvt.filter.GraphicsNodeRed8Bit.copyData(GraphicsNodeRed8Bit.java:116)
 
        at 
org.apache.batik.ext.awt.image.rendered.TranslateRed.copyData(TranslateRed.java:105)
 
        at 
org.apache.batik.ext.awt.image.rendered.PadRed.copyData(PadRed.java:88) 
        at 
org.apache.batik.gvt.renderer.DynamicRenderer.repaint(DynamicRenderer.java:244) 
        at 
org.apache.batik.gvt.renderer.StaticRenderer.repaint(StaticRenderer.java:344) 
        at 
org.apache.batik.swing.gvt.GVTTreeRenderer.run(GVTTreeRenderer.java:123)



java.lang.NullPointerException
        at 
org.apache.batik.gvt.renderer.DynamicRenderer.updateWorkingBuffers(DynamicRenderer.java:85)
        at 
org.apache.batik.gvt.renderer.StaticRenderer.clearOffScreen(StaticRenderer.java:307)
        at 
org.apache.batik.swing.gvt.GVTTreeRenderer.run(GVTTreeRenderer.java:108)



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to