4592: Fix crash in macOS when moving screen (fixes #4435) r=Jupeyy a=def-

Thanks to Jupeyy for the suggestion

Normally it crashes after a few seconds, tried moving window around, resizing, moving between screens like crazy and no crashes after 1-2 min.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2022-01-13 14:50:12 +00:00 committed by GitHub
commit ccdb758479
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2387,7 +2387,7 @@ void CGraphics_Threaded::Resize(int w, int h, int RefreshRate, bool SetWindowSiz
return;
}
// kick the command buffer
// kick the command buffer and wait
KickCommandBuffer();
WaitForIdle();
@ -2506,6 +2506,11 @@ void CGraphics_Threaded::Swap()
// kick the command buffer
KickCommandBuffer();
// TODO: Remove when https://github.com/libsdl-org/SDL/issues/5203 is fixed
#ifdef CONF_PLATFORM_MACOS
if(str_find(GetVersionString(), "Metal"))
WaitForIdle();
#endif
}
bool CGraphics_Threaded::SetVSync(bool State)