processing / processing/processing4
Sketch Window Screen Update and Publishing Issues with Java2D Render on PC without graphic card
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 494
- Forks
- 183
- Merge moyen
- 4 h 39 min
- PR mergées (30 j)
- 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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez le sketch sous Windows 11 sans carte graphique avec Processing 4.3.4, puis examinez processing.awt/PSurfaceAWT.java et processing.core/PSurfaceNone.java autour de la pile de rendu signalée. Comparez le comportement avec 4.3.1 et 4.3.3 ; le travail est considéré comme terminé lorsque le redimensionnement ne déclenche ni l’exception du tampon arrière VolatileImage ni un redimensionnement incorrect du rectangle rouge fixe dans l’EXE publié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- computer-graphics, desktop
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100