[Feature] (EGL+GL): advertise EGL_EXT_create_context_robustness and GL robustness, with per-context reset notification and a pid-targeted device-loss knob.

This commit is contained in:
2026-10-03 04:37:33 -04:00
parent af2b9f4c1c
commit 90e63c9e2a
19 changed files with 963 additions and 40 deletions
+13
View File
@@ -12,6 +12,7 @@
#include "ApplyThreadPolicy.h"
#include "SessionRuntime.h"
#include <MG_Remote/FatalFunnel.h>
#include <MG_Pipe/PipeSessionFail.h>
#include <MG_Remote/Transport/LinkMetrics.h>
#include <MG_Backend/MGPipe/PipeInputs.h>
@@ -633,6 +634,18 @@ namespace MobileGL::MG_Remote::Server {
if (stopOrForfeit()) break;
if (eventRingHasRoom()) DrainRing();
if (stopOrForfeit()) break;
// The session-targeted device-loss debug knob (PipeSessionFail.h): asked here, after a
// drain, so it reaches a client that never presents or reads back, once the session
// has a context bound (it renders); latched as the backends latch a real loss. Unset
// it is one clock read per iteration.
if (!SessionLatched() && session.CurrentContextToken() != 0 &&
MG_Pipe::MGPipeDebugSessionLossDue(session.ClientPid())) {
(void)MG_Pipe::MGPipeSessionLatch(MG_Pipe::MGPipeFatalFamily::DeviceLost,
"MGPipe: Fatal{BackendDeviceLost, \"injected:pid=%u\"} - the debug "
"knob lost this session's device; the session ends and its client "
"reads a lost context, every other session keeps running",
session.ClientPid());
}
if (eventRingHasRoom() && !SessionLatched()) verbs.ReportSignaledFences(/*flush=*/false);
// PH-1 (3): a latched session applies nothing more, so this thread leaves the loop
// (and does not spin on a ring whose head is still ahead of a tail DrainRing will no
@@ -687,6 +687,7 @@ namespace MobileGL::MG_Remote::Server {
m_peer = hello->dialMode() == ::MobileGL::Wire::DialMode::Connect ? ApplyPeer::Connected
: hello->dialMode() == ::MobileGL::Wire::DialMode::Fork ? ApplyPeer::Forked
: ApplyPeer::InProcess;
m_clientPid = hello->pid();
const MobileGLResult compatible = ValidatePeerHandshake(transport, hello->abiMajor(),
hello->abiMinor(), hello->wireFingerprint(), theirStamp, hello->dialMode());
if (compatible != MOBILEGL_OK) return compatible;
@@ -370,6 +370,9 @@ namespace MobileGL::MG_Remote::Server {
// 0 = no context is bound. Every record the session has applied so far belongs to this
// token; a session that never crossed a bind_context has never bound one.
Uint64 CurrentContextToken() const { return m_currentContextToken.load(std::memory_order_acquire); }
// The pid the client's Hello names (its own, in its own pid namespace; 0 before Accept).
// What the session-targeted device-loss debug knob matches.
Uint32 ClientPid() const { return m_clientPid; }
Bool HasContext(Uint64 token) const { return m_contexts.find(token) != m_contexts.end(); }
Uint64 ContextCount() const { return static_cast<Uint64>(m_contexts.size()); }
Uint64 ContextsCreated() const { return m_contextsCreated; }
@@ -418,6 +421,7 @@ namespace MobileGL::MG_Remote::Server {
// P11 B2 (T0). Set by Accept from the Hello, by SettleAdoptT0AtBind on the apply thread;
// the inbox and the counters are the apply thread's.
Bool m_adoptT0Asked = false;
Uint32 m_clientPid = 0;
Bool m_adoptT0Quiet = false;
Uint8 m_adoptAsk = 2;
Bool m_adoptT0Settled = false;