[Fix] (P14): latch a lost GPU device per session on Magma and Espryt instead of aborting the whole server

This commit is contained in:
2026-10-02 13:37:58 -04:00
parent d03fe4c9dd
commit 58c3d9bde5
16 changed files with 421 additions and 30 deletions
+7 -1
View File
@@ -57,6 +57,11 @@
// server-side resource its session had to have is gone - so it reads a clean device loss. Not
// DeviceLost: that code is the latch's own, never a family's projection (see its bucket above).
//
// BackendDeviceLost: the GPU device (Magma's VkDevice, Espryt's EGL context) a session renders
// with was lost to a GPU fault or hang. It is only ever LATCHED (MGPipeSessionLatch), so the one
// session ends and the display server's other sessions keep running; the waiting client is told
// what ServerCrashed says and reads a lost context. Not DeviceLost, for ServerWindowLost's reason.
//
// Two words were NOT given rows, they were collapsed instead: `InitialBytesNotCarried`
// (MG_Impl/Pipe/PipeFill.cpp) said the same thing as `UncarriedInitialBytes` (Client/
// WireTables.cpp) about the same record - a respecify that crossed with no initial bytes - and
@@ -113,6 +118,7 @@
X(ApplyThreadJoinTimeout, ServerCrashed, "the apply thread did not join within its bound at teardown") \
X(ApplyThreadNotRunning, ServerCrashed, "an operation needed the apply thread and it was not running") \
X(ResourceUnavailable, ServerCrashed, "the server could not obtain a native GL/Vulkan resource it had to have") \
X(ServerWindowLost, ServerCrashed, "the server's own display window was destroyed under a live on-screen session (P12)")
X(ServerWindowLost, ServerCrashed, "the server's own display window was destroyed under a live on-screen session (P12)") \
X(BackendDeviceLost, ServerCrashed, "the GPU device a session's backend renders with was lost (fault or hang reset)")
// clang-format on
+23 -10
View File
@@ -45,28 +45,41 @@ namespace MobileGL::MG_Remote {
// The line is forwarded through "%s" rather than re-used as a format: it has already been
// vsnprintf'd once, and a detail string that happened to contain a `%` would otherwise be
// read as a conversion the second time round.
[[noreturn]] void PipeSessionFailAdapter(MG_Pipe::MGPipeFatalFamily family,
const char* line) {
MGFatalFamily mapped = MGFatalFamily::ProtocolCorruption;
MGFatalFamily MapPipeFamily(MG_Pipe::MGPipeFatalFamily family) {
switch (family) {
case MG_Pipe::MGPipeFatalFamily::UnmigratedVerb:
mapped = MGFatalFamily::UnmigratedVerb;
break;
return MGFatalFamily::UnmigratedVerb;
case MG_Pipe::MGPipeFatalFamily::RoleViolation:
mapped = MGFatalFamily::RoleViolation;
break;
return MGFatalFamily::RoleViolation;
#if MOBILEGL_BUILD_DISAGGREGATED
case MG_Pipe::MGPipeFatalFamily::ProtocolCorruption:
mapped = MGFatalFamily::ProtocolCorruption;
break;
return MGFatalFamily::ProtocolCorruption;
case MG_Pipe::MGPipeFatalFamily::DeviceLost:
return MGFatalFamily::BackendDeviceLost;
#endif
}
SessionFail(mapped, "%s", line);
return MGFatalFamily::ProtocolCorruption;
}
[[noreturn]] void PipeSessionFailAdapter(MG_Pipe::MGPipeFatalFamily family,
const char* line) {
SessionFail(MapPipeFamily(family), "%s", line);
}
#if MOBILEGL_BUILD_DISAGGREGATED
// The latch twin (PipeSessionFail.h): the calling thread's session latches the fault and
// the backend returns from its verb; unarmed, SessionLatch is SessionFail.
bool PipeSessionLatchAdapter(MG_Pipe::MGPipeFatalFamily family, const char* line) {
return SessionLatch(MapPipeFamily(family), "%s", line);
}
#endif
} // namespace
void InstallPipeSessionFailHook() {
MG_Pipe::MGPipeInstallSessionFailHook(&PipeSessionFailAdapter);
#if MOBILEGL_BUILD_DISAGGREGATED
MG_Pipe::MGPipeInstallSessionLatchHook(&PipeSessionLatchAdapter, &SessionLatchArmed);
#endif
}
namespace {
+3 -1
View File
@@ -578,7 +578,9 @@ namespace MobileGL::MG_Remote::Server {
MG_Pipe::MGPPixelPackState restorePack{};
restorePack.Pack = savedPack;
MG_Pipe::MGPipeApplySetPixelPackState(restorePack);
return true;
// A backend that found its device lost latched this session and returned without filling
// the scratch: the read is declined rather than answered with stale bytes.
return !SessionLatched();
}
Bool ServerVerbSink::ReadTextureImageTight(const MG_Pipe::MGPReadbackInfo& image, Vector<Uint8>& bytes) {