-
Notifications
You must be signed in to change notification settings - Fork 237
Troubleshooting
Please use the forum for general troubleshooting questions, especially if it's something like Processing not starting up properly, or sketches simply not running.
-
First, check this page to see if your problem is mentioned. It's long! But hitting Ctrl-F (or ⌘-F) will help you find keywords.
-
Second, check the Forum. The Forum is the place for “why isn't this working?” questions.
-
Third, search the issues list to see if your problem has already been reported.
If you don't find your problem, submit a new issue here.
When you're creating a new issue, there is an “issue template” which includes some information we need to help you find the problem. Please fill this out as best you can! We want to help, and these are the first questions will need to ask.
For best results:
-
If the issue is something like “Processing is broken” or “Processing won't start,” then please use the forum. That type of question is usually a problem specific to your machine, and requires a troubleshooting discussion. You can also check below for common causes of such problems.
-
Write a useful title for the report. “Processing broken” or “visual problem” are comically bad but also common titles. The first one isn't helpful because you're reporting an issue, so we already know you think Processing is broken. Saying “visual problem” isn't helpful because Processing is used to make visual things, so nearly all problems are “visual” problems.
-
The people receiving this report work on Processing in their free time because they think it's important for the community. Berating or insulting them is rude, demotivating, and a good way to ensure that your report is ignored.
-
We want the minimum amount of code that will still replicate the bug. The worst that can happen is we get a report with a subject saying “problem!” along with a three page program. Sure, everyone likes a puzzle, but simpler code will receive a faster response.
If your code worked in version 3 and has a problem in version 4, read the Changes in 4.0 page.
If it worked in a previous version of Processing 4, read the revisions page for clues about what might be different.
-
Try changing the sketchbook folder:
- Create an empty folder.
- In the Preferences window, set the sketchbook folder to point to this location.
- Restart Processing.
If that works, you can start moving code and libraries back, bit by bit.
-
If you're behind a proxy, see the notes about proxies on the Preferences and Customization page.
-
Preferences – Try deleting your preferences file. On Windows this is located in Users → [username] → AppData → Roaming → Processing → preferences.txt. Only delete the preferences file when Processing is not running, otherwise it will be automatically re-created.
-
Startup – Next try running from a Command Prompt by typing:
.\\processing.exe --l4j-debug
This will create a launch4j.log file which will describe what's happening during the startup. Then you can post on the discourse section of the site to inquire for help, or the bugs database if you think it's a bug.
-
Slow Startup – An exceptionally large sketchbook folder (especially on a slower machine/disk) can sometimes cause startup problems. The launcher starts, but times out because it assumes something is broken (the Processing code is still indexing the sketchbook) and says there's a launch4j error.
-
When using P2D and P3D – If you're having trouble with P2D or P3D (which use OpenGL graphics), update your graphics drivers. This is almost always the cause of problems in P2D and P3D.
-
(Temporarily) disable virus scanning Try disabling any virus scanning software. More about this below, but it might be holding things up, especially when libraries have been imported. Bitdefender is known to cause problems that we cannot fix.
Windows Defender says this software is a virus! Microsoft Windows says it's a trojan!
It's not. Unfortunately, each Processing release seems to eventually get tagged as a virus or trojan on Windows. This seems to be getting more frequent over time. I'd be more concerned if Microsoft agreed with itself on what virus or trojan the software included, but it's different each time.
Windows Defender sometimes delays the Processing download (at the end of the download, your browser may keep spinning), or even breaks the software before it can be used, by removing files that are incorrectly marked as “malicious.”
We’ve started submitting each release to Microsoft so that it won't flag us in error. If you see an error like this, make sure you're using the latest version of the software.
But then again, why trust me? I'm just an anonymous voice inside a wiki document. I could be the virus itself! Or am I a trojan? If you don't trust me (especially now), please submit the software download to Microsoft yourself using this link. They will investigate and hopefully remove the detection.
Longer-term we probably need to sign the software but we haven’t had time to figure it all out, and it may also cost us a few hundred dollars a year.
Also note that Processing releases for Windows are done inside a Virtual Machine that are only used for Processing releases. No other connections to the internet, so it’d be super hard to get a virus in there. It's not impossible, but over 280 releases, 21 years, and tens of millions of downloads, we’ve had just one—in maybe 2002?—that was infected (and that was before the virtual machine was an option, and I couldn't afford a dedicated Windows machine for testing). It was removed and replaced within a couple hours.
-
Make sure your version of OS X is supported. See the Supported Platforms page for more information.
-
Make sure you're using the latest version of your OS. If you're using Catalina, make sure you're using the latest version of Catalina. Earlier releases are not supported and may cause problems.
-
For weird hangs/nothing happening on startup. Do the following:
-
Open Applications → Utilities → Terminal.app
-
Assuming you have Processing installed in Applications, type:
cd /Applications ./Processing.app/Contents/MacOS/Processing
If that prints any error messages, report them on the Forum or as a new issue so that we can help troubleshoot the problem and prevent it in the future.
The same method can be used to see errors in exported applications.
-
If you get an OutOfMemoryError
while running your program, use the Preferences window to increase the amount of available memory. Check the box next to "Increase maximum available memory" and enter an amount.
Depending on your OS and available RAM, there are limits on how much memory you can ask for.
Use this preference with caution, because if you set the memory too high, programs will no longer run in Processing. When you hit run, you'll get error messages.
If this message appears after you hit Run, then you're trying to use more memory than the machine has installed:
Error occurred during initialization of VM
Could not reserve enough space for object heap
The following messages mean that you're trying to use more memory than the Operating System allows (regardless of how much RAM you have):
Invalid maximum heap size: -Xmx5000m
Could not create the Java virtual machine.
Invalid maximum heap size: -Xmx5g
The specified size exceeds the maximum representable size. Could not create the Java virtual machine.
The maximum is often around 50% more than the actual memory that your machine has.
Unfortunately, memory limitations set an upper bound that is outside our control. If you're having trouble creating very large images for this reason, you might look into the PDF or DXF libraries that are included with Processing, or the contributed Illustrator or SVG vector export libraries that can be found on the libraries page as another alternative for creating large format images.
Memory is like any constraint found in other media, you simply need to be more clever about how to deal with the limitations.
To check the amount of memory that's used so far, or how much is available, use Java's Runtime object:
// The amount of memory allocated so far (usually the -Xms setting)
long allocated = Runtime.getRuntime().totalMemory();
// Free memory out of the amount allocated (value above minus used)
long free = Runtime.getRuntime().freeMemory();
// The maximum amount of memory that can eventually be consumed
// by this application. This is the value set by the Preferences
// dialog box to increase the memory settings for an application.
long maximum = Runtime.getRuntime().maxMemory();
Comparing a string (quoted text) is different in Processing (Java) than it is in JavaScript, ActionScript, and some other languages, which can be confusing. For instance, while this might make sense:
String[] lines = loadStrings("sometext.txt");
for (int i = 0; i < lines.length; i++) {
if (lines[i] == "hello") {
println("hello found on line: " + i); // you'll never see this
}
}
You'll never see the message, even if "hello" is in the list. This is because a String is an Object in Java, comparing them with == will only compare whether the two things are pointing at the same memory, not their actual contents. Instead, use equals() or one of the other String methods (eg. equalsIgnoreCase
):
String[] lines = loadStrings("sometext.txt");
for (int i = 0; i < lines.length; i++) {
if (lines[i].equals("hello")) {
println("hello found on line: " + i); // happiness
}
}
"But if I write the following code, it works!"
final String HELLO = "Hello";
String hello = "Hello";
println(hello == HELLO);
That's because Java compiler detects two identical constant strings, so it groups them together, and their references (memory location) are identical. If you write instead:
final String HELLO = "Hello";
String hell = "Hell";
println(hell + "o" == HELLO);
It no longer works. Same for strings coming from an external source (file, Internet, etc.).
In Java, the result of dividing two integers will always be another integer:
int a = 2;
int b = 5;
int result = a / b;
// result is zero
While somewhat confusing at first (especially if you've been using JavaScript or other languages that don't work this way), this is later useful for more advanced programming (or simply to confuse you further when you go back to those languages).
To get fractions, use a float
instead:
float a = 2.0;
float b = 5.0;
float result = a / b;
// 'result' will be 0.4
It is not enough to just divide two integers and set them to a float:
float y = 2 / 5;
In this case, integer 2 is divided by 5, which is zero, and then zero is assigned to a float. The number doesn't become a float until the left hand side of the = sign. On the other hand, this:
float y = 2.0 / 5;
will work just fine. In this case, Java sees that 2.0 is a float, so it also converts the 5 to a float so that they can be divided, which makes it identical to:
float y = 2.0 / 5.0;
and because floats are being used on the right hand side, the result will be a float, even before it gets to the left hand side.
NaN
is shorthand for “Not a Number,” which means the result of a calculation is undefined. This is caused by dividing 0.0 by 0.0 or taking the square root of a negative number. Infinity is the result of a calculation that is too large to be normally represented by a floating-point number. It's commonly seen as the result of dividing a number by 0.0. Its opposite value, -Infinity, is the result of dividing a negative number by 0.0. These unexpected results are often hidden by variables. Check the value of your variables with print() to search for these and similar numerical problems.
The reason this doesn't work is that color(0, 0, 0, 0)
creates an int
that is simply 0
.
This means that fill(color(0, 0, 0, 0))
is the same
as fill(0)
, which is...black. This is a problem because the color
data type in Processing is just an int
value behind the scenes, and because we overload fill()
to use both int
and color
for argb colors packed into a single value, and also an int
for a gray. This is a rare issue and the complication outweighs the simplicity we get from being able to use fill()
in 99.99% of cases.
If you're hitting this problem, here are possible workarounds:
- use
fill(0, 0, 0, 0)
-
fill(c, 0)
wherec = color(0, 0, 0)
color almostTransparent = color(0, 0, 0, 1);
color almostBlack = color(1, 1, 1, 0);
In macOS Sierra, Apple changed how key repeat works. In most applications, when you press and hold a key for some characters, a small menu will pop up that shows possible alternates. For instance, holding u
might pop up a menu that includes ü
and others like it. Unfortunately, this means that pressing and holding u
inside a Processing sketch won't work properly. To fix this, you'll have to turn off that menu, by opening Applications → Utilities → Terminal and entering:
defaults write -g ApplePressAndHoldEnabled -bool false
You'll probably need to restart Processing after using this command. (It's necessary to use -g
because it needs to work for all applications that you might create and run with Processing, not just the Processing application itself.)
Note that this will turn off the menu for your other applications as well, so if you need to bring back the old behavior, do the following:
defaults write -g ApplePressAndHoldEnabled -bool true
Typing a semicolon after an if()
statement and before its associated code block causes the if
statement to do nothing:
if (somethingAmazing == true);
{
println("This happens, whether or not something is amazing.");
}
The semicolon immediately following if ()
should not be present here, as it effectively closes the if
logic, so the code block beneath it will always run (regardless of whether or not somethingAmazing
is true
or false
).
If you write a couple lines of code with no setup()
or draw()
method, you cannot mix that with code that has functions. It's either all one block of code, or everything needs to live inside functions (except for variables and whatnot).
If your code has a setup()
method and needs to keep running after setup()
has finished (for instance, to respond to mouse/key input and then call redraw()
), you must add a draw()
method, even if it's empty.
For instance, without a draw(), this code will stop after the setup()
method completes:
void setup() {
size(400, 400);
}
void keyPressed() {
println(key); // this will never happen
}
This code can be fixed by adding:
void draw() {
}
This means that you're using code that was compiled for a later version of Java than is supported by Processing.
Processing supports Java 17, so make sure that you're using Java 17 class file format for any Libraries or other code that you're trying to use with Processing.
Any code that accesses the pixels[]
array should be placed inside loadPixels()
and updatePixels()
. This may be confusing because it was not required in very old code—i.e. with some alpha/beta releases in the 1.0 series. A complete description can be found in the reference for the pixels array.
Why doesn't saveFrame (or saveStrings or saveBytes) write things to the data folder?
All saveXxxx()
functions use the path to the sketch folder, rather than its data folder. Once exported, the data folder will be embedded inside the application. This makes sure that all loadXxxx()
functions work properly—whether your app is running on Windows or Linux, or from inside a .app
package on macOS (which often cannot be modified). But it can be a little confusing if you want to save and then load.
The simple solution, if you need to save and then load data, is to explicitly include data/
in the path when saving with saveXxxx()
. This will write to the data
folder of your sketch, or when running as an application, it will create a folder named data
adjacent to the application, where it's safe for use.
Objects with alpha (lines or shapes with an alpha fill or stroke, images with alpha, all fonts) are displayed in P3D and OpenGL based on their drawing order. This creates some unfortunate effects like making things opaque if they're drawn out of order with objects above or beneath them. This is simply how 3D rendering works.
To improve appearance, add hint(ENABLE_DEPTH_SORT)
to setup()
. We don't enable this by default because it would make all sketches slower, not just ones that need it.
Names of sketches cannot start with a number, or have spaces inside. This is mostly because of a restriction on the naming of Java classes.
Also: don't name your sketch the same thing as a library or other class that's used in your sketch. For instance, your sketch shouldn't be named “Server” if you've imported the net library, because it already has a class called Server
. You can be more creative than that.
Mind the capitalization of built-in functions. If a method or variable name is two words, usually the first word is lowercase and the first letter of the second word will be capitalized. For instance: keyPressed
, movieEvent
, mouseX
, etc.
If you have a function called mousepressed()
, it won't be called when mouse events occur, because it needs the capital P on 'pressed'.
Processing sketches have a default frameRate
setting of 60. This prevents sketches from needlessly running too fast and using up excess CPU and battery.
However, 60 is only the “maximum” frame rate, if a lot of computation is in the code, the sketch will attempt to use as much CPU as is available. You can see the current frameRate
by adding this line to your sketch:
println(frameRate);
Because printing to the console a lot can slow down the frame rate that you're trying to check, you can also set it to only print on every 10th frame by using frameCount
and the %
(modulo) operator:
if (frameCount % 10 == 0) {
println(frameRate);
}
If you're using coordinates larger than (or near) 16,384 (2^15) or 32,768 (2^16), you're likely to have problems. This is because of low-level hardware and operating system limits, and not something that we can control. In fact, it's so out of our control that it's difficult when you'll hit these issues: what operating systems, what hardware, etc. Bottom line: just use smaller numbers.
Processing is designed to make it easy to create quick sketches: short code that might be one or three or even six tabs. It's not great—or intended to be used—for larger projects. This is an intentional design decision to keep it simple for the vast majority of users. We're not trying to create a full-featured IDE.
If you have more then 3-5 tabs, you're better off with IntelliJ or Eclipse or even Visual Studio Code. While the PDE may still work with a dozen tabs, we just don't recommend it, and have no plans to make changes to support it further.
Note: need to verify if this one is still an issue. It was a major problem on Windows years ago, but I'm not sure if that's still the case. [fry 220807]
The system clock sometimes goes weird, especially when using frameRate()
or delay()
. This is an old bug with the Windows version of the Java VM.
According to someone on the site: “This bug has been fixed in bug no 4500388 and one requires a PRODUCT FLAG to use the fix. This flag and fix are available in 1.3.1_4, 1.4.0_2, 1.4.1 and 1.4.2. But for Java to actually use the fix, open your Java Plug-in Control Panel in the section 'Java Runtime Parameters' just enter: -XX:+ForceTimeHighResolution
”
Hard crashes that write hs_err_pid10XX.txt
files are errors inside the Java VM, and almost always something that's out of our control.
In some cases, we can find things that might trigger the problem, but it's more likely than not to be a Java problem, or something inside native code from a library that's included.
Note: need to verify if this one is still an issue. It was extremely common on Linux, but we may even be suppressing these messages these days. I can't recall. [fry 220807]
The following message (or messages like it) on startup:
Warning: Cannot convert string "-b&h-lucida-medium-r-normal-sans-*-140-*-*-p-*-iso8859-1" to type FontStruct.
This is just a Java issue, but doesn't seem to affect anything.