Skip to content

Commit 3865a34

Browse files
committed
fix memory leak
1 parent 8f80968 commit 3865a34

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

package/src/renderer/Canvas.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
8484
root.render(children);
8585
}, [children, root, redraw]);
8686

87+
useEffect(() => {
88+
return () => {
89+
root.unmount();
90+
};
91+
}, [root]);
92+
8793
if (NATIVE_DOM) {
8894
return (
8995
<SkiaDomView

package/src/renderer/HostConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const skHostConfig: SkiaHostConfig = {
8282
noTimeout: -1,
8383

8484
appendChildToContainer(container, child) {
85-
debug("appendChildToContainer", container, child);
85+
debug("appendChildToContainer");
8686
appendNode(container.root, child);
8787
},
8888

package/src/renderer/Reconciler.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export class SkiaRoot {
4444
});
4545
}
4646

47+
unmount() {
48+
skiaReconciler.updateContainer(null, this.root, null, () => {});
49+
}
50+
4751
get dom() {
4852
return this.container.root;
4953
}

0 commit comments

Comments
 (0)