Bug 222596 - SVG images are rendered incorrectly (SVGImage.renderImage() called from different threads)
Summary: SVG images are rendered incorrectly (SVGImage.renderImage() called from diffe...
Status: NEW
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 major
Target Milestone: ---   Edit
Assignee: Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-13 11:41 EDT by Alex Shatalin CLA
Modified: 2011-10-25 10:36 EDT (History)
2 users (show)

See Also:


Attachments
Patch solving the problem by introducing synchronization (958 bytes, application/octet-stream)
2008-03-13 11:47 EDT, Alex Shatalin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Shatalin CLA 2008-03-13 11:41:05 EDT
From time to time all ScalableImageFigures based on the same SVG image are substituted by empty 8x8 figure on my diagrams. Instead of actual figures I can see transparent figures, by looking into the code I found these figures are displaying empty SWT images 8x8 pixels each. Usually re-execution of whole Eclipse instance helps. 

SWT 8x8 images are created in SVGImage.renderImage();, last "catch" block, but looks like the reason of this problem is not in SVGImage implementation. AFAIU, SVGImage is statefull and can (should) be correctly rendered only from one thread. In the same time I can see concurrent calls to the SVGImage.renderImage() method from different threads. Simple workaround for this problem is to make whole method AbstractRenderedImage.getSWTImage() synchronized.

Several threads are created and executed for the same srcImage instance in: RenderHelper.renderSWTImage().
Comment 1 Alex Shatalin CLA 2008-03-13 11:47:02 EDT
Created attachment 92459 [details]
Patch solving the problem by introducing synchronization
Comment 2 Alex Shatalin CLA 2008-03-13 11:51:13 EDT
Another (better) solution for this situation Is to not execute unnecessary second rendering thread at all. This patch should be a little bit more complex and in this case renderSWTImage() method should be corrected.

Nevertheless, looks like attached patch should be applied too because AFAIU at least SVGImage.renderImage() method supposed to be called from one thread only.
Comment 3 Eclipse Webmaster CLA 2010-07-19 21:58:26 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime was the original product and component for this bug
Comment 4 Harald Böhme CLA 2011-10-25 10:36:34 EDT
This problem leads not only to incorrect rendering it also produces SWT errors.
See stack trace from eclipse 3.6.1:

java.lang.NullPointerException
at org.eclipse.swt.graphics.Image.createGdipImage(Image.java:876)
at org.eclipse.swt.graphics.GC.drawImage(GC.java:949)
at org.eclipse.swt.graphics.GC.drawImage(GC.java:943)
at org.eclipse.draw2d.SWTGraphics.drawImage(SWTGraphics.java:417)
at org.eclipse.gmf.runtime.draw2d.ui.render.internal.RenderHelper.drawRenderedImage(RenderHelper.java:148)
at org.eclipse.gmf.runtime.draw2d.ui.render.internal.graphics.RenderedMapModeGraphics.drawRenderedImage(RenderedMapModeGraphics.java:83)
at org.eclipse.gmf.runtime.draw2d.ui.render.internal.RenderHelper.drawRenderedImage(RenderHelper.java:136)
at org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure.paintFigure(ScalableImageFigure.java:380)