Skip to content

Commit

Permalink
[Animations] Release all the animations before taking a heap snapshot
Browse files Browse the repository at this point in the history
The animations are stored for replay in the animations panel and they might cause
detached nodes to appear in snapshots. Because of this, we release
all the animations first before taking a heap snapshot.

Fixed: 395798202
Change-Id: Ie75a5c4eadc9f9dd0553c6ad07ad76b0faff8a4f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6286492
Auto-Submit: Ergün Erdoğmuş <[email protected]>
Commit-Queue: Alex Rudenko <[email protected]>
Reviewed-by: Alex Rudenko <[email protected]>
  • Loading branch information
ergunsh authored and Devtools-frontend LUCI CQ committed Feb 21, 2025
1 parent 006f4f5 commit 81a0851
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions front_end/core/sdk/AnimationModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ export class AnimationModel extends SDKModel<EventTypes> {
void this.agent.invoke_setPlaybackRate({playbackRate});
}

async releaseAllAnimations(): Promise<void> {
const animationIds = [...this.animationGroups.values()].flatMap(
animationGroup => animationGroup.animations().map(animation => animation.id()));
await this.agent.invoke_releaseAnimations({animations: animationIds});
}

releaseAnimations(animations: string[]): void {
void this.agent.invoke_releaseAnimations({animations});
}
Expand Down
9 changes: 9 additions & 0 deletions front_end/panels/profiler/HeapSnapshotView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,15 @@ export class HeapSnapshotProfileType extends
this.addProfile(profile);
profile.updateStatus(i18nString(UIStrings.snapshotting));

// Release all the animations before taking a heap snapshot.
// The animations are stored for replay in the animations panel and they might cause
// detached nodes to appear in snapshots. Because of this, we release
// all the animations first before taking a heap snapshot.
const animationModel = heapProfilerModel.target().model(SDK.AnimationModel.AnimationModel);
if (animationModel) {
await animationModel.releaseAllAnimations();
}

await heapProfilerModel.takeHeapSnapshot({
reportProgress: true,
captureNumericValue: true,
Expand Down

0 comments on commit 81a0851

Please sign in to comment.