Skip to content

[Enhancement]: WAA SpiderMonkey pointer/rhythm & DOM parity, header/$Fa alignment, and IP-group failover guardrails #371

Backlog

Description

@giryaby-by

想要什么,用来做什么 / What you want and what for

Static decompilation of AI Studio's live production bundles (_b.js, AgQvWc.js, XVDWwe.js, Eyfuqf.js, zLGE0c.js, QwVCeb.js, and live BotGuard interpreter rLuR9_8kHAlkoTJG4oGZgbHi7somZ4vA3i2xQlLwbKk.js) alongside live Chrome 158 CDP wire captures (decompressed 1828, 1957, 2712 Clearcut logs, 384 captured WebIDL VM calls, live GenerateContent, CountTokens, GenerateImage, and Waa/Create traces) on v0.3.17 (5deae85) identified several concrete protocol bugs, telemetry calculation errors, and DOM selector misalignments.

  1. DOM Selectors & Pointer Targets in WAA Runtime (internal/waa/runtime.go)

Incorrect Rerun button selector in spots (internal/waa/runtime.go:164):

runtime.go:164 defines:
javascript
const rerun = turn.querySelector('button');
In live AI Studio DOM and bundles (AgQvWc.js:3128187, Eyfuqf.js), each ms-chat-turn action container contains multiple buttons in the following order:
(Edit button, leftmost)
(Rerun button, +40px horizontally)
Bug impact: turn.querySelector('button') selects the Edit button. When runtime.rerunClick() calculates mouse movement, pointer coordinates, and event targets, events (pointerdown, pointerup, click) are dispatched to the Edit button rather than the Rerun button.
Recommended fix:
javascript
const rerun = turn.querySelector('button.rerun-button, button[name="rerun-button"], button[aria-label*="Rerun" i]') ?? turn.querySelector('button');

DOM layout math & sides offset (runtime.go:153-155 vs page_elements.go:1132):

runtime.go:153 computes section = Math.max(innerWidth - 520, 220) with left = 220 + (section - box) / 2, assuming a fixed 520px combined sidebar margin.
page_elements.go:1132 computes chatSides = 600 (boxWidth := max(220, min(1000, log.width - chatSides))).
Live measurements in Chrome at 1152x720 (DPR 1.25) and 3072x1582 confirm:
Left navigation (ms-navbar): 220px when expanded, 0px when collapsed.
Right panel (ms-run-settings): fixed 300px (left: innerWidth - 300).
Prompt box (ms-prompt-box): left: 220px, width: 632px at 1152px width, centered up to max 1000px.
Aligning chatSides in page_elements.go with section in runtime.go ensures pointer coordinates in WAA match the visual element positions logged in Clearcut 2712.
2. Wire Protocol & Header Parity (internal/aistudio/client.go, benefit.go)

ImageRoute incorrectly strips X-Goog-Ext-519733851-Bin (internal/aistudio/client.go:260-263):

client.go:262 explicitly clears the logging context extension header:
go
if request.ImageRoute {
rpc.Header["X-Goog-Ext-519733851-Bin"] = nil
}
In _b.js:1516096 (zOb / Mib interceptor), the client attaches X-Goog-Ext-519733851-bin to all MakerSuiteService RPCs without exception, checking only if (a.U2.getName().endsWith("/GetLoggingContext")) return b(a);.
Live wire capture:
GenerateContent with models/gemini-2.5-flash-image sends X-Goog-Ext-519733851-bin (status=200).
/prompts/new_image issuing GenerateImage (models/imagen-4.0-generate-001) and GenerateTitle sends X-Goog-Ext-519733851-bin.
Recommended fix: Remove the deletion in client.go:260-263 so ImageRoute preserves X-Goog-Ext-519733851-Bin.

X-AIStudio-G1-Tier method list diverges from live _b.js $Fa (internal/aistudio/benefit.go:25-36):

tieredRPCMethods currently lists 10 RPCs and includes CreateDecision.
In live _b.js ($Fa at line 1395265), Google defines exactly 18 RPCs:
javascript
$Fa = new Set(
"GenerateContent CountTokens ProxyUnaryCall CodeAssistantOffline StreamRunAgentTask " +
"CancelAgentTask SendAgentFollowUpMessage CancelInteraction CreateInteraction " +
"CreateInteractionStream GetInteraction GetInteractionStream GenerateVideo " +
"GetGenerateVideoOperation StreamExtractVideoFrames CreateVoice ListVoices DeleteVoice"
.split(" ")
);
Discrepancies:
CreateDecision (models/gemini-decision-1) is not in $Fa and should not receive X-AIStudio-G1-Tier.
$Fa includes missing methods: StreamRunAgentTask, CancelAgentTask, SendAgentFollowUpMessage, GetInteraction, GenerateVideo, GetGenerateVideoOperation, CreateVoice, ListVoices, DeleteVoice.
3. Clearcut Telemetry & Web Vitals Parity (internal/aistudio/)

Immediate Streamz 1828 flush on snapshot creation (_b.js Fxb.prototype.snapshot, runtime_go.go:1641):

In _b.js:937965:
javascript
snapshot(a) {
this.logger.J("n");
var b = this.logger.share();
return this.J.then(({oDd: c}) => new Promise(d => {
var e = new sxb(b, "n");
c(f => {
e.done();
b.ha(f.length);
b.R(); // <-- Immediate flush of /client_streamz/bg/{frs,el,ec}!
b.dispose();
d(f);
}, [a.AId, a.fif, a.jj]);
}));
}
In live Chrome, Clearcut 1828 containing /client_streamz/bg/frs (e.g. 1660 bytes) and /client_streamz/bg/el (n duration) fires immediately upon proof creation, right before or concurrently with GenerateContent.
runtime_go.go:1641 already calls go runtime.flushVMStreamz(context.Background(), vm). Ensure TakeMetrics drain does not drop frs / el pairs when multiple proofs are generated in rapid succession.

Web Vitals 1957 metrics and TTFB attribution math (internal/aistudio/page_vitals.go:88-96):

Live decoded 1957 Clearcut logs from Chrome reveal concrete schema discrepancies:
Metric array (payload[8], IWb):
Live: [CLS, FCP, null, LCP, TTFB, 0] (e.g. [0.00136, 956, null, 1640, 480, 0]).
page_vitals.go:88: []any{nil, paint, nil, paint, firstByte}. CLS is omitted (nil), and LCP is hardcoded to equal FCP (paint).
TTFB Attribution (payload[13][4], zWb, _b.js eYb / iYb:1740403):
In _b.js:1740403:
javascript
[TTFB, fetchStart, domainLookupStart - fetchStart, connectEnd - connectStart, responseStart - connectEnd]
(e.g. live values: [480, 10, 3, 333, 133]).
In page_vitals.go:95:
go
[]any{firstByte, lookup, connect - lookup, connected - connect, firstByte - connected}
page_vitals.go starts with lookup (domainLookupStart) instead of fetchStart, and passes connect - lookup instead of DNS duration (domainLookupStart - fetchStart), distorting network timing attribution in upstream's Clearcut logs.
LCP selector attribution (payload[13][3]):
When signed-in without starter cards, live Chrome reports LCP on: ms-model-selector>button.model-selector-card.ng-star-inserted>span.ng-star-inserted.subtitle (LCP 1640ms vs FCP 956ms).
page_vitals.go:94 hardcodes paint (FCP) into LCP attribution.

Navigation timing zero-duration bounds (internal/aistudio/navigation_timing.go:56-57):

navigation_timing.go:56-57 hardcodes:
go
secureConnectionStart == connectEnd // 0ms TLS negotiation
responseStart == responseEnd // 0ms response download
Live navigation entries in Chrome record ~30–60ms TLS handshake (connectEnd - secureConnectionStart) and ~20–60ms response body download (responseEnd - responseStart).

VE ID clarification & non-applicable elements (internal/aistudio/page_elements.go:51, 81):

365043 vs 365044: Bundle analysis (XVDWwe.js:1416579 and 1413502) proves 365043 is "Claim free API credits" (id: "claim" from Google Developer Program), whereas 365044 is "upgrade" (id: "upgrade"). Tier 1 / Pro accounts show 365043, while un-enrolled accounts show 365044.
329280: Defined as Lsd in zLGE0c.js:1290342 for "Thinking summaries" toggle (this.lma = () => { var a = this.baseModel(); return !!a && _.gl(a) }). Emitting it in pageMainElements on models without thinking summaries adds an unused VE.
Waa/Ping confirmation: Confirmed across all 43 JS bundles and live CDP wire captures that XBa.prototype.ping has 0 callers and transmits 0 requests (Zxb.g$d = 432E5 = 12h). AIStudio2API is correct in omitting Waa/Ping.
4. BotGuard VM Probes & Sandbox Consistency (internal/waa/dom.js)

Live Chrome hooks captured 384 WebIDL API calls during BotGuard VM initialization and snapshot generation (rLuR9_8kHAlkoTJG4oGZgbHi7somZ4vA3i2xQlLwbKk.js):

performance.now() (274 calls), requestAnimationFrame (61 calls), getBoundingClientRect (9 calls), document.createElement('iframe') (7 calls to /app/_/bscframe), matchMedia('(any-pointer:fine)'), navigator.hardwareConcurrency, navigator.deviceMemory, navigator.connection, navigator.userActivation, navigator.maxTouchPoints (returns 0), navigator.platform ('Win32'), outerWidth/Height, innerWidth/Height, and performance.getEntriesByType('navigation').
Sandbox inconsistencies in dom.js:
Performance.getEntriesByType() (dom.js:1688-1689): returns [] for 'resource' and 'paint', while page_vitals.go (1957) reports non-zero resource counts.
HTMLCanvasElement.getContext() (dom.js:1691): returns null for 'webgl' and 'webgl2', which contrasts with genuine Firefox desktop profiles.
Overlay & toast dismissal parity (internal/camoufoxnative/page.go:184, 321, internal/aistudio/):
Model-switched warning toast (ms-toast.v4-toast): Navigating to a deprecated model (e.g. ?model=gemini-2.5-flash) redirects to the replacement (gemini-4-hydrogen) and renders a 20-second mat-snack-bar-container (ms-toast.v4-toast > div.toast > div.v4-toast-surface.v4-toast-warning) with button.v4-toast-dismiss[aria-label="Dismiss"]. camoufoxnative/page.go:184 reads mat-snack-bar-container for error reporting, but dismissKnownOverlays (page.go:318) does not dismiss non-error warning toasts (button.v4-toast-dismiss).
XAP Guided Tour (xap-tour, xap-tour-expire): camoufoxnative/page.go:321 clicks button.xap-tour-exit-button, whereas internal/aistudio/ does not seed xap-tour / xap-tour-expire in runtime.storage.
5. IP-Group Failover & Scheduler Guardrails (internal/aistudio/accounts.go, generate.go)

Proxy/IP-group isolation on 403 verify-account (accounts.go:3219, internal/egress/egress.go):

When an account hits 403 Forbidden (ErrAccountVerification), MarkRestricted isolates that specific account.
However, if multiple accounts share the same proxy or egress IP, the scheduler immediately leases another account from the same pool for the retry, leading to rapid cascading bans across accounts on the same IP.
Adding a temporary cooldown or circuit breaker per egress IP group on verification errors prevents burning secondary accounts.

Generation retry bound (internal/aistudio/generate.go:23):

const regenerations = 3 permits up to 4 total attempts per generation request upon streaming or parse errors. Lowering or making this configurable prevents burst rate-limit exhaustion during upstream transient degradations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions