processing / processing/processing4
Sketch Window Screen Update and Publishing Issues with Java2D Render on PC without graphic card
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 494
- Forks
- 183
- Merge medio
- 4 h 39 min
- PR fusionados (30 d)
- 3
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el sketch en Windows 11 sin una tarjeta gráfica usando Processing 4.3.4 y, después, inspecciona processing.awt/PSurfaceAWT.java y processing.core/PSurfaceNone.java alrededor de la pila de renderizado indicada. Compara el comportamiento con 4.3.1 y 4.3.3; se considera terminado cuando cambiar el tamaño no provoca la excepción del búfer trasero VolatileImage ni cambia incorrectamente el tamaño del rectángulo rojo fijo en el EXE publicado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- computer-graphics, desktop
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100