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

PyGame window stops updating after moving the window to another screen (mac) #1720

Open
levsa opened this issue May 11, 2020 · 15 comments
Open
Labels
moderate An intermediate challenge to solve Platform: MacOS

Comments

@levsa
Copy link

levsa commented May 11, 2020

If I move the PyGame window from the screen it was started on to another screen, it stops updating itself. It doesn't start updating again even if moved back to the original screen. Nothing in the terminal and Esc quits the application as normally. Tried own application and python3 -m pygame.examples.aliens

On macOS Mojave 10.14.6 (18G4032). Graphics Radeon Pro 450 2 GB, Intel HD Graphics 530 1536 MB

@illume
Copy link
Member

illume commented May 11, 2020

Hi, thanks for the report.

I think this is fixed in pygame 2. Are you using 1.9.6?
You can use the pre-release like so: python3 -m pip install pygame==2.0.0.dev8

@levsa
Copy link
Author

levsa commented May 11, 2020

No, I was using 2.0.0.dev6, sorry, forgot to include.

Tested 2.0.0.dev8 now, the issue is still present

@illume illume reopened this May 11, 2020
@illume
Copy link
Member

illume commented May 13, 2020

I can't reproduce this on my Mac 10.13.6 Intel Iris Pro 1536 MB, NVIDIA GeForce GT 750M with python 3.7. Maybe it's the MacOS version or ATI driver triggering the issue.

Can you please try with these two examples to see if they work?

python3 -m pygame.examples.aliens

This one prints out a few diagnostic issues, and renders in a different way to the first.

python3 -m pygame.examples.setmodescale

renderer: metal flags: 0b1010
accelerated
render to texture

If either of these work (or one), that narrows it down :) If they both work, then can you please post some code to reproduce?

@levsa
Copy link
Author

levsa commented May 13, 2020

pygame.examples.setmodescale works.
pygame.examples.aliens doesn't work :)

Output from pygame.examples.setmodescale

 lava@3.7.2 ~/src/lava/python/lavalamp/[master] > python3 -m pygame.examples.setmodescale
pygame 2.0.0.dev8 (SDL 2.0.12, python 3.7.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
desktops [(2560, 1440), (1920, 1200)]
renderer: opengl flags: 0b1010
accelerated
render to texture

(Using python 3.7.2)

@MyreMylar
Copy link
Contributor

I assume this is related to this:

#1725

@ghost
Copy link

ghost commented May 13, 2020

I assume this is related to this:

#1725

I don't think so. The aliens example dosen't use SCALED to get a SDL renderer, so I don't see how it could be related.

I can't reproduce this on my Mac 10.13.6 Intel Iris Pro 1536 MB, NVIDIA GeForce GT 750M with python 3.7. Maybe it's the MacOS version or ATI driver triggering the issue.

I tried it on MacOS 10.15.4, pygame2.0.0.dev8 and Python 3.8.2 and I also can't reproduce it.

@levsa
Copy link
Author

levsa commented May 13, 2020

I've just tested the setup from setmodescale in aliens.

If I use

    winstyle = pg.SCALED #0  # |FULLSCREEN
    bestdepth = pg.display.mode_ok(SCREENRECT.size, winstyle, 32)
    screen = pg.display.set_mode(SCREENRECT.size, winstyle, bestdepth)

it works, and pg.display.get_renderer_info() returns: ('opengl', 10)

But if I use

    winstyle = 0  # |FULLSCREEN
    bestdepth = pg.display.mode_ok(SCREENRECT.size, winstyle, 32)
    screen = pg.display.set_mode(SCREENRECT.size, winstyle, bestdepth)

it stops working and pg.display.get_renderer_info() returns None

@MyreMylar MyreMylar added the moderate An intermediate challenge to solve label May 15, 2020
@shortbow123
Copy link

This also happens to me, all I wanted to do was to enter some code into idle but it decided to not work, I went to flip the display but I got nothing...

@shortbow123
Copy link

I am also using version 2.0.0.dev9 and I get None when I get_renderer_info()

@shortbow123
Copy link

To add more to my previous comments, my window still gets frozen but it says I am using metal

@xandark
Copy link

xandark commented Jun 1, 2020

I think I'm having the identical issue but on Linux (KDE neon).

I noticed that this occurred with pygame 2.0.0.dev8 and has continued with dev10.

It happens with my personal game, and also when I run python3 -m pygame.examples.aliens. When I bring an arbitrary window in front of the Aliens game window and then bring Aliens to the front again, Aliens doesn't repaint its background; you see the objects drawing on the garbage of the previous window's contents.

I've made a screen capture so you can see it here. (I tweaked the game to slow down the aliens so that the player wouldn't die and the window wouldn't disappear too quickly...)

PyGame dev10 bad screen updates.zip

I've also tried python3 -m pygame.examples.setmodescale and the background would repaint itself properly, all good there. This was its console output:

pygame 2.0.0.dev10 (SDL 2.0.12, python 3.6.9)
Hello from the pygame community. https://www.pygame.org/contribute.html
desktops [(1366, 768)]
renderer: opengl flags: 0b1010
accelerated
render to texture

Anything else you need to know?

@robertpfeiffer
Copy link
Contributor

Not to be super condescending, but if you lose in aliens, the game stops updating and quits, right? Are you sure it isn't that? Maybe we should add an animated (GAME OVER, PRESS ANY KEY TO QUIT) screen to this game to make this easier to test, or make the game pause when it loses focus.

If it isn't that, we'd need to look into the way pygame.display.update actually works on mac and X11, including the different code paths SDL2 takes on these platforms.

@MyreMylar
Copy link
Contributor

MyreMylar commented Jun 9, 2020

It's not that - you can how it looks in the attached video.

I do suspect it is an artefact of dirty rect optimisation for the aliens game, because pygame clearly is still updating, it's just only updating the display surface under the aliens that move.

Perhaps display.update() calls using the rects argument need to check for changes in the the SDL_WINDOW_MOUSE_FOCUS flag and then repaint the whole screen once rather than using the rects?

@rethanon
Copy link
Contributor

rethanon commented Jul 5, 2020

For what it's worth I can't replicate the issue, works fine on my MacBook running Catalina 10.15.5 using pygame 2.0.0.dev10 and python 3.8.3, although

@shortbow123
Copy link

shortbow123 commented Jul 5, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moderate An intermediate challenge to solve Platform: MacOS
Projects
None yet
Development

No branches or pull requests

7 participants