From 625f4db47d0e6f899654e055320ec9fef5f8618f Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Tue, 29 Sep 2026 04:29:49 -0400 Subject: [PATCH] [Feat] (MG_Remote, P10 A): a present reports the fences finished so far before it returns the credit, so the client the credit releases finds the fence of a frame ago already known --- MobileGL/MG_Remote/Server/PipeApplier.cpp | 5 +++++ MobileGL/MG_Remote/Server/ServerSession.cpp | 5 +++++ MobileGL/MG_Remote/Server/ServerSession.h | 3 +++ 3 files changed, 13 insertions(+) diff --git a/MobileGL/MG_Remote/Server/PipeApplier.cpp b/MobileGL/MG_Remote/Server/PipeApplier.cpp index 5e5bf9a1..9513c49c 100644 --- a/MobileGL/MG_Remote/Server/PipeApplier.cpp +++ b/MobileGL/MG_Remote/Server/PipeApplier.cpp @@ -425,6 +425,11 @@ namespace MobileGL::MG_Remote::Server { // swap and not the record's apply. It advances presentAckSerial AND rings the client's // bell - a client parked in WaitForPresentAck(kWaitForever) needs the pair. if (ServerSession* session = ServerSession::Active()) { + // P10 (CONTRACT-P10.md ยง1): the fences finished by now are reported BEFORE the credit + // goes back - a client released by the credit polls or waits on the fence of a frame + // or two ago at once, and a report posted only after this batch would race it. A + // status query, no submit: the swap has just submitted. + if (session->EventRingHasRoom()) ReportSignaledFences(/*flush=*/false); session->ReturnPresentCredit(m_lastPresentSerial); } return true; diff --git a/MobileGL/MG_Remote/Server/ServerSession.cpp b/MobileGL/MG_Remote/Server/ServerSession.cpp index 1326c795..15a6488b 100644 --- a/MobileGL/MG_Remote/Server/ServerSession.cpp +++ b/MobileGL/MG_Remote/Server/ServerSession.cpp @@ -1144,6 +1144,11 @@ namespace MobileGL::MG_Remote::Server { PublishEvents(); } + Bool ServerSession::EventRingHasRoom() const { + if (!m_accepted || m_link == nullptr) return false; + return m_link->Signals().EventRingFull->load(std::memory_order_acquire) == 0; + } + // PH-6 (ID-P7-2). THE FIRST DROP, AND THE LATCH IT RAISES. // // Logged ONCE, by name, with everything a triage needs: which event, how big, what the diff --git a/MobileGL/MG_Remote/Server/ServerSession.h b/MobileGL/MG_Remote/Server/ServerSession.h index 9f66e09b..efdae1e4 100644 --- a/MobileGL/MG_Remote/Server/ServerSession.h +++ b/MobileGL/MG_Remote/Server/ServerSession.h @@ -214,6 +214,9 @@ namespace MobileGL::MG_Remote::Server { // found signaled. Posted and published at once - a client may be polling on it right now. // Dropped with the same loud line as PostGlError before Accept. void PostFenceSignaled(MG_Pipe::MGPipeHandle fence); + // True when SEG_EVENT is not latched full: an optional post (a fence report) goes + // there without parking the apply thread. False before Accept. + Bool EventRingHasRoom() const; Transport::ITransport* Control_Plane(); // ---- PH-6 (ID-P7-2): THE REVERSE CHANNEL IS FORFEITED, NOT FATAL -------------------