# Program "crashes" when I setResizable(true) and resize the Window

**URL:** <https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208>\
**Category:** Processing\
**Created:** [June 13, 2023, 2:28pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208 "2023-06-13T14:28:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 2:28pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/1 "2023-06-13T14:28:11Z")

</div>

This is my code

```auto
void setup() {
  size(1920, 1080);
  surface.setResizable(true);
}
void draw(){
  background(0);
  fill(255);
  rect(0,0,width,height);
}

```

When I change my window size to be as small as possible then resize it to a normal size it breaks. What I mean by that I can still move the Canvas and resize it but the draw method stops looping and WindowResize() isn’t called anymore when the window is resized. I’m on window 10 intel and I’m on version 4.2. I haven’t seen Any post about this issue before so any help would be great!

Here is a video of it happening if u want too see:  
[Drive link to Video](https://drive.google.com/file/d/1rNUiEWjklEzvM2q1bGQrFfGRH5E1Cg__/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [June 13, 2023, 4:48pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/2 "2023-06-13T16:48:03Z")

</div>

I tried your code using Processing 4.2 on my iMac and it worked without issue. Perhaps it is just with Windows.

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 5:20pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/3 "2023-06-13T17:20:10Z")

</div>

Interesting that’s it’s platform based. It does only happen if I go as small as I can. So if there was a way to increase that minimum width and height it might fix it.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [June 13, 2023, 5:54pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/4 "2023-06-13T17:54:20Z")

</div>

> [@Joseph](#):
>
> So if there was a way to increase that minimum width and height it might fix it.

I doubt if that would make any difference. It is more likely the problem was caused by trying to reduce the window size to below the permitted minimum width and height rather than their actual value.

I tried reducing the window size below minimum size also tried and minimising / maximising the window all worked just fine.

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 6:06pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/5 "2023-06-13T18:06:01Z")

</div>

That does make more sense, do you have any ideas to fix it?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [June 13, 2023, 6:13pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/6 "2023-06-13T18:13:43Z")

</div>

Since it works on my imac there seems to be 2 possibilities

1. It is platform specific i.e. related to Windows version of Processing
2. Something specific related to your system.

If other Windows users try out your code and get the same problem then it might be (1) if they have no problems then (2). Since I am not using Windows and I can’t reproduce the problem I can’t really help further. Good luck.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 7:28pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/7 "2023-06-13T19:28:00Z")

</div>

I’m unable to reproduce this with Windows11. There is some lag of the rectangle when the window is resized but it always comes back to the window width and height. Naive question: Why don’t you just make the window background white (and forget the rectangle)?

I just noticed that your movie was made with an additional line of code where you println() the frameCount; what happens when you take that line out? I tried adding that line to the Windows11 code and it still works as expected.

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 7:49pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/8 "2023-06-13T19:49:02Z")

</div>

I was able to test My code on another machine which is also running windows 10, it does still break but it’s still weird that the bug is fixed on windows 11. @svan This isn’t a Naive Question, This isn’t my actual program, I have alot of elements updating them selves based on the public variable width and height which isn’t being updated because of this bug. Also println() is just telling me if the program is still calling draw() which you could see in the video that it wasn’t. If I remove it, it doesn’t impact the result.

Thx for your Help @quark I guess I’ll have to find some way to detect the bug and fix it. If I come up With a solution I will post it in this forum, and anyone with any ideas of potential fixes plz let me know.

Thx in Advance

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 7:56pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/9 "2023-06-13T19:56:12Z")

</div>

Does this break?

```auto
void setup(){
 size (320, 240);
 surface.setResizable(true); 
 rect(0, 0, width, height);
 noLoop();
}

```

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 8:22pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/10 "2023-06-13T20:22:14Z")

</div>

@svan This is a solution for the problem but in the program I need to use draw() on loop() which breaks the solution. Any other Ideas?

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 8:34pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/11 "2023-06-13T20:34:41Z")

</div>

I have just figured out that the time that it breaks it doesn’t call windowResized() which is very odd

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 8:56pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/12 "2023-06-13T20:56:14Z")

</div>

There is also a windowResize(newWidth, newHeight); does calling that in each loop of draw() help?

```auto
void setup() {
  size(400,400);
  surface.setResizable(true);
  background(0);
}

void draw() {
  windowResize(width, height);
  rect(0,0,width,height);
}

```

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 9:13pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/13 "2023-06-13T21:13:50Z")

</div>

@svan Sadly it doesn’t help cause when the bug happenes sit doesn’t call draw anymore

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 9:42pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/14 "2023-06-13T21:42:15Z")

</div>

Is this usable:

```auto
void setup() {
  size (320, 240);
  surface.setResizable(true);
  background(0);
}

void draw() {
  fill(255);
  rect(0,0,width,height);
  noLoop();
}

```

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 9:53pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/15 "2023-06-13T21:53:07Z")

</div>

no I need draw to loop

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 9:53pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/16 "2023-06-13T21:53:24Z")

</div>

> it doesn’t help cause when the bug happenes sit doesn’t call draw anymore

This is the first time I’ve ever heard of draw() stalling. Someone can correct me if I’m wrong but I thought that the loop() was based on some little vibrating crystal in the guts of a computer, the ‘internal clock’. I just can’t imagine that failing. I think there is a battery somewhere that keeps it powered up.

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 10:07pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/17 "2023-06-13T22:07:08Z")

</div>

the program is crashing so the draw method is not able to be called

---

<div class="post-metadata">

**Author:** ![Joseph](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Joseph](https://discourse.processing.org/u/Joseph)\
**Post date:** [June 13, 2023, 10:07pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/18 "2023-06-13T22:07:35Z")

</div>

and also I’m pretty sure that’s not how draw() works

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 11:00pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/19 "2023-06-13T23:00:49Z")

</div>

We need to hear from more Windows 10 users. There should be quite a few in this forum. The source code looks pretty innocuous and it’s difficult to believe it causes a ‘crash’ or even a ‘freeze’. It will be interesting to see what happens on other Win10 systems.

To me a ‘crash’ is when the window disappears and you have nothing to work with. In your case it looks to me more like a ‘freeze’ or a ‘hang’. Processing’s runtime appears to have stopped processing instructions. A ‘stack trace’ with a debugger should show what caused it to ‘hang’ but unfortunately I have no idea how that could be done with a regular Processing app.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2023, 11:03pm UTC](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208/20 "2023-06-13T23:03:36Z")

</div>

`I’m pretty sure that’s not how draw() works`

How do you think it works? Something has to provide the timing (default 60 frames/sec).

[Next page](https://discourse.processing.org/t/program-crashes-when-i-setresizable-true-and-resize-the-window/42208.md?page=2)
