Skip to content

Commit 815051b

Browse files
authored
fix(🐛): fix bug where unmounted canvases would be drawn (#2929)
1 parent 2b5eed4 commit 815051b

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Diff for: apps/paper/ios/Podfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ PODS:
16941694
- ReactCommon/turbomodule/bridging
16951695
- ReactCommon/turbomodule/core
16961696
- Yoga
1697-
- RNSVG (15.11.1):
1697+
- RNSVG (15.10.1):
16981698
- React-Core
16991699
- SocketRocket (0.7.0)
17001700
- Yoga (0.0.0)
@@ -1989,9 +1989,9 @@ SPEC CHECKSUMS:
19891989
RNGestureHandler: 939f21fabf5d45a725c0bf175eb819dd25cf2e70
19901990
RNReanimated: 9d20a811e6987cba268ef4f56242dfabd40e85c1
19911991
RNScreens: b03d696c70cc5235ce4587fcc27ae1a93a48f98c
1992-
RNSVG: 669ed128ab9005090c612a0d627dbecb6ab5c76f
1992+
RNSVG: 7ff26379b2d1871b8571e6f9bc9630de6baf9bdf
19931993
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
1994-
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8
1994+
Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae
19951995

19961996
PODFILE CHECKSUM: debc09f5cfcbea21f946ca0be3faa5351e907125
19971997

Diff for: packages/skia/src/sksg/Container.ts

+11
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ const nativeDrawOnscreen = (
5252
export abstract class Container {
5353
public root: Node[] = [];
5454
protected recording: Recording | null = null;
55+
protected unmounted = false;
5556

5657
constructor(protected Skia: Skia, protected nativeId: number) {}
5758

59+
unmount() {
60+
this.unmounted = true;
61+
}
62+
5863
drawOnCanvas(canvas: SkCanvas) {
5964
if (!this.recording) {
6065
throw new Error("No recording to draw");
@@ -101,6 +106,9 @@ class ReanimatedContainer extends Container {
101106
if (this.mapperId !== null) {
102107
Rea.stopMapper(this.mapperId);
103108
}
109+
if (this.unmounted) {
110+
return;
111+
}
104112
const recorder = new Recorder();
105113
visit(recorder, this.root);
106114
const record = recorder.getRecording();
@@ -134,6 +142,9 @@ class NativeReanimatedContainer extends Container {
134142
if (this.mapperId !== null) {
135143
Rea.stopMapper(this.mapperId);
136144
}
145+
if (this.unmounted) {
146+
return;
147+
}
137148
const { nativeId, Skia } = this;
138149
const recorder = new ReanimatedRecorder(Skia);
139150
visit(recorder, this.root);

Diff for: packages/skia/src/sksg/Reconciler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class SkiaSGRoot {
6060
}
6161

6262
unmount() {
63+
this.container.unmount();
6364
skiaReconciler.updateContainer(null, this.root, null, () => {
6465
debug("unmountContainer");
6566
});

0 commit comments

Comments
 (0)