Skip to content

Sort out display() being sometimes called from the EDT inside OpenGL #385

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 30, 2022 · 1 comment
Closed
Labels
help wanted Extra attention is needed opengl

Comments

@processing-bot
Copy link
Collaborator

Created by: benfry

Inside PSurfaceJOGL, we've got:

public class DrawListener implements GLEventListener {
    private boolean isInit = false;

    public void display(GLAutoDrawable drawable) {
      if (!isInit) return;

      if (display.getEDTUtil().isCurrentThreadEDT()) {
        // For some unknown reason, a few frames of the animator run on
        // the EDT. For those, we just skip this draw call to avoid badness.
        // See below for explanation of this two line hack.
        pgl.beginRender();
        pgl.endRender(sketch.sketchWindowColor());
        return;
      }

…which is an inauspicious beginning, and it doesn't get much better from there.

We need to figure out:

  1. why those calls are coming from the EDT, and
  2. how we should handle them properly

I think the answer to the first question is that any time the window manager (OS) does a UI update, rather than the Animator thread doing its thing. That said, we need something definitive on whether we should be drawing there (at the moment, the understanding is that we shouldn't) and how it should be handled instead (i.e. re-queue the event in another thread).

But this is also related to #370 to some degree, where it's unclear to what degree we're paying for badness like this lurking in the code, or something that's not entirely our fault.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Lots of similar issues in PGraphicsOpenGL.readPixels(), where Exceptions are just ignored, presumably to paper over issues during resize events.

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 opengl
Projects
None yet
Development

No branches or pull requests

2 participants