Skip to content

Commit eb0e94f

Browse files
XChikuXwcandillon
andauthored
fix(🤖): fix android snapshot view with SVG content (#3612)
--------- Co-authored-by: William Candillon <[email protected]>
1 parent 32585ed commit eb0e94f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎packages/skia/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ private static Paint createPaint() {
6767
return paint;
6868
}
6969

70+
private static boolean isSvgView(View view) {
71+
try {
72+
String className = view.getClass().getName();
73+
return className != null && className.startsWith("com.horcrux.svg");
74+
} catch (Throwable t) {
75+
Log.e("ViewScreenshotService", "Error checking if view is SVG", t);
76+
return false;
77+
}
78+
}
79+
7080
private static void renderViewToCanvas(Canvas canvas, View view, Paint paint, float parentOpacity) {
7181
float combinedOpacity = parentOpacity * view.getAlpha();
7282
canvas.save();
@@ -83,7 +93,7 @@ private static void renderViewToCanvas(Canvas canvas, View view, Paint paint, fl
8393
canvas.clipRect(clipLeft, clipTop, clipRight, clipBottom);
8494
}
8595

86-
if (view instanceof ViewGroup) {
96+
if (view instanceof ViewGroup && !isSvgView(view)) {
8797
ViewGroup group = (ViewGroup) view;
8898
drawBackgroundIfPresent(canvas, view, combinedOpacity);
8999
drawChildren(canvas, group, paint, combinedOpacity);

0 commit comments

Comments
 (0)