josephburnett / hive-jam

A loop-oriented, multi-player framework for making music with Sonic Pi.
MIT License
7 stars 0 forks source link

JSON state truncated in transit over websocket #23

Open josephburnett opened 8 years ago

josephburnett commented 8 years ago

On a Macbook Air in Chrome, a new track couldn't be added. The error was "Track type must not be nil".

State: track-type-cannot-be-nil.json.txt

josephburnett commented 8 years ago

Was unable to reproduce on Macbook Air with OS X or Ubuntu 16.04.

josephburnett commented 8 years ago

Reproduces on OSX using Chome (was accidentally using Safari)

josephburnett commented 8 years ago

When adding a row fails, this message is seen in STDOUT of the sonic-jam binary:

2016/07/16 21:39:43 Error unmarshalling message from client. 2016/07/16 21:39:43 unexpected end of JSON input 2016/07/16 21:39:43 Error unmarshalling message from client. 2016/07/16 21:39:43 invalid character 'h' looking for beginning of value

Issue #24

josephburnett commented 8 years ago

For some reason, Chrome on OS X is splitting the state update message into two messages over the websocket:

2016/07/16 22:13:33 [Received from client qnBsBCRkpEGdzKLN: {"Address":"/set-state","Params":["root","{\"name\":\"root\",\"id\":\"root\",\"bpc\":\"1/2\",\"tracks\":[{\"type\":\"sample\",\"id\":\"iclaluhr\",\"on\":true,\"beats\":[[1],[1],[0],[1],[1],[0],[1],[0]],\"fx\":[],\"sample-params\":{},\"sample\":\"drum_bass_hard\"},{\"type\":\"sample\",\"id\":\"ipktxsez\",\"on\":true,\"beats\":[[0],[1],[0],[0],[1],[0],[0],[0]],\"fx\":[],\"sample-params\":{},\"sample\":\"drum_tom_lo_hard\"},{\"type\":\"grid\",\"id\":\"fjjupjwl\",\"on\":true,\"beats\":[[1]],\"fx\":[],\"synth-params\":{},\"sample-params\":{},\"grid-id\":\"rhbvpvfh\"},{\"fx\":[],\"beats\":[[0],[1],[0],[0],[1],[0],[0],[0]],\"sample-params\":{},\"id\":\"cdoawzqx\",\"synth-params\":{},\"grid-id\":\"zwfqxvmi\",\"grid-type\":\"sample\",\"on\":true,\"type\":\"grid\",\"sample\":\"drum_bass_soft\"},{\"type\":\"sample\",\"id\":\"utphyvdo\",\"on\":true,\"beats\":[[0],[0],[1],[0],[1],[0],[1],[0]],\"fx\":[],\"synth-params\":{},\"sample\":\"drum_heavy_kick\"},{\"fx\":[],\"beats\":[[0],[1],[0],[1],[0],[1],[0],[1]],\"sample-params\":{\"amp\":\"0.6\"},\"id\":\"amyqoybb\",\"synth-params\":{},\"grid-id\":\"sbjkhefa\",\"on\":true,\"type\":\"sample\",\"sample\":\"drum_tom_mid_hard\"},{\"type\":\"sample\",\"id\":\"cqbcohwm\",\"on\":true,\"beats\":[[0],[0],[0],[0],[1],[0],[0],[0]],\"fx\":[],\"synth-params\":{},\"sample\":\"sn_dub\"},{\"type\":\"sample\",\"id\":\"mqtpmrtv\",\"on\":true,\"beats\":[[0],[0],[1],[0],[1],[0],[1],[0]],\"fx\":[],\"synt] 2016/07/16 22:13:33 [Error unmarshalling message from client.] 2016/07/16 22:13:33 [unexpected end of JSON input] 2016/07/16 22:13:33 [Received from client qnBsBCRkpEGdzKLN: h-params\":{},\"sample\":\"guit_harmonics\"}]}"]}] 2016/07/16 22:13:33 [Error unmarshalling message from client.] 2016/07/16 22:13:33 [invalid character 'h' looking for beginning of value] 2

josephburnett commented 8 years ago

According to Chrome developer tools, the message went out as one frame.

josephburnett commented 8 years ago

Increased server buffer size from 2000 to 10000 bytes but the frame is still being split. The frame should have only been 1669 bytes anyway.

josephburnett commented 8 years ago

The message received from Chrome on Ubuntu 16.04 is identical up to the point of truncation.

josephburnett commented 8 years ago

While stress testing Ubuntu 16.04 to try and reproduce the WS bug, I ran into a size limitation in parsing OSC messages. Different bug but same class of errors.

josephburnett commented 8 years ago

@ede5f9cd405ce0d9549cd6bed456b119202ede64 -- Limit track count to a maximum of 6.

This puts a guard in place so this doesn't destroy the user experience. Removing from milestone 0.2.