wayland: Set EGL_SWAP_BEHAVIOR_PRESERVED_BIT on surface create
Description
Set EGL_SWAP_BUFFERS_PRESERVE_BIT when using wayland wm. The working theory is that this was implicitly set on X clients but not on wayland clients.
Note
Video coding is not my comfort zone so this fix is mostly me guessing on how we'd want to fix this and knowing about one line of code that does fix the problem. Please comment and set me on the right path if this is not how we want to solve this issue.
Existing Issue(s)
Issue: #7647
I've addressed your comments. As for the confusion about the fix. I haven't investigated much further and I'm not that experienced with video drivers and rendering. Compiling the example code with and without this patch does prove that it's doing something because I just get a blank transparent image without it. The one thing that's changed is that this computer (not sure if it's the same) now uses the vulkan renderer instead of opengl. I just realized. Not sure if that changes anything though.
I tested your patch, and it segfaults on Nvidia drivers. Mesa doesn't crash, but it never finds a matching EGL config. The EGL_SWAP_BEHAVIOR_PRESERVED_BIT is a bit for the EGL_SURFACE_TYPE attribute parameter. Simply putting it in the array just poisons the attribute list at best, and crashes in this case.
This appears to "fix" the issue by creating a malformed attribute list causing a matching EGL configuration to never be found, which (when it doesn't crash) causes SDL to skip over the GLES and GL drivers completely in favor of Vulkan or the software renderer.
I pushed a change that tries to enable it properly (it seems to be unsupported on many drivers and needs fallback behavior), so try it with screenshot example code from the linked issue on your system.
That would explain how it's "working" then.
I'm traveling for 2 weeks now. I'll test it when I get back.
Just a ping that I haven't forgotten about this. Just vacation times. I'll be back to normal scheduling in mid August
When attempting to confirm this problem without my submitted change (and without pulling from main) I'm no longer able to reproduce the issue. This is the case on both laptops where I was seeing the issue. I can't really explain it. I guess some related library or service must have been updated.
We can drop this PR and I will close the related issue.