Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1242

Race condition for UpdateTrack.dirtyNodes from RunnableQueue and AWT-EventQueue



    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.10
    • Fix Version/s: None
    • Component/s: GVT
    • Labels:


      When using the JSVGCanvas set to ALWAYS_DYNAMIC, with a loaded SVG document, that has its style changed externally, the dirtyNodes member of UpdateTracker, will sometimes clear while within the process of a changeStarted.

      When the problem occurs a NullPointerException will be thrown if the race condition manifests itself within the changeStarted code, in the lines:

      boolean doPut = false;
      if (dirtyNodes == null) {
          dirtyNodes = new HashMap();
          doPut = true;
      } else if (!dirtyNodes.containsKey(gnWRef))
          doPut = true;
      if (doPut) {
          AffineTransform at = gn.getTransform();
          if (at != null) at = (AffineTransform)at.clone();
          else            at = new AffineTransform();
          dirtyNodes.put(gnWRef, at);

      When executing the line: dirtyNodes.put(gnWRef, at); the field dirtyNodes is null. This happens because the RunnableQueue thread calls the clear() method in between the initialization and put method.

      This clear method is called from the UpdateManager class in the repaint method, in the lines:

      List dirtyAreas = updateTracker.getDirtyAreas();
      if (dirtyAreas != null) {
          updateRendering(dirtyAreas, false);

      Most likely the updateTracker's dirtyNodes section should be a locked resource, at least within the bounds of changeStarted.

      At other times the problem manifests it self in form of a ConcurrentModificationException spawned from the getDirtyAreas method of UpdateTracker, as called from above. Here it is the iteration of keys that cause the problem. Again dirtyNodes should probably be a locked resource within the confined space of the getDirtyAreas function.

      Below is the list of Batik dependencies used in the project where the problem was seen:

      Maven: org.apache.xmlgraphics:batik-anim:1.10
      Maven: org.apache.xmlgraphics:batik-awt-util:1.10
      Maven: org.apache.xmlgraphics:batik-bridge:1.10
      Maven: org.apache.xmlgraphics:batik-constants:1.10
      Maven: org.apache.xmlgraphics:batik-css:1.10
      Maven: org.apache.xmlgraphics:batik-dom:1.10
      Maven: org.apache.xmlgraphics:batik-ext:1.10
      Maven: org.apache.xmlgraphics:batik-gui-util:1.9
      Maven: org.apache.xmlgraphics:batik-gvt:1.10
      Maven: org.apache.xmlgraphics:batik-i18n:1.10
      Maven: org.apache.xmlgraphics:batik-parser:1.10
      Maven: org.apache.xmlgraphics:batik-script:1.10
      Maven: org.apache.xmlgraphics:batik-svg-dom:1.10
      Maven: org.apache.xmlgraphics:batik-svggen:1.10
      Maven: org.apache.xmlgraphics:batik-swing:1.9
      Maven: org.apache.xmlgraphics:batik-transcoder:1.10
      Maven: org.apache.xmlgraphics:batik-util:1.10
      Maven: org.apache.xmlgraphics:batik-xml:1.10
      Maven: org.apache.xmlgraphics:xmlgraphics-commons:2.2






            • Assignee:
              TommyAndersen Tommy Andersen
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: