processing / processing/processing4

Sketch Window Screen Update and Publishing Issues with Java2D Render on PC without graphic card

Đang mở
#1,032 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug
Ngôn ngữ chính
Java
Star
494
Fork
183
Merge trung bình
4 giờ 39 phút
Pull request đã merge (30 ngày)
3

Mô tả

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
  1. find a PC with Window 11 and without graphic card installed
  2. 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);
}
  1. 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

  2. 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:

https://youtu.be/lMtrNX8p7-c

https://youtu.be/xRLfz0D7XF8

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện sketch trên Windows 11 không có card đồ họa bằng Processing 4.3.4, sau đó kiểm tra processing.awt/PSurfaceAWT.java và processing.core/PSurfaceNone.java xung quanh rendering stack được báo cáo. So sánh hành vi với 4.3.1 và 4.3.3; được xem là hoàn tất khi việc thay đổi kích thước không gây ra ngoại lệ bộ đệm sau VolatileImage cũng không thay đổi kích thước sai cho hình chữ nhật màu đỏ cố định trong EXE đã phát hành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
computer-graphics, desktop
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.