piccolo2d / piccolo2d.java

Structured 2D Graphics Framework
http://piccolo2d.org
Other
51 stars 14 forks source link

SWTGraphics2D keeps invalid caches #206

Closed mro closed 9 years ago

mro commented 9 years ago

Originally reported on Google Code with ID 206

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?).

Reported by akurtakov on 2011-01-28 09:49:41


mro commented 9 years ago

Reported by akurtakov on 2011-01-28 09:51:05

mro 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.

Reported by heuermh on 2011-02-03 19:44:39

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

Reported by akurtakov on 2011-02-03 21:45:34

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

Reported by heuermh on 2011-02-03 22:49:13

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

Reported by akurtakov on 2011-02-04 07:06:06

mro 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.

Reported by heuermh on 2011-02-18 16:26:58

mro 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.

Reported by heuermh on 2011-02-18 17:19:12

mro 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.

Reported by atdixon on 2011-02-26 22:28:31

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

Reported by atdixon on 2011-02-26 22:29:22

mro 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."

Reported by atdixon on 2011-02-26 22:55:01

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

Commits look good, marking as Fixed.

Reported by heuermh on 2011-02-27 06:11:59

mro commented 9 years ago

Reported by atdixon on 2011-04-02 02:35:15