Bug 314996

Summary: Avoid lazy-allocating UndoManager during Document teardown
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: DOMAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

David Kilzer (:ddkilzer)
Reported 2026-05-17 20:26:27 PDT
`Document::willBeRemovedFromFrame()` calls `protect(undoManager())->removeAllItems()` unconditionally. `Document::undoManager()` lazy-creates the `UndoManager` through `ensureUndoManager()` when `m_undoManager` is null. For clients that do not create `m_undoManager`, every detached `Document` lazy-allocates a 32-byte `UndoManager`, calls a no-op `removeAllItems()` on its empty `HashSet`, and then destroys it in `~Document`. This is wasted work that scales with every detached `Document`.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-05-17 20:26:36 PDT
David Kilzer (:ddkilzer)
Comment 2 2026-05-17 20:42:52 PDT
EWS
Comment 3 2026-05-17 22:25:49 PDT
Committed 313393@main (408429b44b24): <https://commits.webkit.org/313393@main> Reviewed commits have been landed. Closing PR #65083 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.