Bug 19 : println() can quickly hose the environment, making it unresponsive
Last modified: 2005-07-28 15:54




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

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions
Patch to buffer updates to the EditorConsole and post them periodically patch 2005-07-11 14:53 7.54 KB
Simple println performance test sketch text/plain 2005-07-11 14:55 407 bytes

Description:   Opened: 2005-05-12 19:15
problem with a new thread being launched for each message addition. need a
separate thread to handle grabbing the data from the stream, and then when
swing is ready, updating the text.
Additional Comment #1 From stendahl 2005-07-11 14:48
I took a shot at this (see attached patch) and have come up with something that seems to
help. Basically, messages passed to appendText() get buffered and displayed to the console
at a fixed interval (currently 250 ms) using a Swing timer. More importantly, though, the
updates happen using a custom subclass of DefaultStyledDocument, which uses the mass
insert() function. This means, I think, that the JTextPane is only redrawn once for each
batch.

I've only tested it on the Mac (an iBook running Tiger), as that's what I have, but it offers a
significant speed-up for applets running internally. I can run a simple test (attached)
relatively smoothly 150 FPS, and jerkily but still somewhat responsive w/o calling framerate
(). I tried it with externally launched apps (Tom's HTTPClient example), and in presentation
mode. It should be tested on other machines, as I'm a bit nervous that the protected
DefaultStyledDocument interface must act differently (appearance- or performance-wise).

The 250 milliseconds update rate is a compromise between responsiveness and drawing
performance. If the delay is much lower, drawing tends to stop, and if the delay is much
higher, you really notice it. It should probably be in the preferences file.

Anyway, if you get a chance take a look and let me know what you think, and what needs
to be changed or tested.
Additional Comment #2 From stendahl 2005-07-11 14:53
edit]
Patch to buffer updates to the EditorConsole and post them periodically
Additional Comment #3 From stendahl 2005-07-11 14:55
edit]
Simple println performance test sketch
Additional Comment #4 From fry 2005-07-15 07:55
awesome, thanks so much.. this is exactly what i need to get this fixed
(having a test case and testing on multiple platforms is huge)

i'll do a quick test myself but assume that things are working based on
your tests, and get it into rev 92.
Additional Comment #5 From fry 2005-07-15 14:22
now applied for rev 93. keeps fingers crossed & thanks again for your help.
Additional Comment #6 From fry 2005-07-28 15:49
regression found while testing on linux... with this patch, an extra
character on each line can be seen.

if you run a sketch, the ten blank lines inserted just before run will each
have a small square on them, presumably the NUL character that's being
inserted?
Additional Comment #7 From fry 2005-07-28 15:54
closing this bug, filing the regression as bug #118.