# Weird ArrayOutOfBound issue, using PShape

**URL:** https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529
**Category:** Coding Questions
**Created:** [March 30, 2023, 9:38am UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529 "2023-03-30T09:38:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jokoko](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jokoko](https://discourse.processing.org/u/jokoko)
#### Post date: [March 30, 2023, 9:38am UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529/1 "2023-03-30T09:38:14Z")

</div>

Hi there,

I’m working on a project, involving video, svg and createdShape, displayed in 3 “sub-window” (actually 3 “rectangles” drawn in the main window canva) -the aim is to map it on 3 screen surfaces.

I’d like to use multiple SVG files, loaded in a PShape array (actually 3 PShape Array, one per subwindow).

For that my code look like that (I simplified it, as I have multiple tabs for different functionnalities, like OSC receiving, video, ect…):

```auto
PShape[] svgA = new PShape [1];
PShape[] svgB = new PShape [1];
PShape[] svgC = new PShape [1];

void setup(){
  
  svgA[0] = loadShape("beetle.svg");
  svgB[0] = loadShape("beetle.svg");
  svgC[0] = loadShape("beetle.svg");

}

void draw(){
svgA();
svgB();
svgC();
}

void svgA(){
    shape(svgA[0],centerWinAx,centerWinAy, 160,260);

}

void svgB(){
    shape(svgB[0],centerWinBx, centerWinBy, 160,260);

}

void svgC(){
    shape(svgC[0],centerWinCx, centerWinCy, 160,260);

}

```

But as I got this error:

> ArrayIndexOutOfBoundsException: Index 662 out of bounds for length 662

I decided to come back to my first svg test code with a far more simple code :

```auto
  PShape beetle;
  
  void setup() {
  size(640, 360);
  beetle = loadShape("beetle.svg");
  }
  
  void draw(){
     shape(beetle,40, 40, 320, 320);
  }

```

But it gives me the very same error :

> ArrayIndexOutOfBoundsException: Index 662 out of bounds for length 662

Which is very weird as there is no Array in this code.

So I’m lost with it and have absolutely no idea how to proceed to debug it…  
(Of course, my simple svg test code is saved with the svg file in the data folder, and it used to work when I tried it the first time).

Thank you.

---

<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: [March 30, 2023, 10:56am UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529/2 "2023-03-30T10:56:43Z")

</div>

Hello @jokoko,

It is my experience that not all SVGs will work. I just tried a few SVGs (beetle SVG search) and only one of the 3 worked and the other 2 had various errors.

There is a comment about the SVG implementation here:

> **[PShape / Reference](https://processing.org/reference/PShape.html)**
>
> Datatype for storing shapes. Before a shape is used, it must be loaded with the loadShape() or created with the createShape(). The shape() function is used to draw the shape to th…

Arrays are most certainly used by the PShape methods behind the scenes.

You may find something in the GitHub issues…

SVG issues on GitHub for Processing 3:

> **[Issues · processing/processing](https://github.com/processing/processing/issues?q=svg)**
>
> Source code for the Processing Core and Development Environment (PDE) - Issues · processing/processing

SVG issues on GitHub for Processing 4:

> **[Issues · processing/processing4](https://github.com/processing/processing4/issues?q=svg)**
>
> Processing 4.x releases for Java 17. Contribute to processing/processing4 development by creating an account on GitHub.

`:)`

---

<div class="post-metadata">

### Author: ![jokoko](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jokoko](https://discourse.processing.org/u/jokoko)
#### Post date: [March 30, 2023, 2:15pm UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529/3 "2023-03-30T14:15:58Z")

</div>

Hi,

thank you for the answer.  
I don’t think it come from the svg file itself because it’s one I’ve made myself with inkscape, and it worked perfectly before with processing.  
But actually, I think I have found a big clue in this issue :  
Open my sketches from another session (I mean another ubuntu install I have on my disk), and it work perfectly, even the array part of my code. So I think this about Processing software.  
I don’t know if you have something to recommend me about that.  
I think I shall reinstall processing, but maybe there are some stuffs to do before or after that…

---

<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: [March 31, 2023, 10:44am UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529/4 "2023-03-31T10:44:38Z")

</div>

> [@jokoko](#):
>
> So I think this about Processing software.

It helps to share additional information:

- Operating System
- Processing version
- SVG if you have permission to share or a link
- Combinations of above that don’t work and those that do work.

`:)`

---

<div class="post-metadata">

### Author: ![jokoko](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jokoko](https://discourse.processing.org/u/jokoko)
#### Post date: [March 31, 2023, 2:58pm UTC](https://discourse.processing.org/t/weird-arrayoutofbound-issue-using-pshape/41529/5 "2023-03-31T14:58:02Z")

</div>

That’s right sorry:

Both session are on Ubuntu Studio (Kde Plasma) 22.04  
And the session that works use Processing 4.0.1  
The bugging one is with 4.2

About the SVG file, it’s not possible to upload it due to extension authorization (only image file are) and I have no link to give you. It was a PNG file, I turn to SVG with Inkskape (I made it with differents files, and their were all easily displayed with the second session that work…)

I think the main difference between those 2 sessions is about the Graphics Nvidia driver that are installed on the session that have this weird bug, whereas the other one runs with “Nouveau” drivers.

EDIT :  
I’ve run processing 4.0.1 (that is installed on the disk of my second session, but is not the one I’d like to use) and it worked.  
So I now think this is something about processing 4.2 (or this installation on my laptop and changes I’d have made, but I have no idea which, if so…)
