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

Mac - pygame.Window.flip() seemingly doesn't work since v2.5.0.dev4 was implemented #3056

Closed
rethanon opened this issue Aug 15, 2024 · 5 comments · Fixed by #3059
Closed
Labels
bug Not working as intended

Comments

@rethanon
Copy link
Contributor

rethanon commented Aug 15, 2024

I was following up on a help post on the Discord server, and I have replicated an issue where pygame.Window.flip() no longer seems to work on Mac.

Current behavior:

When you create a window and get the associated surface, if you fill the surface, or draw to it, or load an image and blit to it, then call flip(), the screen is not updated and remains blank/black.

Expected behavior:

The window surface is updated and images, shapes, fill colors are presented correctly on the surface.

Steps to reproduce:

On a Mac:

  1. Create a pygame.WIndow object
  2. get the display surface by calling pygame.Window.get_surface()
  3. fill the surface, or draw to it, or blit an image to it
  4. call pygame.Window.flip()
  5. Observe the screen remaining blank/black

Test code

The test code is that which is listed in the docs, however I have tested with drawing shapes and blitting images to the surface and have the same results:

import pygame
 
win = pygame.Window()
surf = win.get_surface()  # get the window surface
 
while True:
   for event in pygame.event.get():
      if event.type == pygame.QUIT:
            pygame.quit()
            raise SystemExit
 
   # draw something on the surface
   surf.fill("red")
 
   win.flip()  # update the surface to the window

Please note I've repeated the testing on Windows and have no issues, works fine.

On Mac my testing showed the following:
2.4.0 to 2.5.0.dev2 - sample code works successfully
2.5.0.dev4 and beyond - sample code runs but the window / surface is not updated

@rethanon rethanon added the bug Not working as intended label Aug 15, 2024
@ddorn
Copy link
Contributor

ddorn commented Aug 16, 2024

I have the same problem on 2.5.0 and 2.5.1 on wayland (with swaywm) and it was also fine with 2.4.1. I worked around it by setting $SDL_VIDEODRIVER=x11 instead of $SDL_VIDEODRIVER=wayland.

@Starbuck5
Copy link
Member

Thank you for the report.

Theory time: I've looked into the code, I think it is this 235b675

Wouldn't have figured this out today if @oddbookworm hadn't asked you on discord what win.opengl printed (True, where it should be False).

The commit I referenced assumes that if the SDL window says it uses OpenGL, that we requested it. What's actually happening is that SDL is internally using a renderer instead of a surface on your platforms, making a renderer using opengl, the window gets marked as opengl, and then we're off to the races.

This is an absolutely classic bug for us, SDL creating renderers when we asked for surfaces has bitten us before.

Try setting the env SDL_RENDER_DRIVER=metal (Rethanon), or SDL_FRAMEBUFFER_ACCELERATION=0 (either platform).

@Starbuck5
Copy link
Member

I put up #3059 as an attempted fix, although I'm not able to reproduce the problem on Windows.

@ddorn
Copy link
Contributor

ddorn commented Aug 17, 2024

Thanks!
Though setting SDL_FRAMEBUFFER_ACCELERATION doesn't work for me, instead of having a black screen, it fails with pygame.error: Window framebuffer support not available on pygame 2.5.1, wayland+swaywm.

@niajane: Does it work on your mac?

@rethanon
Copy link
Contributor Author

rethanon commented Aug 17, 2024

I'm not sure how to set env variables myself, but I installed #3059 and it fixes the issue, thanks for looking at this.

EDIT: Sorry, just confirming I tested the fix on Intel MacBook Pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants