[Ohrrpgce] [ohrrpgce/ohrrpgce] Mac/gfx_sdl2: Random crash when resizing window (#1181)

Ralph Versteegen notifications at github.com
Wed Oct 28 18:47:37 PDT 2020


Getting an occasional crash on resizing the window in gfx_sdl2 (64 bit, Mac OS 10.13.6, SDL 2.0.12). It seems to be a bit more likely the larger the window is resized, and happens almost always when the window is maximised (e.g. by double-clicking the bottom-right corner of the window or the "Zoom" Window menu option that appears when not linking to SDLMain.m). Doesn't happen when clicking the green window frame button to fullscreen the app.

I found reports of the same/similar problem in Firefox ([here](https://bugzilla.mozilla.org/show_bug.cgi?id=1575023) and [here](https://bugzilla.mozilla.org/show_bug.cgi?id=1474216)) and Qt ([here](https://bugreports.qt.io/browse/QTBUG-68524)). Qt seemed to be rendering in a thread and blamed it on that. (We aren't, we only use the main thread). They filed apparently filed as a bug with Apple.
The Firefox bug is described as "macOS crash which affects 10.13, 10.14 and 10.15. All of the comments mention crashing when resizing windows, or zooming in and zooming out." "There were 10 crashes in 70 nightly, none in 70 beta and none in 71 nightly."

It happens when calling SDL_RenderPresent (from gfx_present):
```
0   libsystem_platform.dylib      	0x00007fff63b27d4b _platform_bzero$VARIANT$Base + 59
1   GLRendererFloat               	0x00007fff45ff355f gldSetZero + 63
2   GLRendererFloat               	0x00007fff45feb56e gldClearDrawBuffer + 3792
3   GLRendererFloat               	0x00007fff45fecda5 gldClearFramebufferData + 49
4   GLEngine                      	0x00007fff45e6f264 glClear_Exec + 541
5   org.libsdl.SDL2               	0x00000001003da945 0x100309000 + 858437
6   org.libsdl.SDL2               	0x00000001003b8bcb 0x100309000 + 719819
7   ohrrpgce-custom               	0x000000010017b868 present_internal2 + 232 (gfx_sdl2.bas:1053)
```
If I comment out the unnecessary SDL_RenderClear call before the RenderPresent, I instead get:
```
0   libGLProgrammability.dylib    	0x00007fff4537db23 glvmRasterOpRead + 803
1   libGLProgrammability.dylib    	0x00007fff45378127 glvmInterpretFPTransformFour + 6327
2   GLRendererFloat               	0x00007fff45ffcfce gldLLVMFPTransform + 558
3   ???                           	0x0000000100fe672e 0 + 4311639854
4   GLRendererFloat               	0x00007fff45ff7107 gldRenderFillTriangleStrip + 149
5   ???                           	0x0000000100fe5113 0 + 4311634195
6   GLEngine                      	0x00007fff45e6bd7a glEnd_Exec + 58
7   org.libsdl.SDL2               	0x00000001003b7ffe 0x10030a000 + 712702
8   org.libsdl.SDL2               	0x00000001003a0aa9 0x10030a000 + 617129
9   ohrrpgce-custom               	0x000000010017b866 present_internal2 + 230 (gfx_sdl2.bas:1054)
10  ohrrpgce-custom               	0x000000010017baa2 present_internal + 178 (gfx_sdl2.bas:550)
```

Searching for a workaround.
Searching SDL bugzilla only found [this bug](https://bugzilla.libsdl.org/show_bug.cgi?id=5046) (bugfix after the SDL 2.0.12 release), a crash on resize due to touching the OpenGL context from another thread. I assume it only happens if you're calling SDL functions from multiple threads. But I wonder whether it actually is this bug, since SDL does use a number of threads.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ohrrpgce/ohrrpgce/issues/1181
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20201028/841ec272/attachment.html>


More information about the Ohrrpgce mailing list