google-code-export / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
2 stars 1 forks source link

SWTGraphics2D keeps invalid caches #206

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In SWTGraphics2D.decrementGCCount() if there are no more references all 
resources in the caches are disposed but they are keeped in them. This is a 
real problem because next time one request e.g. some Font(that has been used 
already) it will be found in the FONT_CACHE and returned but every node that 
tries to use if will make swt fail badly due to trying to use disposed font.
The attached test case shows the problem.
The other attachment is a patch that fixes the problem/makes the test case 
patch.
The problem has been found while porting pydev to use latest released piccolo2d 
(1.3) so it will really help if an updated stable version can be issued 
(1.3.1?).

Original issue reported on code.google.com by akurta...@gmail.com on 28 Jan 2011 at 9:49

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by akurta...@gmail.com on 28 Jan 2011 at 9:51

GoogleCodeExporter commented 9 years ago
The unit test only fails for me on svn trunk

$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Piccolo2D SWT 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.piccolo2d.extras.swt.SWTGraphics2DTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.438 sec <<< 
FAILURE!
Running org.piccolo2d.extras.swt.PSWTHandleTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running org.piccolo2d.extras.swt.PSWTPathTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running org.piccolo2d.extras.swt.PSWTCanvasTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running org.piccolo2d.extras.swt.PSWTBoundsHandleTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running org.piccolo2d.extras.swt.PSWTImageTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running org.piccolo2d.extras.swt.PSWTTextTest
Tests run: 14, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0 sec <<< 
FAILURE!

Results :

Tests in error:
  testCacheCleanup(org.piccolo2d.extras.swt.SWTGraphics2DTest)
  testConstructorRemembersTextValue(org.piccolo2d.extras.swt.PSWTTextTest)
  testTextPersistsTrainingAndInternalNewlines(org.piccolo2d.extras.swt.PSWTTextTest)
  testShrinkingFontShrinksBounds(org.piccolo2d.extras.swt.PSWTTextTest)
  testTranslatingDoesntAffectSize(org.piccolo2d.extras.swt.PSWTTextTest)

Tests run: 39, Failures: 0, Errors: 5, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.453s
[INFO] Finished at: Thu Feb 03 13:36:22 CST 2011
[INFO] Final Memory: 6M/495M
[INFO] ------------------------------------------------------------------------

not on the 1.3 release branch

$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Piccolo2D SWT 1.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running edu.umd.cs.piccolox.swt.PSWTTextTest
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.375 sec
Running edu.umd.cs.piccolox.swt.PSWTHandleTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running edu.umd.cs.piccolox.swt.PSWTImageTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec
Running edu.umd.cs.piccolox.swt.PSWTBoundsHandleTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running edu.umd.cs.piccolox.swt.PSWTPathTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running edu.umd.cs.piccolox.swt.SWTGraphics2DTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running edu.umd.cs.piccolox.swt.PSWTCanvasTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests run: 39, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.438s
[INFO] Finished at: Thu Feb 03 13:37:04 CST 2011
[INFO] Final Memory: 6M/495M
[INFO] ------------------------------------------------------------------------

This is on windows with SWT version 3.5.1.

Original comment by heue...@gmail.com on 3 Feb 2011 at 7:44

GoogleCodeExporter commented 9 years ago
It definetely fails for me when using swt 3.6.1 and binary 1.3 release

Original comment by akurta...@gmail.com on 3 Feb 2011 at 9:45

GoogleCodeExporter commented 9 years ago
ok, thanks.  I'll try updating swt to 3.6.1.

Original comment by heue...@gmail.com on 3 Feb 2011 at 10:49

GoogleCodeExporter commented 9 years ago
I should have said that I'm testing on linux only.

Original comment by akurta...@gmail.com on 4 Feb 2011 at 7:06

GoogleCodeExporter commented 9 years ago
Applying patch to svn trunk

$ svn commit -m "applying patch and unit test from Issue 206 to clear caches" .
Sending        swt/src/main/java/org/piccolo2d/extras/swt/SWTGraphics2D.java
Adding         swt/src/test/java/org/piccolo2d/extras/swt/SWTGraphics2DTest.java
Transmitting file data ..
Committed revision 1104.

Original comment by heue...@gmail.com on 18 Feb 2011 at 4:26

GoogleCodeExporter commented 9 years ago
I'm still not seeing the unit test fail on branches/release-1.3 or on 
tags/release-1.3 on x86 linux with jdk

$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1~10.04.1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)

and swt versions 3.3.0-v3346 (the minimum of the version range specified in 
pom.xml) through 3.6.1.

Original comment by heue...@gmail.com on 18 Feb 2011 at 5:19

GoogleCodeExporter commented 9 years ago
I am able to reproduce this in release-1.3 and trunk (pre-patch) if I run the 
test in solitude:

mvn test -Dtest=SWTGraphics2DTest

I noticed that if I run the full swt test suite in trunk, the SWTGraphics2DTest 
runs first, but if I run the sweet in branch, it runs last. Since this defect 
is sensitive to reference counting via SWTGraphics2D.decrementGCCount(), I 
believe the other tests are not leaving SWTGraphics2D.CACHE_COUNT == 0, and 
therefore no resources are getting disposed when SWTGraphics2DTest runs--and 
consequently the test is succeeding.

Michael, I'll go ahead and apply the fix to release-1.3.1 now.

Original comment by atdi...@gmail.com on 26 Feb 2011 at 10:28

GoogleCodeExporter commented 9 years ago
Oops, sweet = suite. Lol.

Original comment by atdi...@gmail.com on 26 Feb 2011 at 10:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ok, disregard my comment about not having commit access. 

I've commited patch to release-1.3:

   "Committed revision 1106."

This commit also includes a slight change to the swt pom.xml to allow Mac OS 
developers to run the SWT unit tests (which, on Macs require JVM argument 
-XstartOnFirstThread.)

I've also commited this slight pom change to trunk:

   "Committed revision 1105."

Original comment by atdi...@gmail.com on 26 Feb 2011 at 10:55

GoogleCodeExporter commented 9 years ago
Thanks, I do see the problem now if I run the test in isolation.

Commits look good, marking as Fixed.

Original comment by heue...@gmail.com on 27 Feb 2011 at 6:11

GoogleCodeExporter commented 9 years ago

Original comment by atdi...@gmail.com on 2 Apr 2011 at 2:35