Open zmike opened 1 year ago
Looks like whatever caught the error then tried to call the previous error handler, tossing us back into SDL, deep inside OpenGL.
That's messy. :/
No, wait, I lied, it looks like a single error triggered in glX/OpenGL, and it's calling us directly from there.
The error is from mesa, but then the SDL handler is called and deadlocks. Messy indeed.
Actually, are X11 error handlers set per-thread? I'm wondering if this background thread triggered an error, and we caught in an unexpected place because a handler we set on the main thread happened to be in effect at the time.
Specifically, this is almost certainly X11_SafetyNetErrHandler...
...which lives the entire time SDL is initialized, which is probably not a great idea, considering all our other error handlers protect tiny blocks of code. But that presumably gets set on the main thread (unless Steam did the init on a background thread before anything else got there).
It's there to try to reset the screen mode in case of disaster, but maybe that's not necessary in modern times? It certainly was in the XVidMode days.
I think they're global? Would have to double check to see any TLS usage.
I think in case of disaster the modern thing to do is let things crash and restart, but don't quote me 😬
I think in case of disaster the modern thing to do is let things crash and restart, but don't quote me
Yeah, the problem was if SDL changed the X11 display's resolution for the game and then crashed without restoring it, it would screw up the desktop (sometimes to the point where you couldn't navigate to the system settings UI to put it back manually, if the resolution was extremely low).
But again, we don't support XVidMode in SDL3, and XRandR might handle this significantly better, so this error handler might be needlessly aggressive now...if so, we should simply remove it.
@slouken, you have an opinion on this, or have an X11 expert near your desk that might have an opinion on this?
Maybe the event could be captured and then processed somewhere else in the message loop outside be the X11 error handler? Since X11 is async it shouldn't matter if if the event is processed slightly later.
This may be annoying if Xlib is running in synchronous mode though. I often use that + a breakpoint in steam's X11 error handler to catch the function call that is causing the error. But we could have a hint to avoid the delay and we'd set that hint when we make the call to make X11 synchronous.
Alternatively, we could just just skip this bit of code for steam. We could either stomp the error handler after we call SDL init, or we could have some mechanism in SDL to avoid these calls. Either via a hint or by keeping this safetynet dormant until a video mode is set via SDL.
Some extra context in case it is useful:
X11_XRRGetScreenResourcesCurrent 什么时候会返回空呢? 怎样才能让它不返回空?
When running the latest steam beta on llvmpipe, it looks like some XError handler inside SDL is causing a deadlock by attempting to call
X11_XRRGetScreenResourcesCurrent
inside the handler:X11 requests can't be made from the error handler, as this will cause a deadlock.
Mesa issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9345