muellmusik / Utopia

This is an attempt at a generic library of tools for making Network Music Apps in SuperCollider
43 stars 8 forks source link

OSCObjectSpace: Problem Archiving Closed Function #2

Closed sidechained closed 9 years ago

sidechained commented 11 years ago

Hey Scott (and whoever else might be working on this!),

I've been experimenting with NML/Utopia and want to share a closed function using an OSCObjectSpace, but I have problems when I execute the following code.

( ~aFunc = {\test.postln}; ~peer1 = Peer(\me1, NetAddr.localAddr); ~addrBook1 = AddrBook().addMe(~peer1); ~objSpace1 = OSCObjectSpace(~addrBook1, oscPath:'/objSpace'); // me1's local copy ~objSpace1.put(\me1, ~aFunc); // me1 adds her Server addr )

Here's the error I get:

ERROR: cannot archive Frames. ERROR: Primitive '_AsArchive' failed. Failed. RECEIVER: Instance of Function { (0x11479a5d8, gc=88, fmt=00, flg=80, set=02) instance variables [2] def : instance of FunctionDef - closed context : Frame (0x10b903658) of Interpreter:functionCompileContext } PATH: /Users/grahambooth/Library/Application Support/SuperCollider/Extensions/Utopia-master/classes/NMLRelays.sc CALL STACK: MethodError:reportError 0x1134465d8 arg this = Nil:handleError 0x113446aa8 arg this = nil arg error = Thread:handleError 0x113449a18 arg this = arg error = Object:throw 0x1134477b8 arg this = Object:primitiveFailed 0x11344c408 arg this = OSCObjectSpace:updatePeers 0x113451ec8 arg this = arg key = 'me1' arg value = AbstractOSCDataSpace:put 0x10b796818 arg this = arg key = 'me1' arg value = OSCObjectSpace:put 0x1134bba68 arg this = arg key = 'me1' arg value = Interpreter:interpretPrintCmdLine 0x114b22218 arg this = var res = nil var func = var code = "( ~aFunc = {\test.postln}; ~..." var doc = var ideClass = Process:interpretPrintCmdLine 0x10b741f38 arg this = ^^ The preceding error dump is for ERROR: Primitive '_AsArchive' failed. Failed. RECEIVER: a Function

Here's my own attempt to archive the function:

~aFunc.asBinaryArchive

This doesn't throw an error, and return (correctly I think) an Int8Array.

However when the same thing is done in the OSCObjectSpace source (value.asBinaryArchive, where value is apparently the self-same function), the frame error occurs.

updatePeers {|key, value|
        addrBook.sendExcluding(addrBook.me.name, oscPath, key, encryptor.encryptBytes(value.asBinaryArchive));
}

Everything seems okay here:

OSCObjectSpace:updatePeers   0x113451ec8
    arg this = <instance of OSCObjectSpace>
    arg key = 'me1'
    arg value = <instance of Function>

Any ideas? I guess the other way to do it would be archive the function as a compile string and share that using an OSCDataSpace, but that seems clunky.

Any help appreciated.

Regards, Graham

muellmusik commented 11 years ago

Hi Graham,

Manually binary-archiving the Function returns the same error for me. I was aware of this in any case.

In truth binary archiving is a sort of legacy supported thing. I only switched to it as an experiment, for security reasons, since it avoided the need to interpret the archives. But I should probably just revert it back to using the standard text archive, with some additional safety checks.

sidechained commented 11 years ago

Hi Scott,

Thanks for the info on this, for now I'll do the revert you suggest in my own fork of the project and will keep and eye on things in the main branch.

Cheers, Graham

muellmusik commented 11 years ago

Cool. I'm hoping to get back to Utopia stuff soon. Currently trying to clear my SC backlog, while doing a little contributing to some of the newer codebases...

muellmusik commented 9 years ago

Okay, the switch is in PR #13 and everything seems to be working, so closing this.