Skip to content

Sketch Window Resizing Issues with Java2D Renderer on Windows  #931

@MartinTheSun

Description

@MartinTheSun

Most appropriate sub-area of Processing 4?

Core/Environment/Rendering

Processing version

4.3 and 4.3.1

Operating system

Window 11, with Nvidia RTXA4000

Steps to reproduce this

"1. I use Processing 4.3 and 4.3.1. I find that I cannot resize the
Processing window if I use Java2D as the renderer. This situation does
not always happen. After many tests on different machines, I find that it
specifically happens under this settings: "Window + desktop + with
Nvidia graphic card". The problem does not happen on notebook with
Nvidia card and not happen on Mac. I believe that the Java2D renderer
has certain problem to work with the high-end graphic card (e.g. Nvidia
RTX A4000 which is the GPU on my PC desktop ). Running the following
sample program and resize the window can let you experience the problem
(but the problem only happened by running it in window desktop with high end Nvidia card)

  1. I find that the problem can be eased (but not solved) if I change the
    frameRate() to '1' during window resize and resume it back to "60" after
    resize. Then the window sometimes can be resize without problem but not
    every time. I tried many other approaches but all of them not working.
    By the way, if I use other renderer like P2D, OpenGL, this problem does
    not exist. For example, changing the renderer to P2D in the following sample program
    and run it again in my PC desktop, I can resize the window without problem.

  2. I sincerely hope that the development team can handle this bug in the
    new release of Processing. I am now relying Processing to build a
    software with multiple window and this problem gives me a lot of
    inconvenience which is not a problem that i am capable to solve from my
    side. The scale of my software is too big and not possible to change the
    renderer to others. Thus I hope your team can try solving this issues in the new version
    in future. If you need any more information please let me know. Many thanks in
    advance.
    "

snippet

// Paste your code below :)

int i=0;
void setup()
{
   size(800, 600);
   surface.setResizable(true);

}
void draw()
{
   background(i%256);
   i++;
   line(0, 0, width, height);
   line(width, 0, 0, height);
}

Additional context

No response

Would you like to work on the issue?

yes, i can try

Activity

MartinTheSun

MartinTheSun commented on Jan 20, 2025

@MartinTheSun
Author

For more information, the following is the specification of my PC. My PC is just one example to have this problem. I know three more cases which all include Window desktop with high-end Nvidia GPU (e.g. Nvidia GeForce RTX4070 EX GAMER WHITE 12GB GDDR6X in one of those cases).

Image

Stefterv

Stefterv commented on Jan 20, 2025

@Stefterv
Collaborator
2025-01-20.11-05-47.mp4

Is this an accurate recording of the issue you are having?

Stefterv

Stefterv commented on Jan 20, 2025

@Stefterv
Collaborator

I see this on a VM without a graphics card as well so doesn't seem connected to the graphics drivers / card directly

changed the title [-]reporting a bug for Processing, related with Java2D and graphic card conflict[/-] [+]Sketch Window Resizing Issues with Java2D Renderer on Windows [/+] on Jan 20, 2025
MartinTheSun

MartinTheSun commented on Jan 21, 2025

@MartinTheSun
Author

yes, if the problem happens, it happens exactly like what your video shows. Part of the window is black, and the color change stops (no more white to black and black to white inside the window)

I try to upload a video that i captured when I run this code on a PC without Nvidia card. I failed to upload it here so i put it to YouTube temporarily. Here is the link:
https://youtu.be/3GV6idiBxP8

This video shows you how it looks like when no problem happens.

My software are used by different users on different machines. From all the information that i collected, all problem cases involve Nvidia card on PC desktop. On the other hand, i did not come across such problem on a PC desktop without Nvidia card. This problem does not even happen on notebook with Nvidia card. Thus I believe that it is the high-end Nvidia card that does not work well with Java2D.

If you change the code "size(800, 600);" to "size(800, 600, P2D);" or "size(800, 600, OPENGL);". The program works without problem in PC dekstop with Nvidia card, although dragging the edge of window is a bit difficult under these two cases.

Stefterv

Stefterv commented on Jan 21, 2025

@Stefterv
Collaborator

Thanks for confirming the issue, I've created a minimum reproducible example:

void setup(){
  surface.setResizable(true);
}
void draw(){
  text("Hello world", 10, 10);
}
Stefterv

Stefterv commented on Jan 21, 2025

@Stefterv
Collaborator

I've traced the issue to these lines:

canvas.setBounds((contentW - sketchWidth)/2,
(contentH - sketchHeight)/2,
sketchWidth, sketchHeight);

Disabling these stops the crash, pausing on them with a debugger also stops it so it leads me suspect a race condition

Stefterv

Stefterv commented on Jan 21, 2025

@Stefterv
Collaborator
void draw(){
  frameRate(9999);
  surface.setSize(frameCount + 100, 100);
}

Even smaller example of the issue. This crashes reliably on my machine with 30 or so frames

added a commit that references this issue on Jan 21, 2025
Stefterv

Stefterv commented on Jan 21, 2025

@Stefterv
Collaborator

Hi @MartinTheSun I've added a PR that might hopefully solve the issue.

Please download the test version of processing here https://github.com/processing/processing4/actions/runs/12882788847/job/35915711434 and let me know if that solves your issue

15 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcore

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @SableRaf@Stefterv@MartinTheSun

      Issue actions

        Sketch Window Resizing Issues with Java2D Renderer on Windows · Issue #931 · processing/processing4