ERROR: Message 'top' not understood

Dear users,

Sometimes, sclang returns errors while evaluating the code attached below the error message. I am perplexed because sclang sometimes does not return the errors after evaluating the same code block. It seems to be related to data processing speed due to the TempoClock and the method defer, but I have never seen that error message if I correctly remember. Has anyone seen the following error? It would be greatly appreciated if someone could explain the reason for the errors.

ERROR: Message ‘top’ not understood.
RECEIVER:
nil
ARGS:
PATH: /Users/prko/Dropbox/prko/Lecture/KWU/2022-1/0411.scd

PROTECTED CALL STACK:
Meta_MethodError:new 0x7fb3fb31f9c0
arg this = DoesNotUnderstandError
arg what = nil
arg receiver = nil
Meta_DoesNotUnderstandError:new 0x7fb3fb321d00
arg this = DoesNotUnderstandError
arg receiver = nil
arg selector = top
arg args = [ ]
Object:doesNotUnderstand 0x7fb3f8083840
arg this = nil
arg selector = top
arg args = nil
Meta_Window:flipY 0x7fb3fb3bd840
arg this = Window
arg aRect = nil
var flippedTop = nil
a FunctionDef 0x7fb3ea3ddcc8
sourceCode = “”
a FunctionDef 0x7fb3fb603940
sourceCode = “”
a FunctionDef 0x7fb3f868d700
sourceCode = “”
Function:prTry 0x7fb3fb606d40
arg this = a Function
var result = nil
var thread = a Thread
var next = nil
var wasInProtectedFunc = false

CALL STACK:
DoesNotUnderstandError:reportError
arg this =
< closed FunctionDef >
arg error =
Integer:forBy
arg this = 0
arg endval = 0
arg stepval = 2
arg function =
var i = 0
var j = 0
SequenceableCollection:pairsDo
arg this = [*2]
arg function =
Scheduler:seconds_
arg this =
arg newSeconds = 104130.61858946
Meta_AppClock:tick
arg this =
var saveClock =
Process:tick
arg this =
^^ ERROR: Message ‘top’ not understood.
RECEIVER: nil

The code I evaluated is as follows:

(
Window.closeAll;

s.waitForBoot{
	fork{
		var win, bus, posX, posY, height, width, sig;
		
		# posX,	posY = [{ 20.rand2 }, { 30.rand2 }];
		# height, width = [{ 10.rand2 }, { 20.rand2 }];
		
		bus = Bus.audio(s, 2);
		
		{
			win = Window(border: false);
			win.onClose_{ s.queryAllNodes; fork{ 1.wait; s.quit } }
			.front;
			s.plotTree;
			FreqScope.new(400, 200, 0, server: s);
			s.meter;
			s.scope
		}.defer;
		
		{
			var sig2dac;
			sig2dac = In.ar(bus, 2);
			FreeSelf.kr(DetectSilence.ar(sig2dac.abs.sum / 2.sqrt));
			sig2dac;
		}.play.onFree{ s.queryAllNodes; { win.close }.defer };
		
		10.do{ |i|
			sig = { |freq=4000, ampMod=7|
				var pan, lev, env;
				pan = posX.() / 20;
				lev = width.().linlin(-10, 10, -48.dbamp, -24.dbamp);
				env = Env.sine.kr(doneAction: Done.freeSelf);
				sig = SinOsc.ar(freq.lag(0.05)) * env * SinOsc.kr(ampMod);
				Pan2.ar(sig, pan, lev);
			}.play(s, bus, addAction: \addToHead);
			
			s.sync;
			s.queryAllNodes;
			
			(20-i).do{ |j|
				var colour, posXthis, posYthis, widthThis, heightThis, transparency;
				# posXthis, posYthis = [posX.(), posY.()];
				# widthThis, heightThis = [width.(), height.()];
				
				colour = Color(
					rrand(0, 0.2),
					rrand(0.5, 1),
					rrand(0.5, 0.7),
					0.5.rand
				);
				transparency = sin(i*0.1+j*0.1pi)*0.5+0.5;
				
				0.05.yield;
				
				sig.set(\freq, posYthis + 4000,
					\ampMod, heightThis.linlin(-10, 10, 3, 10));
				
				{
					win.background = colour;
					win.bounds = win.bounds
					.moveBy(posXthis, posYthis)
					.resizeBy(widthThis, heightThis);
					win.alpha = transparency;
				}.defer;
			}
		};
		s.queryAllNodes;
	}
}
)

best regards,

I can reproduce the error by executing the code twice, the second time being executed before the first execution finishes, or more precisely before windows close by themselves.

You are starting the code with Window.closeAll, and that’s why in this particular case (executing twice), you got the error, because you are later asking for the window to close but it’s been deleted already and can’t answer to the top message which is needed, I think, to close it (after thinking about it, it’s more likely the .bounds call that triggers the .top call ).


What I tried then is this :

}.play.onFree{ s.queryAllNodes; { win.close; "ping".postln; }.defer };

So I can see exactly when the window is deleted. This happens indeed randomly, and the very time it closes, it sometimes leads to the error, as seen in this log :

Shared memory server interface initialized
NODE TREE Group 0
   1 group
      1001 temp__77
      1000 temp__76
   1002 system_freqScope1_shm
ping
NODE TREE Group 0
   1003 localhostInputLevels
   1 group
   1002 system_freqScope1_shm
   1005 stethoscope1
   1004 localhostOutputLevels
FAILURE IN SERVER /n_set Node 1001 not found
ERROR: Message 'top' not understood.
RECEIVER:

More debugging shows it happens during this call :

{
	win.background = colour;
	win.bounds = win.bounds
	.moveBy(posXthis, posYthis)
	.resizeBy(widthThis, heightThis);
	win.alpha = transparency;
}.defer;

I don’t have time to go deeper into this, but I think your silence detection is messy and sometimes frees itself before it should, closing win while it still has to be processed in the above block.


Yep, that’s that.

Try changing the synth ampMod :

sig = { |freq=4000, ampMod=1|

The signal isn’t lasting long enough and frees sig2dac at the end of the first iteration, which in turns closes win.

But you are still asking, 9 * 20 times, to change win's background, etc. Since it’s been closed, it raises an error.

2 Likes

Thank you very much for dedicating your precious time to solving my problem. Thanks to you, I found the cause and resolved the issue.

With deep appreciation,

1 Like