Error in Processing 4 (freezing with show usage, jump to declaration etc.)

processing v4 crashes when using

  • show usage
  • jump to declaration
  • etc.
1 Like

example code, that freezes

try show usage on variable “words”



// Weltfrauentag 2023 !

//combinations of two
String[] words = {
  "mother", "daughter", "sister", "wife", "grandma", "girlfriend"
};
String[] words2 = {
  "singer", "doctor", "housewife", "teacher", "programmer", "designer", "architect", "feminist"
};

// their indexes
int currentWordIndex  = 0;
int currentWordIndex2 = 0;

// for mouse detection
boolean showMother   = false;
boolean showDaughter = false;
boolean showSister   = false;

PFont font;

float wordChangeDelay = 0.5;
float wordChangeTimer = 0;

// --------------------------------------------------------------------------------------

void setup() {
  size(600, 600);
  font = createFont("data/RobotoMono-Regular.ttf.ttf", 32); // create the font
}//setup

void draw() {
  //background(150);
  background(255, 10, 150);

  // textFont(font);
  textSize(32);
  fill(#FFFFFF);

  // show 4 lines of text ----

  String motherString = "I am a w(?)man";
  if (showMother) {
    motherString = "I am a w(" + words[currentWordIndex2] + ")man";
    if (wordChangeTimer >= wordChangeDelay) {
      currentWordIndex2++;
      if (currentWordIndex2>= words.length) {
        currentWordIndex2 = 0;
      }
      wordChangeTimer = 0;
    } else {
      wordChangeTimer += 50 / 1000.0;
    }
  }
  text(motherString, 100, 150);

  String daughterString = "I could be a w(?)man";
  if (showDaughter) {
    daughterString = "I could be a w(" + words2[currentWordIndex] + ")man";
    if (wordChangeTimer >= wordChangeDelay) {
      currentWordIndex++;
      if (currentWordIndex >= words2.length) {
        currentWordIndex = 0;
      }
      wordChangeTimer = 0;
    } else {
      wordChangeTimer += 50 / 1000.0;
    }
  }
  text(daughterString, 100, 200);

  text("but most of all", 100, 250);

  String sisterString = "I need to be (wǒ)";
  if (showSister) {
    sisterString = "I need to be w()men  ";
  }
  text(sisterString, 100, 300);
  //
}//draw

// --------------------------------------------------------------------------------------

void mouseMoved() {
  // for mouse detection

  // Check if mouse is over the word "mother"
  if (mouseX > 155 && mouseX < 225 &&
    mouseY > 135 && mouseY < 170) {
    showMother = true;
  } else {
    showMother = false;
  }

  // Check if mouse is over the word "daughter"
  if (mouseX > 125 && mouseX < 290 &&
    mouseY > 185 && mouseY < 220) {
    showDaughter = true;
  } else {
    showDaughter = false;
  }

  // Check if mouse is over the word "sister"
  if (mouseX > 155 && mouseX < 275 &&
    mouseY > 285 && mouseY < 320) {
    showSister = false;
  } else {
    showSister = true;
  }
}
//

1 Like

Hello,

With Processing 4.2 on a W10 PC it works if I remove the “odd” character:

Change this:
image

To this:
image

And it works.

This is what I see in Notepad:
image

:)

1 Like

There are related Github issues reported here:

:)

Hello,

I got a reminder of this issue today with a degrees symbol ° in my code!

These actions on the the variable test will hang Processing 4.4.4 and I must end task with Task Manager in Windows 10:

  • Show Usage…
  • Jump to decoration
  • Rename

This simple code will hang Processing 4.4.4

int test;

String s = "Yaw (Y axis): 0°";

This is what is in my Processing temp folder after running (and hanging):

// Code removed from start

int test;

String s = "Yaw (Y axis): 0\u00b0";

//Code removed from end

This is safe to use the actions on:

int test;

String s = "Yaw (Y axis): 0\u00b0";

Including to be thorough:

Adding this to my Notes:

  • Do not use any special characters!
  • Substitute them with the \u character sequence (Unicode escape sequence).

It also seems to freeze with the Lamba style in the code and using actions:

import processing.javafx.*;
import javafx.application.Platform;

void setup() {
  size(600, 600, P3D); // Set 3D canvas size
  noLoop();
}

// Secondary PApplet used to bootstrap the JavaFX UI
public class FXBoot extends PApplet {

  public void setup() {
    size(200, 200, FX2D); // Minimal invisible canvas

    Platform.runLater(() -> launchUI()); // Lambda style — active
  }

  // Creates the JavaFX slider UI
  void launchUI() {
  }
}

Not the best example because it requires the JavaFX JAR files and is shared as example only to show what is failing.
This was part of much larger code and I reduced it down to this.
I will try to find a better example!

Deleting the line allows me to use actions without freezing:

Platform.runLater(() -> launchUI()); // Lambda style — active

This works :

import javax.swing.SwingUtilities;

void setup() {
  SwingUtilities.invokeLater(() -> launchUI());  // <- Test rename/jump on launchUI
}

void launchUI() {
  println("launchUI called");
}

:)