processing / processing/processing4
Sketch Window Screen Update and Publishing Issues with Java2D Render on PC without graphic card
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 494
- Forks
- 183
- Avg merge
- 4h 39m
- Merged PRs (30d)
- 3
Description
Most appropriate sub-area of Processing 4?
Core/Environment/Rendering
Processing version
Processing 4.3.4, and PRocessing 4.3.3
Operating system
Windows, PC
steps to reproduce this
- find a PC with Window 11 and without graphic card installed
- run this code by Processing 4.3.4:
int i=0;
PGraphics pg;
void setup()
{
size(800, 600);
surface.setResizable(true);
pg = createGraphics(400, 300);
pg.beginDraw();
pg.fill(255,0,0);
pg.rect(0,0,400,300);
pg.endDraw();
}
void draw()
{
background(i%256);
i++;
line(0, 0, width, height);
line(width, 0, 0, height);
image(pg, (width-pg.width)/2, (height-pg.height)/2);
}
-
should see this error when you resize the window:
java.lang.NullPointerException: Cannot invoke "java.awt.image.VolatileImage.getGraphics()" because "this.backBuffers[i]" is null
at java.desktop/java.awt.Component$BltBufferStrategy.showSubRegion(Component.java:4516)
at java.desktop/java.awt.Component$BltBufferStrategy.show(Component.java:4477)
at processing.awt.PSurfaceAWT.render(PSurfaceAWT.java:249)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1389)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
NullPointerException -
If you publish the above code by Processing 4.3.4, run the EXE file, you can resize the window but the red box in the middle will also resize together with the window. The content of window does not get updated
snippet
This is an extension of my closed issue #931
I recently find that the problem that i raised up on Jan 20 (issue #931) concerning the resizing of window on PC is not completely solved. I suppose the issue that i find now has certain relation with the resizing problem on Jan 20 so i decide to continue this post rather than creating a new one.
My problem raised up on Jan 20 was that, under the use of standard JAVA renderer, Processing window cannot be resized when running on PC with high end graphic card. It just halted after resizing. There was no such problem when running on PC without graphic card. After using the Processing 4.3.3 given by @Stefterv on Jan 21, this problem disappeared and i can resize Processing window on PC with graphic card. However, i do not notice until these few days that a related problem go back to the case of PC without graphic card.
Actually a more completed code to represent my situation should be like the following. Apart from the window, there is a red rectangle always in the middle of the window with 400 width and 300 height:
int i=0;
PGraphics pg;
void setup()
{
size(800, 600);
surface.setResizable(true);
pg = createGraphics(400, 300);
pg.beginDraw();
pg.fill(255,0,0);
pg.rect(0,0,400,300);
pg.endDraw();
}
void draw()
{
background(i%256);
i++;
line(0, 0, width, height);
line(width, 0, 0, height);
image(pg, (width-pg.width)/2, (height-pg.height)/2);
}
[For the case of PC with graphic card]
When running this code by Processing 4.3.4 on PC with high end graphic card. Everything is ok. Window can resize and the red box always keeps it size and DO NOT resize together with the window. If I publish the code by Processing 4.3.4 as a EXE file, in most of the time it also run correctly.
[For the case of PC without graphic card]
When running this code directly by Processing 4.3.1 on PC without graphics card, it is also fine without problem. However, if I run the code by Processing 4.3.4 on PC without graphics card, it can run but then it has error if i resize the window. The error is like this:
java.lang.NullPointerException: Cannot invoke "java.awt.image.VolatileImage.getGraphics()" because "this.backBuffers[i]" is null
at java.desktop/java.awt.Component$BltBufferStrategy.showSubRegion(Component.java:4516)
at java.desktop/java.awt.Component$BltBufferStrategy.show(Component.java:4477)
at processing.awt.PSurfaceAWT.render(PSurfaceAWT.java:249)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1389)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
NullPointerException
Then if I publish the code as EXE file by Processing 4.3.1, the EXE file runs fine and red box does not resize together with the window on PC without graphic card. However if I publish the code as EXE file by Processing 4.3.4 and run it on PC without graphic card, the window can be resized without problem but the red box also resize together with the window rather than keeping its size unchanged. I suspect that the content on the window does not get updated when window is resized. This happen on the EXE file after publishing. Unfortunately it affects me very much since I have to publish my code as applicable software for others to use and many of them have no graphic card.
To explain the situation in a better way, here are two videos and i put them on youtube temporarily as i cannot attach them here:
The first video is the case of running the code on PC without graphic card, the code is executed by Processing 4.3.1 so it can run. The EXE file is published by Processing 4.3.4, in the later part of the first video, you should see that i am running the EXE version and the red box resizes together with the window. The second video is the case of running the code on PC with graphic card, no problem by running it inside Processing 4.3.4 or by EXE file published by Processing 4.3.4
I test this issue on more than one PC, some have graphic card and some have not. The problem exists so i think it is not related with any individual PC settings
(Finally, I want to add a point, running the EXE file on PC with graphic card is not 100% ok. In most of time it works but there may be one or two times that it also shows the same problem as how it behaves when running on PC without graphic card, i.e. the red box also resize, although it does not happen often)
Additional context
No response
Would you like to work on the issue?
yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sketch on Windows 11 without a graphics card using Processing 4.3.4, then inspect processing.awt/PSurfaceAWT.java and processing.core/PSurfaceNone.java around the reported rendering stack. Compare behavior with 4.3.1 and 4.3.3; done means resizing neither raises the VolatileImage back-buffer exception nor resizes the fixed red rectangle incorrectly in the published EXE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100