Weird ArrayOutOfBound issue, using PShape

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…):

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 :

  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.

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:

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:

SVG issues on GitHub for Processing 4:

:)

2 Likes

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…

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.

:)

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…)