Skip to content

Commit

Permalink
fix(🐛): fix bug where unmounted canvases would be drawn (#2929)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Jan 29, 2025
1 parent 2b5eed4 commit 815051b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/paper/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNSVG (15.11.1):
- RNSVG (15.10.1):
- React-Core
- SocketRocket (0.7.0)
- Yoga (0.0.0)
Expand Down Expand Up @@ -1989,9 +1989,9 @@ SPEC CHECKSUMS:
RNGestureHandler: 939f21fabf5d45a725c0bf175eb819dd25cf2e70
RNReanimated: 9d20a811e6987cba268ef4f56242dfabd40e85c1
RNScreens: b03d696c70cc5235ce4587fcc27ae1a93a48f98c
RNSVG: 669ed128ab9005090c612a0d627dbecb6ab5c76f
RNSVG: 7ff26379b2d1871b8571e6f9bc9630de6baf9bdf
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8
Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae

PODFILE CHECKSUM: debc09f5cfcbea21f946ca0be3faa5351e907125

Expand Down
11 changes: 11 additions & 0 deletions packages/skia/src/sksg/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ const nativeDrawOnscreen = (
export abstract class Container {
public root: Node[] = [];
protected recording: Recording | null = null;
protected unmounted = false;

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

unmount() {
this.unmounted = true;
}

drawOnCanvas(canvas: SkCanvas) {
if (!this.recording) {
throw new Error("No recording to draw");
Expand Down Expand Up @@ -101,6 +106,9 @@ class ReanimatedContainer extends Container {
if (this.mapperId !== null) {
Rea.stopMapper(this.mapperId);
}
if (this.unmounted) {
return;
}
const recorder = new Recorder();
visit(recorder, this.root);
const record = recorder.getRecording();
Expand Down Expand Up @@ -134,6 +142,9 @@ class NativeReanimatedContainer extends Container {
if (this.mapperId !== null) {
Rea.stopMapper(this.mapperId);
}
if (this.unmounted) {
return;
}
const { nativeId, Skia } = this;
const recorder = new ReanimatedRecorder(Skia);
visit(recorder, this.root);
Expand Down
1 change: 1 addition & 0 deletions packages/skia/src/sksg/Reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class SkiaSGRoot {
}

unmount() {
this.container.unmount();
skiaReconciler.updateContainer(null, this.root, null, () => {
debug("unmountContainer");
});
Expand Down

0 comments on commit 815051b

Please sign in to comment.