Skip to content

Commit ad6e7d0

Browse files
authored
fix(💚): Fix iOS segfault error for surfaces with 0 size (#2753)
1 parent f298622 commit ad6e7d0

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

‎apps/paper/src/Examples/Breathe/Breathe.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from "react";
2-
import { StyleSheet, useWindowDimensions } from "react-native";
2+
import { StyleSheet, useWindowDimensions, View } from "react-native";
33
import {
44
BlurMask,
55
vec,
@@ -67,15 +67,17 @@ export const Breathe = () => {
6767
);
6868

6969
return (
70-
<Canvas style={styles.container}>
71-
<Fill color="rgb(36,43,56)" />
72-
<Group origin={center} transform={transform} blendMode="screen">
73-
<BlurMask style="solid" blur={40} />
74-
{new Array(6).fill(0).map((_, index) => {
75-
return <Ring key={index} index={index} progress={progress} />;
76-
})}
77-
</Group>
78-
</Canvas>
70+
<View style={{ flex: 1 }}>
71+
<Canvas style={styles.container}>
72+
<Fill color="rgb(36,43,56)" />
73+
<Group origin={center} transform={transform} blendMode="screen">
74+
<BlurMask style="solid" blur={40} />
75+
{new Array(6).fill(0).map((_, index) => {
76+
return <Ring key={index} index={index} progress={progress} />;
77+
})}
78+
</Group>
79+
</Canvas>
80+
</View>
7981
);
8082
};
8183

‎packages/skia/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
// usage growing very fast in the simulator without this.
7878
@autoreleasepool {
7979
auto surface = _ctx->getSurface();
80+
if (!surface) {
81+
return false;
82+
}
8083
auto canvas = surface->getCanvas();
8184
cb(canvas);
8285
_ctx->present();

0 commit comments

Comments
 (0)