[squeak-dev] strange bug in squeak 4.2 & 4.3 alpha running Cog, MTCog and regular VMs on a Mac

Bert Freudenberg bert at freudenbergs.de
Tue Sep 6 10:47:44 UTC 2011


On 06.09.2011, at 04:44, Lawson English wrote:

> When I run the following code, I start to get  MNU: UndefinedObject>>containsPoint   errors.
> 
> http://pastebin.com/TTDmSnZS

Not a bug. Morphic is single-threaded and not re-entrant. You must not call any morphic methods from a forked process. If you do, you get exactly those kind of errors.

Instead of forking, use the step mechanism for animation. This is what you would use in a real application.

For prototyping in a workspace, do not fork, but insert a "World doOneCycleNow" in the loop. This should never be used in production code. Here is what this would look like with your example:

n := 100.
myRectArray := (1 to: n) collect: [:i | RectangleMorph new].
rnd := [(-500 to: 500) atRandom].
myGrid := PasteUpMorph new openInWorld.
myGrid extent: 1100 at 1100.
myRectArray do: [:m | myGrid addMorph: m].
p := myGrid center.
Transcript show: ([
	1000 timesRepeat: [
		myRectArray do: [:m | m center: p + (rnd value at rnd value)].
		World doOneCycleNow].
] timeToRun); cr.
myGrid delete.

On my machine this loop takes 5 seconds, so that's 200 fps (animating 100 objects for 1000 frames).

- Bert -





More information about the Squeak-dev mailing list