# Sketch soft crashes when resizing window

**URL:** <https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032>\
**Category:** Processing\
**Created:** [October 1, 2022, 3:53pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032 "2022-10-01T15:53:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jSdCool](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jsdcool/32/14246_2.png) [@jSdCool](https://discourse.processing.org/u/jSdCool)\
**Post date:** [October 1, 2022, 3:53pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032/1 "2022-10-01T15:53:24Z")

</div>

I was trying to play around with the new windowResizable() and other related functions added in processing 4. however I found that sometimes after resizing the window the sketch would stop redrawing, mouse click also didn’t work. The window didn’t close and I could keep resizing it however the new window space that was created was just black. I created another thread and that didn’t get stopped when the sketch froze and was able to detect when the main thread stopped executing.

code that I was testing

```auto
void setup(){
  size(400,400);
  windowResizable(true);
  thread("nt");
}

int lt=0;
void draw(){
  background(100);
  println(width+" "+height+" "+frameCount);
  fill(random(-16777215,0));
  rect(width/2,height/2,100,100);
  lt=millis();
}

void windowResized(){
  println("window resized");
}

void windowMoved(){
  println("window moved");
}

void mouseClicked(){
  println("peepee poopoo");
}

void nt(){
 while(true){
   random(1);
   if(millis()-lt>100){
     println("wee woo");
   }
 }
}

```

does anyone know why this might be happening?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 2, 2022, 4:42pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032/2 "2022-10-02T16:42:08Z")

</div>

Hello @jSdCool,

Related topic:

> [@Image() flickers when changing sketch size with windowResize()](https://discourse.processing.org/t/image-flickers-when-changing-sketch-size-with-windowresize/38952/3):
>
> Hello @sableRaph, My exploration of this: // windowResize Flicker // v1.0.0 // GLV 2022-09-23 //References: // https://forum.processing.org/one/topic/flickering-when-using-the-java-frame-resize-method#25080000001705051.html // https://github.com/processing/processing4/blob/main/build/shared/revisions.md PImage img1; int sz; void setup() { windowResizable(true); img1 = loadImage("frog.png"); sz = 200; windowResize(sz, sz); delay(12); frameRate(60); } void draw() { prin…

`:)`

---

<div class="post-metadata">

**Author:** ![jSdCool](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jsdcool/32/14246_2.png) [@jSdCool](https://discourse.processing.org/u/jSdCool)\
**Post date:** [October 2, 2022, 5:33pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032/3 "2022-10-02T17:33:28Z")

</div>

that is not the issue that I am having here  
 ![effect](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/4/74a3e4b8e77ab249b5e0f440edc5abd4d38a5666.gif)  
the issue is not that it flickers it is that the image stops updating entirely

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 2, 2022, 7:42pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032/4 "2022-10-02T19:42:23Z")

</div>

Hello @jSdCool,

> [@jSdCool](#):
>
> that is not the issue that I am having here

> [@jSdCool](#):
>
> the issue is not that it flickers it is that the image stops updating entirely

I shared a [related](https://www.oxfordlearnersdictionaries.com/definition/english/related) topic and the solution that solved the flicker solved the issue here.

W10 and Processing 4.01 tested.

`:)`

---

<div class="post-metadata">

**Author:** ![jSdCool](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jsdcool/32/14246_2.png) [@jSdCool](https://discourse.processing.org/u/jSdCool)\
**Post date:** [October 2, 2022, 8:03pm UTC](https://discourse.processing.org/t/sketch-soft-crashes-when-resizing-window/39032/5 "2022-10-02T20:03:06Z")

</div>

I tried adding delay to my sketch and it did not fix the problem  
I don’t know why it would solve the problem when the problem is that the sketch stop executing entirely after the window is resized.  
additionally the window is not resized from inside the sketch but by the user at any point.

where exactly did you change things to fix it?
