# Why does Processing 4 randomly freeze/produce a different output each time

**URL:** https://discourse.processing.org/t/why-does-processing-4-randomly-freeze-produce-a-different-output-each-time/38703
**Category:** Processing.py
**Created:** [September 10, 2022, 6:42pm UTC](https://discourse.processing.org/t/why-does-processing-4-randomly-freeze-produce-a-different-output-each-time/38703 "2022-09-10T18:42:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![luhdooce](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@luhdooce](https://discourse.processing.org/u/luhdooce)
#### Post date: [September 10, 2022, 6:42pm UTC](https://discourse.processing.org/t/why-does-processing-4-randomly-freeze-produce-a-different-output-each-time/38703/1 "2022-09-10T18:42:18Z")

</div>

So I’m trying to make an rtx program with the new Processing 4, but everything seems 100x harder than before on version 3 of Processing. Shapes are sometimes drawn, and sometimes not. It was also my understanding that if I drew a shape, and then ran a while loop, the shape would remain on the screen. It also seems that aside from syntax errors, Processing 4 no longer reports errors. Additionally, even when I only have 1 tab, it looks like I have to manually save before the code recompiles (I’m like 70% sure this was not a requirement in Processing 3).

Am I just tripping? Or is the new Processing just worse? Also, it seems that whenever I run the program, it takes an uncomfortably long time before the sketch actually opens (on top of sometimes, seemingly randomly, freezing, even without any changes being made to the code).

```auto
sc = PVector(700,700)

class Shape:
    def __init__ (self,x,y,dia):
        self.pos = PVector(x,y)
        self.dia = dia
        
    def show(self):
        circle(self.pos.x,self.pos.y,self.dia)

def setup():
    size(int(sc.x),int(sc.y))
    background(255)
    
obj_list = []
c1 = Shape(700,700,30)
obj_list.append(c1)
    
def draw():
    background(255)
    for obj in obj_list:
        obj.show()
    
    epsilon = 10
    min_dist = 2*(sc.x+sc.y)
    begin_pos = PVector(0,0)
    current_pos = PVector(0,0)
    while min_dist > epsilon:
        for obj in obj_list:
            obj.show()
            if abs(dist(current_pos.x,current_pos.y,obj.pos.x,obj.pos.y))-obj.dia/2 < min_dist:
                min_dist = abs(dist(current_pos.x,current_pos.y,obj.pos.x,obj.pos.y))-obj.dia/2
        current_pos = PVector(mouseX,mouseY).limit(min_dist)
    

```

Also, the instantiation of c1 is really strange. Sometimes using PVector sc for its coordinates works, but then if I try to do sc.x/2 or sc.y/2, it doesn’t work. But substituting sc.x and sc.y with their literal values (both are 700) also makes the program stop working.

---

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [September 13, 2022, 7:00pm UTC](https://discourse.processing.org/t/why-does-processing-4-randomly-freeze-produce-a-different-output-each-time/38703/2 "2022-09-13T19:00:53Z")

</div>

Cheers @luhdooce !

I’ve seen reports that Processing 4 is not working properly with Python mode, unfortunately.  
I would stick to using the Processing 3.5.4 IDE.

In my experience, when using secondary tabs , it never works if I don’t save.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/c/6c9a57f5d7b4a94d565a989037d972b790604c64.png)

I have added some of the preparing to setup(). I was told we should not use variables in size… but this is working.

I would hard code the `size(700, 700`, and then use, inside `setup():` something like `Shape(width / 2, height / 2)`.

You might want to have a look at [https://py5coding.org](https://py5coding.org) too…

Best regards,  
Alexandre
