Skip to content

Calling windowResize() with multiple PApplet instances running destabilizes the sketch #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
processing-bot opened this issue Jan 3, 2023 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@processing-bot
Copy link
Collaborator

Created by: onimatrix

Description

Modifying the MultipleWindows example to use P3D for the main window and JAVA2D for the child one, plus doing a windowResize in the ChildApplet::draw() method, leaves the child window frozen.

ChildApplet childA;

void setup()
{
  size(400, 300, P3D);    
  childA = new ChildApplet();
}

class ChildApplet extends PApplet
{
  ChildApplet()
  {
    super();
    PApplet.runSketch(new String[] { this.getClass().getName() }, this);
  }

  void settings()
  {
    size(400, 300);
  }

  void setup()
  {
    windowResizable(true);
  }

  void draw()
  {
    println("frame #" + frameCount);
    windowResize(width + 1, height); 
  }
}

There's a second, (maybe related?) issue, where calling windowMove and windowResize on a simple sketch's draw() triggers an exception with every frame for P2D and P3D, and freezes completely in JAVA2D

void settings()
{
  size(400, 300, P2D);
}

void setup()
{
  windowResizable(true);
}

void draw()
{
  windowMove(20, 20);
  println("frame #" + frameCount);
  windowResize(width + 1, height); 
}

It seems that calling windowMove before calling windowResize is what triggers the issue here.
If I move windowMove to setup() instead, it only triggers the issue once and then resizes successfully (but remains frozen in JAVA2D)

Thank you for your time!

Your Environment

This is happening on Windows 10 with Processing 4.1.1.

Possible Causes / Solutions

Might be related to #507?

@processing-bot
Copy link
Collaborator Author

Created by: benfry

When you have more than one PApplet running at a time, things are going to get messy very quickly… We'll have to see about a fix, but that'll mostly be in #507.

@processing-bot
Copy link
Collaborator Author

Created by: retiutut

For some reason, not really affected by the Fullscreen button for the window itself, or the windows "snap to position" feature.

Only freezes when resizing from the edges after about 1 second.


Update: Fixed by specifying P2D renderer.
Update: Using P2D renderer though doesn't allow me to close the child sketch window.

This worked fine in Processing 3. We should be able to create child windows of the main process that can be resized and closed.

@processing-bot
Copy link
Collaborator Author

Created by: retiutut

Investigated this again. Window resizing is broken for JAVA2D, but not for P2D.

If we could only exit() in the child PApplet class while using P2D renderer using default implementation or something like

    @Override
    void exit() {
        dispose();
    }

The above is what I was doing in Processing 3 with JAVA2D. If you don't override exit() and you close the child PApplet, it usually closes the child and the parent.

@Stefterv
Copy link
Collaborator

Fixed by #932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants