# loadShape crashes sketch but only in the build

**URL:** <https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778>\
**Category:** Processing\
**Created:** [March 23, 2021, 10:30pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778 "2021-03-23T22:30:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 10:30pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/1 "2021-03-23T22:30:17Z")

</div>

this is a follow up to this problem [When i build this application it just makes a blank grey window](https://discourse.processing.org/t/when-i-build-this-application-it-just-makes-a-blank-grey-window/28642)

so i have identified the problem! for some reason it doesn’t like when i load svg shapes from a graphics folder. here is the problematic code

```auto
  imagePINE = loadShape("graphics/pine.svg");
  imageOAK = loadShape("graphics/oak.svg");
  imageBUSH = loadShape("graphics/bush.svg");
  imageOAKf = loadShape("graphics/oak-flowered.svg");
  imageBUSHf = loadShape("graphics/bush-flowered.svg");
  imageSTEPSTONES = loadShape("graphics/stepstones.svg");
  imageFOLIAGE = loadShape("graphics/foliage.svg");
  imageSHOPFRONT = loadShape("graphics/shop-front.svg");
  imageSHOPROOF = loadShape("graphics/shop-roof.svg");

```

it runs fine when i test in in-ide but when i build an actual app it freezes and the screen is just blank grey. these are all real svg files in a folder i made in the main project folder called ‘graphics’. does that folder not carry over to the build? this has never been a problem before. can anyone help me dubug this?

**UPDATE**

okay actually there is a another function that is also causing a crash. it’s uiUpdate(), a function that updates some ui variables. again, i have no idea why it is doing that

```auto
void uiUpdate(){
  if(mousePressed&&mouseButton==LEFT){
    if(iMOUSE == 0){
      iMOUSE = 1;
    } else {
      iMOUSE = 2;
    }
  } else {
    iMOUSE = 0;
  }
  if(mousePressed&&mouseButton==RIGHT){
    if(iRMOUSE == 0){
      iRMOUSE = 1;
    } else {
      iRMOUSE = 2;
    }
  } else {
    iRMOUSE = 0;
  }
  if(mousePressed&&mouseButton==CENTER){
    if(iMMOUSE == 0){
      iMMOUSE = 1;
    } else {
      iMMOUSE = 2;
    }
  } else {
    iMMOUSE = 0;
  }
  if(hENTER){
    if(iENTER == 0){
      iENTER = 1;
    } else {
      iENTER = 2;
    }
  } else {
    iENTER = 0;
  }
  if(hSHIFT){
    if(iSHIFT == 0){
      iSHIFT = 1;
    } else {
      iSHIFT = 2;
    }
  } else {
    iSHIFT = 0;
  }
  if(hTAB){
    if(iTAB == 0){
      iTAB = 1;
    } else {
      iTAB = 2;
    }
  } else {
    iTAB = 0;
  }
  if(hR){
    if(iR == 0){
      iR = 1;
    } else {
      iR = 2;
    }
  } else {
    iR = 0;
  }
  if(hE){
    if(iE == 0){
      iE = 1;
    } else {
      iE = 2;
    }
  } else {
    iE = 0;
  }
  
  if(hUP){
    if(iUP == 0){
      iUP = 1;
    } else {
      iUP = 2;
    }
  } else {
    iUP = 0;
  }
  if(hDOWN){
    if(iDOWN == 0){
      iDOWN = 1;
    } else {
      iDOWN = 2;
    }
  } else {
    iDOWN = 0;
  }
  if(hRIGHT){
    if(iRIGHT == 0){
      iRIGHT = 1;
    } else {
      iRIGHT = 2;
    }
  } else {
    iRIGHT = 0;
  }
  if(hLEFT){
    if(iLEFT == 0){
      iLEFT = 1;
    } else {
      iLEFT = 2;
    }
  } else {
    iLEFT = 0;
  }

  mouseScroll=round(mouseScroll*0.5);
}

```

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 23, 2021, 10:47pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/2 "2021-03-23T22:47:33Z")

</div>

You need to use processing functions and variables for the mouse.

mouseWheel is called using

[https://processing.org/reference/mouseWheel\_.html](https://processing.org/reference/mouseWheel_.html)

And if the variables beginning with i are system variables then they also need to be changed to processing variables or you need to use `keyCode` or `key`

Also CENTER is reserved for rectMode() or ellipseMode(), again you need to use the processing.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 10:52pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/3 "2021-03-23T22:52:05Z")

</div>

that’s odd, i thought i was using the processing members, because i’m coding this in the processing ide. is there a general resource for what members i should use for all the mouse input stuff

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 10:52pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/4 "2021-03-23T22:52:52Z")

</div>

i actually am using mouseWheel() btw, here’s the whole ui class

```auto

boolean hUP;
int iUP;
boolean hDOWN;
int iDOWN;
boolean hRIGHT;
int iRIGHT;
boolean hLEFT;
int iLEFT;
boolean hR;
int iR;
boolean hE;
int iE;
boolean hSPACE;
int iMOUSE;
int iRMOUSE;
int iMMOUSE;
boolean hENTER;
int iENTER;
boolean hSHIFT;
int iSHIFT;
boolean hTAB;
int iTAB;
float mouseScroll;
float mouseSV = 0;
float msLAST = 0;
void uiUpdate(){
  if(mousePressed&&mouseButton==LEFT){
    if(iMOUSE == 0){
      iMOUSE = 1;
    } else {
      iMOUSE = 2;
    }
  } else {
    iMOUSE = 0;
  }
  if(mousePressed&&mouseButton==RIGHT){
    if(iRMOUSE == 0){
      iRMOUSE = 1;
    } else {
      iRMOUSE = 2;
    }
  } else {
    iRMOUSE = 0;
  }
  if(mousePressed&&mouseButton==CENTER){
    if(iMMOUSE == 0){
      iMMOUSE = 1;
    } else {
      iMMOUSE = 2;
    }
  } else {
    iMMOUSE = 0;
  }
  if(hENTER){
    if(iENTER == 0){
      iENTER = 1;
    } else {
      iENTER = 2;
    }
  } else {
    iENTER = 0;
  }
  if(hSHIFT){
    if(iSHIFT == 0){
      iSHIFT = 1;
    } else {
      iSHIFT = 2;
    }
  } else {
    iSHIFT = 0;
  }
  if(hTAB){
    if(iTAB == 0){
      iTAB = 1;
    } else {
      iTAB = 2;
    }
  } else {
    iTAB = 0;
  }
  if(hR){
    if(iR == 0){
      iR = 1;
    } else {
      iR = 2;
    }
  } else {
    iR = 0;
  }
  if(hE){
    if(iE == 0){
      iE = 1;
    } else {
      iE = 2;
    }
  } else {
    iE = 0;
  }
  
  if(hUP){
    if(iUP == 0){
      iUP = 1;
    } else {
      iUP = 2;
    }
  } else {
    iUP = 0;
  }
  if(hDOWN){
    if(iDOWN == 0){
      iDOWN = 1;
    } else {
      iDOWN = 2;
    }
  } else {
    iDOWN = 0;
  }
  if(hRIGHT){
    if(iRIGHT == 0){
      iRIGHT = 1;
    } else {
      iRIGHT = 2;
    }
  } else {
    iRIGHT = 0;
  }
  if(hLEFT){
    if(iLEFT == 0){
      iLEFT = 1;
    } else {
      iLEFT = 2;
    }
  } else {
    iLEFT = 0;
  }

  mouseScroll=round(mouseScroll*0.5);
}

void keyPressed(){
  if(keyCode == 38 || keyCode == 87){
      hUP = true;
  }
  if(keyCode == 39 || keyCode == 68){
      hRIGHT = true;
  }
  if(keyCode == 37 || keyCode == 65){
      hLEFT = true;
  }
  if(keyCode == 40 || keyCode == 83){
      hDOWN = true;
  }
  if(keyCode == 82){
    hR = true;
  }
  if(keyCode == 69){
    hE = true;
  }
  if(keyCode == 32){
    hSPACE = true;
  }
  if(keyCode == 10){
    hENTER = true;
  }
  if(keyCode == 16){
    hSHIFT = true;
  }
  if(keyCode == 9){
    hTAB = true;
  }
  //println(keyCode);
}
void keyReleased(){
  if(keyCode == 38 || keyCode == 87){
      hUP = false;
  }
  if(keyCode == 39 || keyCode == 68){
      hRIGHT = false;
  }
  if(keyCode == 37 || keyCode == 65){
      hLEFT = false;
  }
  if(keyCode == 40 || keyCode == 83){
    hDOWN = false;
  }
  if(keyCode == 82){
    hR = false;
  }
  if(keyCode == 69){
    hE = false;
  }
  if(keyCode == 32){
    hSPACE = false;
  }
  if(keyCode == 10){
    hENTER = false;
  }
  if(keyCode == 16){
    hSHIFT = false;
  }
  if(keyCode == 9){
    hTAB = false;
  }
}

void mouseWheel(MouseEvent event) {
  mouseScroll = event.getCount();
}

```

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 23, 2021, 11:16pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/5 "2021-03-23T23:16:07Z")

</div>

What error do you get the debugger aught to be saying something.

[https://processing.org/examples/mousefunctions.html](https://processing.org/examples/mousefunctions.html)  
[https://processing.org/reference/keyCode.html](https://processing.org/reference/keyCode.html)  
[https://processing.org/reference/key.html](https://processing.org/reference/key.html)

That should cover all mouse keyboard activity. More complex logic has to be coded manually.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 11:27pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/6 "2021-03-23T23:27:54Z")

</div>

i don’t think i’m getting getting errors? maybe i don’t know where the debugger is. this is a build of the app, so the console of the ide doesn’t say anything right

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 23, 2021, 11:30pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/7 "2021-03-23T23:30:19Z")

</div>

Can you try and run it in the pde preview, that will post errors to the console.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 11:42pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/8 "2021-03-23T23:42:13Z")

</div>

yea it runs totally fine in the preview that’s what i’m saying. it breaks when you build it

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 23, 2021, 11:43pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/9 "2021-03-23T23:43:14Z")

</div>

What platform are you building to?

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 23, 2021, 11:54pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/10 "2021-03-23T23:54:11Z")

</div>

mac and windows both have the same problem

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 23, 2021, 11:57pm UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/11 "2021-03-23T23:57:56Z")

</div>

Not sure what to suggest other than make sure you have all prequesjtes java etc, and all environment variables are set, perhaps clean version of processing, also can you replicate this problem on previous processing builds.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 24, 2021, 2:34am UTC](https://discourse.processing.org/t/loadshape-crashes-sketch-but-only-in-the-build/28778/12 "2021-03-24T02:34:33Z")

</div>

what do you mean by environment variables. like the surface parameters and framerate and stuff? or like all variables
