Skip to content

Commit

Permalink
Merge pull request #2124 from Shopify/fix-memory-leak2
Browse files Browse the repository at this point in the history
Fix regression
  • Loading branch information
wcandillon authored Jan 7, 2024
2 parents 8f80968 + 3865a34 commit e5c324a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package/src/renderer/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
root.render(children);
}, [children, root, redraw]);

useEffect(() => {
return () => {
root.unmount();
};
}, [root]);

if (NATIVE_DOM) {
return (
<SkiaDomView
Expand Down
2 changes: 1 addition & 1 deletion package/src/renderer/HostConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const skHostConfig: SkiaHostConfig = {
noTimeout: -1,

appendChildToContainer(container, child) {
debug("appendChildToContainer", container, child);
debug("appendChildToContainer");
appendNode(container.root, child);
},

Expand Down
4 changes: 4 additions & 0 deletions package/src/renderer/Reconciler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class SkiaRoot {
});
}

unmount() {
skiaReconciler.updateContainer(null, this.root, null, () => {});
}

get dom() {
return this.container.root;
}
Expand Down

0 comments on commit e5c324a

Please sign in to comment.