jonathanperret / paysage

Paysage is a visual shared playground for code.
http://paysage.xyz
GNU Affero General Public License v3.0
19 stars 9 forks source link

invalid code makes rendering stop for the rest of objects in the list #73

Closed juliendorra closed 7 years ago

juliendorra commented 7 years ago

Tested in a classroom environnement with 22 students and 22-26 code objects: Only the Code Objects up to an (unknown) invalid Code Object will render, creating confusion and frustration because many objects will not appear. Strangely, some renderer will appear to be immune, when in fact they are stuck and not updating. Other renderer will update and show just a few objects. The source of the problem will be at first, and quite erroneously, attributed to the fabled bad networks of schools. The first invalid code will of course be in an object a the top of the list, making only 3 objects appearing. This will lead to the solution. But then more invalid code will be there, in abandoned test code. Students will be at the edge of rebelling against the teacher. "Is he of any competence?", they will think, starting to wonder if the trust they put in him to guide them on the path of creative coding was well placed. The teacher will react by frantically searching for bugs in the 22 code objects, and will ultimately ressort to delete objects that seem to have no proper owner.

How to reproduce Send good code in 2 or 3 objects Send an other code object that is invalid from the start, example: no { } at all for void draw() {} or a part of a function in the middle of nowhere. Send more new code objects that will appears further down the list, after the bad code object. These will not render.

Workaround Not much. Ask each participant to test its own code on a separate Playground. Identify abandoned objects with partial code and delete them.

jonathanperret commented 7 years ago

First, looks like you need some 🤗

Now that it's done, this seems similar to #26, right? Unfortunately, I can't seem to find the right kind of "bad code" to reproduce it. If you can, could you post here a complete list of programs that shows the issue?

Also, which browser was used? Did the problem occur in every preview frame or just on the "big screen"?

juliendorra commented 7 years ago

This code will show the bug on at least Chrome and Safari Mobile.

The students used a variety of browser, but most probably Safari and Chrome were in the majority (as in IE11 and Firefox there's an UI bug)

void draw() {

background (0)

int deplacement = sin (millis()/50) * 20
translate (deplacement, 30)
fill (10, 50, 10, 10)

rect (10, 10, 100, 100)

}

You can try by opening a fresh playground and with just one object. Send an good object that move. Replace the code with the bad one and send. The rendering will not update and animation of the replaced code will freeze. Here's the error I got in the console:

Uncaught SyntaxError: Unexpected identifier at new Function () at Processing.Sketch.attach (processing.js:885) at executeSketch (processing.js:21564) at new Processing.Processing (processing.js:21598) at createLayer (paysagerenderer.js:90) at updateObject (paysagerenderer.js:81) at r. (paysagerenderer.js:32) at r.emit (index.js:133) at r.onevent (socket.js:270) at r.onpacket (socket.js:228)

jonathanperret commented 7 years ago

I confirm that if I replace a running object's code with this broken code its animation stops. But this works as expected, doesn't it? I thought the original bug report was that other objects were affected?

juliendorra commented 7 years ago

Try that: Create 4 good objects. Replace the code in the 2nd one (list order) with the bad code. Animation freeze, Load the playground in another page (or just hide it / show it) Only the first animation will load Animation 3 and 4 will not

juliendorra commented 7 years ago

(also, replacing the bad code with a good one won't unfreeze the affected playgrounds that are partially rendered. You have to close and reload from scratch)

etienneCharignon commented 7 years ago

@juliendorra I would have loved to have a teacher like you !

jonathanperret commented 7 years ago

Load the playground in another page (or just hide it / show it)

A-ha! That was the missing step. I did all my testing without trying to reload the renderer, missing the fact that a different code path was taken when initializing a renderer for an existing playground.

An interesting illustration of why code should be kept DRY 😉

(edit: quoted the wrong step, duh)