Bug 511 : major threading overhaul required before 1.0
Last modified: 2008-08-15 07:11




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P1
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2007-02-03 08:51
this is a compendium of several bugs.
Additional Comment #1 From fry 2007-02-03 08:54
these are all related, but will require a solid block of time to fix
properly, as they have far-reaching implications and cross-platform
inconsistencies:

bug #197 - window fixed at 100 x 100 pixels

bug #282 - window not showing up on linux

bug #369 - need to make alloc() thread-safe

bug #122 - flicker in java2d mode

bug #512 - improve accuracy of frameRate
Additional Comment #2 From fry 2007-02-03 09:43
*** Bug 430 has been marked as a duplicate of this bug. ***
Additional Comment #3 From fry 2007-10-12 06:07
*** Bug 639 has been marked as a duplicate of this bug. ***
Additional Comment #4 From fry 2008-06-01 15:02
textFont() before text(), clashing calls to defaults()
http://dev.processing.org/bugs/show_bug.cgi?id=726
Additional Comment #5 From ewjordan 2008-06-01 18:13
Ok, moving the discussion from bug #726 to here...I promised a log, so here
goes:

(Log of failing case)

PGraphicsJava2D.resize enter100 100
PGraphicsJava2D.allocate enter: w: 100, h: 100
PGraphicsJava2D.allocate exit: w: 100, h: 100
PGraphicsJava2D.resize exit
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Nulling font...
Thread-2 1b draw
PApplet.size: w: 640, h: 480, irenderer: processing.core.PGraphicsJava2D
Renderer was not null.
calling setRendererSize from size() 640 480
PGraphicsJava2D.resize enter640 480
PGraphicsJava2D.allocate enter: w: 640, h: 480
PGraphicsJava2D.allocate exit: w: 640, h: 480
PGraphicsJava2D.resize exit
PGraphicsJava2D.resize enter100 100 ******* this doesn't happen in
successful run
PGraphicsJava2D.allocate enter: w: 100, h: 100
PGraphicsJava2D.allocate exit: w: 100, h: 100
PGraphicsJava2D.resize exit
***********************************
PGraphicsJava2D.resize enter640 480
PGraphicsJava2D.allocate enter: w: 640, h: 480
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Nulling font...
Thread-2 1b draw
PApplet.size: w: 640, h: 480, irenderer: processing.core.PGraphicsJava2D
Renderer was not null.
calling setRendererSize from size() 640 480
PGraphicsJava2D.allocate exit: w: 640, h: 480
PGraphicsJava2D.resize exit
**********************************
Thread-2 3a calling repaint() 1
Thread-2 3b calling Toolkit.sync 1
Thread-2 3c done 1
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Nulling font...
Thread-2 1b draw

java.lang.RuntimeException: use textFont() before text()
at processing.core.PGraphics.text(PGraphics.java:2522)
at processing.core.PApplet.text(PApplet.java:7764)
at Temporary_9656_4770.draw(Temporary_9656_4770.java:14)

Thread-2 thread finished
at processing.core.PApplet.handleDisplay(PApplet.java:1472)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1570)
at java.lang.Thread.run(Thread.java:613)


AWT-EventQueue-0 5a enter paint
AWT-EventQueue-0 5b enter paint sync
AWT-EventQueue-0 5c inside paint sync
AWT-EventQueue-0 6 exit paint


The allocate enter/exit traces are at the top and bottom of that function -
I starred the area of this trace that disturbs me, where allocate gets
interwoven with the drawing stuff. This seems to show up every time it
crashes.

BTW, the "Nulling font..." output happens in PGraphics.defaults(), right
before textFont is set to null.

For comparison's sake, a successful run looks like this:

PGraphicsJava2D.resize enter100 100
PGraphicsJava2D.allocate enter: w: 100, h: 100
PGraphicsJava2D.allocate exit: w: 100, h: 100
PGraphicsJava2D.resize exit
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Nulling font...
Thread-2 1b draw
PApplet.size: w: 640, h: 480, irenderer: processing.core.PGraphicsJava2D
Renderer was not null.
calling setRendererSize from size() 640 480
PGraphicsJava2D.resize enter640 480
PGraphicsJava2D.allocate enter: w: 640, h: 480
PGraphicsJava2D.allocate exit: w: 640, h: 480
PGraphicsJava2D.resize exit
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Nulling font...
Thread-2 1b draw
PApplet.size: w: 640, h: 480, irenderer: processing.core.PGraphicsJava2D
Renderer was not null.
calling setRendererSize from size() 640 480
Thread-2 3a calling repaint() 1
Thread-2 3b calling Toolkit.sync 1
Thread-2 3c done 1
Thread-2 handleDisplay()
Thread-2 1a beginDraw
Thread-2 1b draw
Thread-2 2b endDraw
Thread-2 3a calling repaint() 2
Thread-2 3b calling Toolkit.sync 2
Thread-2 3c done 2
(continues on, looking fine)

Maybe that will give you some idea what's happening...I've been playing
around, synchronizing various bits here and there, but it's very difficult
to tell what fixes anything, since the problem sometimes won't show up for
50 runs, and I don't know the overall threading architecture well enough to
be confident in what should do the trick.
Additional Comment #6 From fry 2008-06-05 10:34
*** Bug 808 has been marked as a duplicate of this bug. ***
Additional Comment #7 From fry 2008-06-11 07:31
*** Bug 369 has been marked as a duplicate of this bug. ***
Additional Comment #8 From fry 2008-06-25 14:37
thanks for the dump, need to just sit down with this one and fight through
all the various scenarios.
Additional Comment #9 From fry 2008-07-24 20:53
*** Bug 853 has been marked as a duplicate of this bug. ***
Additional Comment #10 From fry 2008-08-11 18:05
Found the main cause of the threading problems--I'm calling some GUI stuff
from the animation thread rather than the EDT (basically ping-ponging
between.. oy.) Now working on a fix.
Additional Comment #11 From fry 2008-08-15 07:07
fixed for 0145.