Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/css-animation-gc-witness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CSS animation GC reference witness (diagnostic)

on:
pull_request:
branches: [codex/snapshot-source-css-animations]
workflow_dispatch:

permissions:
contents: read

jobs:
linux-firefox-witness:
if: github.event_name == 'workflow_dispatch' || (github.head_ref == 'codex/css-animation-gc-reference-witness' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
timeout-minutes: 20
env:
WITNESS_BASE_SHA: ${{ github.event.pull_request.base.sha }}
WITNESS_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.witness-browsers-onehost
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24.22.3
cache: pnpm
- name: Install frozen dependencies
run: |
pnpm install --frozen-lockfile --ignore-scripts
node -e "if (require('playwright/package.json').version !== '1.64.1') process.exit(1)"
- name: Check source and test lint
run: pnpm run lint:check
- name: Build
run: pnpm run build
- name: Check published entries
run: pnpm run test:package
- name: Check browser test types
run: pnpm run test:browser:types
- name: Install locked browser engines
run: pnpm exec playwright install --with-deps
- name: Record exact input identity
run: |
mkdir -p .vitest/css-animation-gc-onehost
node scripts/record-css-animation-gc-witness-inputs.mjs
cp .vitest/attachments/css-animation-gc-witness/input-identity.json .vitest/css-animation-gc-onehost/input-identity-before.json
- name: Run fixed four-case sequence on this runner image
id: sequence
run: python3 scripts/run-css-animation-gc-onehost.py
- name: Always restore original Firefox bytes after the sequence
if: always() && steps.sequence.outcome != 'skipped'
run: python3 scripts/css-animation-gc-witness/firefox-gc-reference-probe.py restore --output .vitest/css-animation-gc-onehost/final-restore
- name: Always verify production source after the sequence
if: always() && steps.sequence.outcome != 'skipped'
run: |
node scripts/record-css-animation-gc-witness-inputs.mjs
cp .vitest/attachments/css-animation-gc-witness/input-identity.json .vitest/css-animation-gc-onehost/input-identity-after.json
cmp .vitest/css-animation-gc-onehost/input-identity-before.json .vitest/css-animation-gc-onehost/input-identity-after.json
git diff HEAD --exit-code -- src
- name: Upload primary verdict, original log and postfailure evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: css-animation-gc-reference-onehost
path: |
.vitest/css-animation-gc-onehost/
.vitest/attachments/
if-no-files-found: warn
56 changes: 56 additions & 0 deletions scripts/css-animation-gc-witness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
This is a failure-observation workflow, not a GC repair or a standard CI result.

The three `firefox-gc-reference-*` files are byte-identical copies from
`docs/evidence/document-property-lifetime/dom-access-raw.tar.gz`:

- installer: `e624edfdd10bb3447e823447460cd9ed5676d867f625187cfc2b689bca9775d6`
- content method: `349b6d83cb332e7f4551b84f0a1ef43792355e19ba0aeeaf5e0d15bfa8d9e230`
- parent method: `09822e64784966122833a63037986f9470222643d8b1f19bd67cdfcbf07c4677`

Installation requires Linux, exact original `omni.ja` SHA256
`f975f204199e40fcb5a7545b44b90ca4e365c1344825c0a2248d1556b35951a3`,
and all three original Juggler source hashes. A matching Playwright version or
Firefox revision alone is insufficient. The workflow uses its own engine cache,
the original `ubuntu-latest` runner label, and Node 24.22.3; actual runner image,
OS, merge parents, source-tree identity, and source bytes are recorded.

`pnpm test` runs exactly once per fixed case. The single job uses one runner
image for unpatched/hook0, patched/hook0, unpatched/hook1, patched/hook1,
in that order. All earlier results remain historical observations; runner
image differences and the remaining time/order effects preclude a unique
causal conclusion from this sequence. Existing expectations, three primary GC calls,
skips and test deadlines are unchanged. With the workflow flag enabled, both
Firefox test cases record their cached primary verdict. Only a false verdict
registers existing WeakRef wrappers and requests heap inspection. No source
target is marked, dereferenced again or deliberately held by this observer.

The observer is installed before testing (including Juggler changes/startup
logging), so it may prevent a failure from reproducing. Only heap inspection
is deferred until the cached failure.

The 2s browser budget includes transport; the Node command uses its remaining
deadline, reserving time for an incomplete receipt. A timeout is not native
cancellation. The original privileged method can continue its snapshot or
10s GC/CC-log request after the caller stops waiting. Late remote handles are
disposed on settlement; the browser helper deletes its registry in `finally`
and attempts to report its deletion result with `console.warn`. Vitest may
omit that detail from the captured log. Without an actual retained log or
receipt, deletion status is unknown; source-level `finally` and offline
controls are not a runtime acknowledgement. Native
DevTools prior boolean state restoration is reported only from returned
open/close receipts; this is not proof about native registration counts.
Pending operations, missing raw files, or a snapshot with no unique target
remain **no witness**; process termination is an additional final boundary,
not proof that an in-flight operation was cancelled. Synchronous native work
and JSON serialization cannot be preempted by JavaScript timers.

Snapshots, Debugger wrappers/DevTools registration and subsequent diagnostic
GC/CC can alter the graph. Paths may contain inspector roots. A later missing
target or changed reachability cannot overturn the cached primary failure.
Raw snapshots/logs are copied only when acknowledged within the budget.

The workflow restores the exact original archive in an `always()` step and
uploads the restoration receipt alongside the original test exit code/log.
If a worker is forcibly lost, neither that step nor an in-process `finally`
can promise completion; this is why the cache is job-owned. Standard `ci.yml`
and all production sources are unchanged.
49 changes: 49 additions & 0 deletions scripts/css-animation-gc-witness/firefox-gc-reference-method.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
async _codexHeapPaths(root) {
dump("codex heap begin\n");
const ids = {}, rawHolds = {};
for (const key of ['reference']) {
const object = root.getOwnPropertyDescriptor(key)?.value;
if (object instanceof Debugger.Object)
ids[key] = ChromeUtils.getObjectNodeId(rawHolds[key] = object.unsafeDereference());
}
dump("codex heap ids "+JSON.stringify(ids)+"\n");
const opened = Services.cpmm.sendSyncMessage('codex-heap-state', {action:'open'});
let file, closed;
try { file = ChromeUtils.saveHeapSnapshot({runtime: true}); }
finally { closed = Services.cpmm.sendSyncMessage('codex-heap-state', {action:'close'}); }
const beforeIDs = {...ids};
for (const key of Object.keys(rawHolds)) ids[key] = ChromeUtils.getObjectNodeId(rawHolds[key]);
dump("codex heap file "+file+"\n");
let contentRead;
if (root.getOwnPropertyDescriptor('checkContentRead')?.value === true) {
try { ChromeUtils.readHeapSnapshot(file); contentRead = {succeeded:true}; }
catch (error) { contentRead = {succeeded:false,name:error.name,message:error.message,result:error.result,stack:error.stack}; }
}
// The snapshot is a parent-created file. Analyze its saved bytes in the
// parent, without changing content sandbox policy or sending app objects.
const results = Services.cpmm.sendSyncMessage('codex-heap-analyze', {file,ids});
const graph = results[0] || {ids,errors:[{phase:'parent-analysis',message:'No parent response'}]};
if (!graph.ids.target) return {...graph,beforeIDs,opened,closed,contentRead,
limits:{introducedTargetHold:false,introducedWeakRefWrapperHold:true,weakTargetMayHaveCollectedAfterPrimary:true}};
const request = Services.appinfo.processID+'-'+Date.now()+'-'+ids.reference;
const cc = await new Promise(resolve => {
const {setTimeout,clearTimeout} = ChromeUtils.importESModule('resource://gre/modules/Timer.sys.mjs');
const timer = setTimeout(() => {
Services.cpmm.removeMessageListener('codex-gc-done', listener);
resolve({error:'Parent GC/CC log request timed out',request});
},10000);
const listener = ({data}) => {
if (data.request !== request) return;
clearTimeout(timer);
Services.cpmm.removeMessageListener('codex-gc-done', listener);
resolve({...data,wantAllTraces:false,phase:'after-primary-and-heap',extraCollectionForDiagnosisOnly:true,
method:'parent nsIMemoryInfoDumper with native child file-descriptor sink'});
};
Services.cpmm.addMessageListener('codex-gc-done', listener);
Services.cpmm.sendAsyncMessage('codex-gc-start', {request,pid:Services.appinfo.processID});
});
return {...graph,version:9,cc,file,ids:graph.ids,beforeIDs,opened,closed,contentRead,
limits:{maxPathsPerStart:20,runtimeSnapshot:true,introducedTargetHold:false,
introducedAllRootWrapperHolds:false,introducedWeakRefWrapperHold:true,introducedApplicationObjectHolds:false,
snapshotIsAfterPrimaryOnly:true,rootPathsIncludeInspectorReferences:true,analysisProcess:'parent'}};
}
54 changes: 54 additions & 0 deletions scripts/css-animation-gc-witness/firefox-gc-reference-parent.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
function codexAnalyzeReferenceHeap(file, ids) {
try {
const snapshot = ChromeUtils.readHeapSnapshot(file);

const tree = snapshot.computeDominatorTree();

const census = snapshot.takeCensus({breakdown:{by:'coarseType',objects:{by:'objectClass',then:{by:'bucket'}},other:{by:'count'},strings:{by:'count'},scripts:{by:'count'},symbols:{by:'count'},bigInts:{by:'count'}}});
const documentBuckets = Object.fromEntries(Object.entries(census.objects).filter(([name]) => /Document/.test(name)));
const documents = Object.values(documentBuckets).flat();
const targetCandidates = [...snapshot.computeShortestPaths(ids.reference, documents, 20)];
const direct = targetCandidates.filter(([id, paths]) => paths.some(path => path.length === 2 && path[0].edge === 'proxy target' && path[1].edge === 'WeakRefObject::target'));
if (direct.length !== 1) return {version:9,file,ids,errors:[],targetState:'no unique direct WeakRef target in snapshot',observedDirectTargets:direct.length,documentBuckets,targetCandidates,limits:{introducedTargetHold:false,weakTargetMayHaveCollectedAfterPrimary:true}};
const referenceWrapperID = ids.reference;
ids.target = direct[0][0];
const paths = {}, errors = [];
for (const [name, start] of Object.entries({...ids, gcRoot: tree.root})) {
if (name === 'target' || name === 'reference') continue;
try {
paths[name] = [...snapshot.computeShortestPaths(start, [ids.target], 20)];
} catch (error) { errors.push({name, error: String(error)}); }
}
return {version:9,file,ids,referenceWrapperID,documentBuckets,targetCandidates,root:tree.root,paths,errors};
} catch (error) {
return {version:9,file,ids,errors:[{phase:'parent-analysis',name:error.name,message:error.message,result:error.result,stack:error.stack}]};
}
}
Services.ppmm.addMessageListener('codex-heap-analyze', ({data}) => codexAnalyzeReferenceHeap(data.file, data.ids));

// Use Firefox's native parent-opened file-descriptor sinks for child logs.
// Content sandbox policy is unchanged; direct child file access is unnecessary.
Services.ppmm.addMessageListener('codex-gc-start', message => {
const {request,pid} = message.data;
const logs = [], errors = [];
const reply = () => {
const selected = logs.filter(log => !log.isParent && log.gcFile?.split('/').pop().startsWith('gc-edges.'+pid+'.'));
message.target.sendAsyncMessage('codex-gc-done', {request,pid,logs,errors,
...(selected.length===1 ? selected[0] : {error:'No unique native child log pair',matches:selected.length})});
};
const callback = {
QueryInterface: ChromeUtils.generateQI(['nsIDumpGCAndCCLogsCallback']),
onDump(gcLog,ccLog,isParent) {
try { logs.push({gcFile:gcLog?.path,file:ccLog?.path,isParent}); }
catch (error) { errors.push({name:error.name,message:error.message,result:error.result}); }
},
onFinish() { reply(); },
};
try {
Components.classes['@mozilla.org/memory-info-dumper;1'].getService(Components.interfaces.nsIMemoryInfoDumper)
.dumpGCAndCCLogsToFile('codex-after-primary-'+request,false,true,callback);
} catch (error) {
errors.push({name:error.name,message:error.message,result:error.result});
reply();
}
});
Loading
Loading