siaflab / haskap-jam-pack

An extension package for Sonic Pi
http://siaf.jp/siaflab/2015/03/29/sonic-pi-x-siaf-lab/
Other
21 stars 2 forks source link

jam_loop :test gives error can't modify frozen String on SP 2.12 dev #1

Open rbnpi opened 7 years ago

rbnpi commented 7 years ago

Just trying out the code. voice works fine. However setting up jam_loop as per the instructions gives thread death! can't modify frozen String when running SP 2.12 dev. Works OK on sp 2.11 and 2.10

load "~/downloads/haskap-jam-pack-0.5.0/client/haskap-jam-loop.rb"
jam_loop :test do
  play 60
  sleep 0.5
end

(path modified as running from downloads folder on my iMac. Using SP 2.12 dev

kn1kn1 commented 7 years ago

Thank you so much for reporting the issue.

I'm afraid that there's no SP 2.12-dev environment in my computer and I'm not able to reproduce this issue for now. Just googling the error message shows that some string might get immutable and needs to be mutable for modifying. It would be helpful if you provide the stacktrace like this (displayed bellow the error message in SP Buffer).

/Users/kn1kn1/github/haskap-jam-pack/client/haskap-jam-loop.rb:55:in `jam_loop'
workspace_seven:2:in `block (2 levels) in __spider_eval'
/Applications/Sonic Pi2.11.app/app/server/sonicpi/lib/sonicpi/lang/core.rb:3366:in `block in in_thread'
rbnpi commented 7 years ago

I think it is a more general problem with Sonic Pi at the moment. The frozen string error is effecting other things, and Sam is working on the case. e.g. run_code "play 60" was not working, although he has fixed that now Also the Sonic Pi spark commands are currently not working either. So rather than alter your code at present, I think we need to wait at present until these other issues are resolved. If you want to see what is happening look at

https://github.com/samaaron/sonic-pi/issues/1530 and https://github.com/samaaron/sonic-pi/issues/1533

rbnpi commented 7 years ago

The stack trace produced by the error was:

/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/oscencode.rb:95:in `block in encode_single_message'
/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/oscencode.rb:54:in `each'
/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/oscencode.rb:54:in `encode_single_message'
/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/tcp_client.rb:45:in `send'
/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/haskap-jam-loop.rb:93:in `jam_loop'
workspace_six:3:in `block (2 levels) in __spider_eval'
/Users/rbn/src/sonic-pi/app/server/sonicpi/lib/sonicpi/lang/core.rb:3678:in `block in in_thread'

The Sonic Pi debug log contained

[2017-01-18 13:52:06|haskap-jam] local_address: 192.168.1.10
[2017-01-18 13:52:06|haskap-jam] local_address: 192.168.1.10
[2017-01-18 13:52:06|haskap-jam] remote_address: 127.0.0.1
[2017-01-18 13:52:06|haskap-jam] remote_port: 4559
[2017-01-18 13:52:06|haskap-jam] proc.source_location: ["workspace_six", 3]
[2017-01-18 13:52:06|haskap-jam] workspace_id: six
[2017-01-18 13:52:06|haskap-jam] file_name: workspace_six.spi
[2017-01-18 13:52:06|haskap-jam] project_path: /Users/rbn/.sonic-pi/store/default/
[2017-01-18 13:52:06|haskap-jam] workspace_file_path: /Users/rbn/.sonic-pi/store/default/workspace_six.spi
[2017-01-18 13:52:06|haskap-jam] code: load "/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/haskap-jam-loop.rb"

jam_loop :test do
  play 60
  sleep 0.5
end

[2017-01-18 13:52:06|haskap-jam] remote_code: #load "/Users/rbn/Downloads/haskap-jam-pack-0.5.0/client/haskap-jam-loop.rb"

live_loop :test do
  play 60
  sleep 0.5
end

[2017-01-18 13:52:06|haskap-jam] client_id: haskap-client-192.168.1.10
[2017-01-18 13:52:06|haskap-jam] buffer_id: haskap-buffer-192.168.1.10-six
[2017-01-18 13:52:06|haskap-jam] workspace: haskap-workspace-192.168.1.10-six

As I say, there appear to be several frozen string errors emerging in Sonic Pi at present, and this is just another source of them.

kn1kn1 commented 7 years ago

Thank you so much for everything.

This gist file may fix the issue. (I changed the following part in the file as "," seems to be frozen)

# WORKAROUND for frozen string literal
# args_encoded, tags = "", ","
args_encoded, tags = String.new(""), String.new(",")

Please replace it with haskap-jam-pack/client/oscencode.rb and run the code again.

I would be happy if you try it when you have time.

kn1kn1 commented 7 years ago

Same file of above gist code is also attached here, please check this out. oscencode.rb.zip