Skip to content
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

Weird jittery behavior when background() is not called in draw() while using the skia renderer. #425

Closed
procub3r opened this issue Feb 23, 2023 · 12 comments

Comments

@procub3r
Copy link

Describe the bug
When background() is not called in draw(), there is a weird jittery behavior that is observed while the graphics are being rendered using the skia renderer.

To Reproduce
Run an example program:

from p5 import *

def size():
    pass

def draw():
    # Do not call background() here.
    circle(mouse_x, mouse_y, 50)

run(renderer='skia')

Expected behavior
Smooth rendering without any weird jittery behavior.

Screen capture

jittery.mov

System information:

  • p5 release: Current master branch 8f4777b
  • Python version: 3.10.10
  • Operating system: Windows 11

Additional context
#423 (comment)

@github-actions
Copy link
Contributor

Thank you for submitting your first issue to p5py

@tushar5526
Copy link
Member

This seems to be related to some bug with swapping of frame buffer and this was not the case earlier. I think a good strategy would be to go a few commits back and identify for the buggy commit

@tushar5526
Copy link
Member

tushar5526 commented Feb 26, 2023

6b079cf -- This is the commit that produced this bug. Things are working fine before this commit. Would you like to do a fix for this ?

@tushar5526
Copy link
Member

tushar5526 commented Feb 26, 2023

We only need to disable this line - 6b079cf#diff-7a18b014da674a8330d705e9c488589c23a673a0062af59d7d1e1270181f673aL80 and test it on windows and then check for a possible fix.

@procub3r
Copy link
Author

Cool! I'll get in on this.

@procub3r
Copy link
Author

I'm slightly confused 😅
What do you mean by disabling that line? That line doesn't exist in the master branch anymore.

Adding back all three of those lines seems to work (yet to test on windows though).

@procub3r
Copy link
Author

Adding back all three of those lines seems to error out on windows. This is the error that I get:

Traceback (most recent call last):
  File "c:\dev\p5dev\test\main.py", line 9, in <module>
    run(renderer='skia')
  File "C:\Users\procub3r\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\userspace.py", line 231, in run
    p5.sketch.start()
  File "C:\Users\procub3r\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\Skia2DRenderer\base.py", line 159, in start
    self.window = self.glfw_window()
  File "C:\Users\procub3r\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\Skia2DRenderer\base.py", line 80, in glfw_window
    GL.glEnable(GL.GL_MULTISAMPLE)
  File "C:\Users\procub3r\AppData\Local\Programs\Python\Python310\lib\site-packages\OpenGL\platform\baseplatform.py", line
415, in __call__
    return self( *args, **named )
  File "src/errorchecker.pyx", line 58, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError
OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'invalid operation',
        baseOperation = glEnable,
        cArguments = (GL_MULTISAMPLE,)
)

Adding back just the first two lines and commenting out GL.glEnable(GL.GL_MULTISAMPLE) doesn't produce an error but it doesn't fix the issue either. The jittery behavior persists.

@procub3r
Copy link
Author

My initial thought was that maybe the buffers were being swapped more than once in a single frame due to some bug. But I've just tested it and that doesn't seem to be the case.

Unrelated note: I don't quite understand the role GL.glEnable(GL.GL_MULTISAMPLE) plays here.
I mean for some reason, when I add that line in, the jittery behavior stops on linux and it works smoothly. But it simply errors out on windows.

@tushar5526
Copy link
Member

Sorry for all the confusion. I removed those 3 lines to remove the error that you were facing. Those lines are some configurations for GLFW related to anti-aliasing etc. you can read about them in the glfw docs.

I mean for some reason, when I add that line in, the jittery behavior stops on linux and it works smoothly. But it simply errors out on windows.

This is what we have to fix for. Research why its throwing error on windows and workarounds for it.

@tushar5526
Copy link
Member

#399 - more context for you.

@procub3r
Copy link
Author

Thanks for the clarification! I know what to do now :D

@tushar5526
Copy link
Member

Closed by #446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants