Skip to content

Commit ce12be5

Browse files
committed
fix(page): explain requestGC's hit-target workaround via Blink's node_under_mouse_
Blink's EventHandler caches the last hit-tested node for hover/mouseout tracking and only refreshes it on the next pointer event, so a detached element stays pinned by that native reference until a synthetic mouse move forces a fresh hit-test. Verified by removing the workaround (test fails ~70% of repeats), doubling collectGarbage (still fails), and dispatching an unrelated CDP command instead of a mouse move (still fails) -- only a new pointer event releases the reference, at any coordinate.
1 parent 4c98845 commit ce12be5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • packages/playwright-core/src/server/chromium

‎packages/playwright-core/src/server/chromium/crPage.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class CRPage implements PageDelegate {
221221
}
222222

223223
async requestGC(): Promise<void> {
224-
// A no-op mouse move off-viewport clears Blink's native hit-target state, which retains the last-targeted element as a GC root invisible to V8.
224+
// Blink's EventHandler caches the last hit-tested node (node_under_mouse_) for hover/mouseout tracking and only refreshes it on the next pointer event, so a removed element stays pinned by that native reference, invisible to collectGarbage, until we force a fresh hit-test.
225225
await this._mainFrameSession._client.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: -1, y: -1 });
226226
await this._mainFrameSession._client.send('HeapProfiler.collectGarbage');
227227
}

0 commit comments

Comments
 (0)