Processing crashes

edited October 2015 in Questions about Code

Hey, I've been working on a relatively simple sketch and after a few cycles of triangles being animated, processing gives me this error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000069277ea6, pid=5844, tid=15192
#
# JRE version: Java(TM) SE Runtime Environment (8.0_51-b16) (build 1.8.0_51-b16)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [dcpr.dll+0x7ea6]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Program Files (x86)\processing-3.0.1\hs_err_pid5844.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug

This is the sketch i'm running:

int TriangleNo = 5;
int gridSize = 3;

Triangle[] newTriangle = new Triangle[TriangleNo];

void setup() {
  size(700, 700);
  smooth();
  noStroke();
  colorMode(HSB, 100);

  for (int n = 0; n < newTriangle.length; n++) {
    newTriangle[n] = new Triangle();

    // get the first set of Triangles
    //newTriangle[n].display();
  }
}

void draw() {
  background(0, 0, 95);

  float grid = floor(width/gridSize);

  for (int i = 0; i < gridSize; i++) {
    for (int j = 0; j < gridSize; j++) {

      pushMatrix();
      translate(i*grid, j*grid);
      for (int n = 0; n < newTriangle.length; n++) {
        newTriangle[n].display();
      }
      popMatrix();

    } // end j
  } // end i
}


//////////////////


class Triangle {
  float x1, y1, x2, y2, x3, y3;
  float xx1, yy1, xx2, yy2, xx3, yy3;
  float upSizeFactor = 100;
  color cF;

  Triangle() {
  }

  void display() {
    if (frameCount % 100 == 0) {
      getFill();
      getNumbers();
    }
    updateTriangle();
    drawTriangle(cF);
  }

  void updateTriangle() {
    x1 = lerp(x1, xx1, 0.15);
    y1 = lerp(y1, yy1, 0.15);
    x2 = lerp(x2, xx2, 0.15);
    y2 = lerp(y2, yy2, 0.15);
    x3 = lerp(x3, xx3, 0.15);
    y3 = lerp(y3, yy3, 0.15);
  }

  void getNumbers() {
    x1 = floor((random(3) - 1)) * upSizeFactor;
    y1 = floor((random(3) - 1)) * upSizeFactor;
    x2 = floor((random(3) - 1)) * upSizeFactor;
    y2 = floor((random(3) - 1)) * upSizeFactor;
    x3 = floor((random(3) - 1)) * upSizeFactor;
    y3 = floor((random(3) - 1)) * upSizeFactor;

    x1 = xx1;
    y1 = yy1;
    x2 = xx2;
    y2 = yy2;
    x3 = xx3;
    y3 = yy3;

    xx1 = floor((random(3) - 1)) * upSizeFactor;
    yy1 = floor((random(3) - 1)) * upSizeFactor;
    xx2 = floor((random(3) - 1)) * upSizeFactor;
    yy2 = floor((random(3) - 1)) * upSizeFactor;
    xx3 = floor((random(3) - 1)) * upSizeFactor;
    yy3 = floor((random(3) - 1)) * upSizeFactor;
  }

  void drawTriangle(color cF_) {
    beginShape();
    fill(cF_);
    vertex(x1, y1);
    vertex(x2, y2);
    vertex(x3, y3);
    endShape();
  }

  color getFill() {
    cF = color(random(100), 100, 95, 90);
    return cF;
  }
}

Here's the full log: http://pastebin.com/JbsYyNwz

Anyone knows why this is happening?

Answers

  • I don't see the source for this behavior, but it crashes on OSX too. If i move the updateTriangle()-function (line 57), so that it is executed only every 100th frame, it runs for a while and i did not see crashes.
    But this is still weird.

  • Well i'm relatively new to processing and programming so i'm not sure if it's my code that's causing the crash or something is wrong with Processing. Thanks!

Sign In or Register to comment.