mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-18 07:23:24 +09:00
[MobileGL, MG_Backend, MG_Remote, scripts] (P7): the split wire comes up before the first frontend object, and the caps mirror stops deciding a family's fate from a placeholder
F1. `MG_State::Init()` runs before `MG_Backend::Init()`, and the second is what
starts the session - so `GLContext`'s `TextureState` constructor materialised its
eleven default texture objects, each of them emitted `resource_create` through
`FamilyIsLive`, and `CapsMirror::ServerConsumes(0x400)` answered every one of them
from a generation-0 placeholder with `callMask=0`. All eleven records were dropped
and the whole event was one WARN line:
MG_Remote client: the server does not consume MGPipe subsystem 0x400 - this
family emits NOTHING and the legacy pull path runs for it (R-8). callMask=0x0,
caps generation 0
It is NOT a race. The line reproduces byte-for-byte on lavapipe and on the Adreno
830, because the two Init calls are two statements on one thread. And "the legacy
pull path runs for it" is false on the client under split: there is no pull path
on this side of the wire, so withholding is not a fallback, it is a drop that only
a later respecify's self-healing create ever undoes.
Two of the three options the brief offered do not apply, and both facts are worth
recording. (b) "extend the P6.5 fix to inproc" is already the tree: `FinishStartup`
step 7 is the one funnel every transport reaches and it will not return without a
real snapshot. (a) "a bounded wait in Consumes()" cannot work alone and would
deadlock: at `MG_State::Init()` no handshake is in flight, and the one that will
land is started later BY THE SAME THREAD.
So the fix is the ORDER, with the rule behind it as the gate:
* `MobileGL::Initialize` calls `MG_Backend::InitSplitRolesBeforeState()` before
`MG_State::Init()`. `Init()`'s split arm becomes one body, `InitSplitBackend()`,
shared with the direct callers that still reach `Init()`; the monolith arm keeps
its place after `MG_State::Init()`, because moving it would move pull `.text`.
* `CapsMirror::ServerConsumes()` refuses to answer from a placeholder. It waits,
bounded, when a bring-up is genuinely in flight on ANOTHER thread, and otherwise
dies as `Fatal{CapsBeforeFirstSnapshot, "<family>"}` through `SessionFail` -
a new family word, one row in `FatalFamilies.def`, no new abort site.
* Two arms are exempt and say why in place: the server arm (`MGPipeServerArm()` -
the apply thread and the spawn server, where the client's mirror is the wrong
object rather than a late one), and a process whose own configuration never
asked for a split transport (`MG_Config::SplitTransportRequestedByConfig`, set
by `MG_ConfigLoader::InitTransport`, which is what tells a real run apart from a
fixture that assigns `MG_Config::Transport` by hand).
The read accessors keep P5's ruling untouched: `LogBackendInfo` reads
`GetRendererInfo()` during `MG_Backend::Init()` and an abort there is a process that
cannot start. Only the DECISION changed. The warning was not made quieter and the
callMask was not defaulted to all-ones.
`MOBILEGL_TEST_DELAY_FIRST_CAPS_MS` (server side, disaggregated builds, inert unless
set) holds back the FIRST CapsSnapshot. On spawn/tcp that is a genuinely late
snapshot in another process and it exercises the client's step-7 wait; on inproc it
only makes `Start` slower, which is itself the proof that the only window a client
can read a placeholder in is the one before `Start` is called.
G1: `.text` 0xa52203 and the 30570-symbol list identical to p7-before/pull-syms.txt.
Census: 79 abort sites unchanged, 44 family words (was 43). Link ratchet: 186,
unchanged.
This commit is contained in:
@@ -75,6 +75,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// of the answer on the client under split: MGPipeGetResourceOps() is the SERVER's
|
||||
// registration and is null in the client process, which would silently disable the
|
||||
// whole push path in the one mode that matters.
|
||||
//
|
||||
// F1 (P7 wave 2): IT NEVER ANSWERS FROM A PLACEHOLDER ANY MORE. See RequireFirstSnapshot.
|
||||
Bool ServerConsumes(Uint64 subsystemBit) const;
|
||||
|
||||
// GLFunctionsTable::PrefersCpuXfbPrimitiveAccounting (BackendObject.h:274) does NOT
|
||||
@@ -84,6 +86,27 @@ namespace MobileGL::MG_Remote::Client {
|
||||
Bool PrefersCpuXfbPrimitiveAccounting() const;
|
||||
|
||||
private:
|
||||
// F1 (P7 wave 2). THE PLACEHOLDER MAY NOT ANSWER "THIS FAMILY HAS NO CONSUMER".
|
||||
//
|
||||
// The placeholder rule above is right for the READ accessors - one imprecise startup
|
||||
// log line is cheaper than restructuring MG_Backend::Init() - and it was catastrophic
|
||||
// for this one, which is not a read but a DECISION: answering it from a zeroed mask
|
||||
// says "the server consumes nothing, emit nothing, run the legacy pull path", and
|
||||
// under split there IS no legacy pull path on the client. Every record the caller
|
||||
// would have emitted is simply lost, the emitter clears its dirty flags on the
|
||||
// acceptance it never asked for, and the one R-8 warning that says so is emitted once
|
||||
// per family for the life of the process.
|
||||
//
|
||||
// So: generation 0 is not an answer. This waits, bounded, for a handshake that is
|
||||
// genuinely in flight on ANOTHER thread, and otherwise dies by name -
|
||||
// Fatal{CapsBeforeFirstSnapshot, "<family>"} - naming the family that asked. It does
|
||||
// NOT wait when the calling thread is the one performing the handshake: that is the
|
||||
// shape MobileGL::Initialize used to produce (MG_State::Init() before
|
||||
// MG_Backend::Init()), and waiting for a snapshot this thread has not yet gone to
|
||||
// fetch is how a deadlock is spelled. The ORDER is the fix; this is the gate that
|
||||
// makes a regression of it loud instead of silent.
|
||||
void RequireFirstSnapshot(Uint64 subsystemBit) const;
|
||||
|
||||
MG_Pipe::MGPCaps m_caps{};
|
||||
MG_Backend::FormatCapabilityCache m_formats{};
|
||||
RendererInfo m_renderer{};
|
||||
@@ -121,4 +144,42 @@ namespace MobileGL::MG_Remote::Client {
|
||||
Uint64 LastRefusedSubsystem();
|
||||
void ResetConsumerRefusalsForTest();
|
||||
|
||||
// F1's cases need the ONE state a running process can never get back: a mirror that has
|
||||
// adopted nothing. A fork child inherits its parent's adopted instance, so without this a
|
||||
// case about the placeholder would be a case about whatever the previous case adopted.
|
||||
// Test-only by name, like ResetConsumerRefusalsForTest above it; nothing in the library
|
||||
// calls either.
|
||||
void ResetCapsMirrorForTest();
|
||||
|
||||
// ---- F1 (P7 wave 2) --------------------------------------------------------------------
|
||||
//
|
||||
// THE BOUNDED WAIT'S ONE HONEST SHAPE. ServerConsumes cannot pump a control plane itself -
|
||||
// CapsMirror deliberately knows nothing about ClientSession - so the session installs the
|
||||
// wait and the mirror calls it. The contract is narrow on purpose:
|
||||
//
|
||||
// * it returns FALSE IMMEDIATELY when no session bring-up is in flight, or when the
|
||||
// CALLING thread is the one performing it. Both mean the snapshot cannot arrive while
|
||||
// this call blocks, and a wait there would burn the budget and then die anyway;
|
||||
// * otherwise it waits up to `timeoutMs` for the first Adopt() and reports whether one
|
||||
// landed.
|
||||
//
|
||||
// Installed once, by ClientSession's constructor. A raw function pointer for ID-8's
|
||||
// reason, like SetCapsAdoptedHook beside it.
|
||||
using CapsFirstSnapshotWait = Bool (*)(Uint32 timeoutMs);
|
||||
void SetCapsFirstSnapshotWait(CapsFirstSnapshotWait wait);
|
||||
|
||||
// The generation, readable from a thread that does not own the mirror. m_generation is
|
||||
// GL-thread state by the same argument that makes one gPipeInputs legal; this is the one
|
||||
// fact a WAITING thread has to see, so it is published separately and atomically.
|
||||
Uint64 PublishedCapsGeneration();
|
||||
|
||||
// `kMGPipeSubsystem*` -> the word the Fatal and the R-8 warning print. Names only grow
|
||||
// (G14); an unknown bit prints as a hex literal rather than as a guess.
|
||||
const char* CapsSubsystemName(Uint64 subsystemBit);
|
||||
|
||||
// How long RequireFirstSnapshot gives a handshake that IS in flight. Bounded and small:
|
||||
// an in-process Adopt lands in microseconds and a socket one in single-digit milliseconds,
|
||||
// so anything past this is a peer that is not coming.
|
||||
inline constexpr Uint32 kFirstSnapshotWaitMs = 250;
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Client
|
||||
|
||||
Reference in New Issue
Block a user