Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] getCurrentColor crash DepsView + Use, java.lang.ClassCastException: com.horcrux.svg.DefsView cannot be cast to com.horcrux.svg.RenderableView #2520

Closed
mym0404 opened this issue Oct 30, 2024 · 2 comments · Fixed by #2521

Comments

@mym0404
Copy link

mym0404 commented Oct 30, 2024

Description

#2466 introduces new getCurrentColor implementation that causes weird crash in Android.

Crash log indicates getCurrentColor of RenderableView doesn't handle case parent is DefsView.

I can't guess how to fix this and tried changing condition if (parent instanceof VirtualView) { to if (parent instanceof VirtualView && !(parent instanceof DefsView)) { but no luck.

FATAL EXCEPTION: main
java.lang.ClassCastException: com.horcrux.svg.DefsView cannot be cast to com.horcrux.svg.RenderableView
	at com.horcrux.svg.RenderableView.getCurrentColor(RenderableView.java:142)
	at com.horcrux.svg.RenderableView.setupPaint(RenderableView.java:652)
	at com.horcrux.svg.RenderableView.setupFillPaint(RenderableView.java:582)
	at com.horcrux.svg.RenderableView.draw(RenderableView.java:520)
	at com.horcrux.svg.UseView.draw(UseView.java:86)
	at com.horcrux.svg.RenderableView.render(RenderableView.java:486)
	at com.horcrux.svg.GroupView.drawGroup(GroupView.java:135)
	at com.horcrux.svg.GroupView.draw(GroupView.java:91)
	at com.horcrux.svg.RenderableView.render(RenderableView.java:486)
	at com.horcrux.svg.GroupView.drawGroup(GroupView.java:135)
	at com.horcrux.svg.GroupView.draw(GroupView.java:91)
	at com.horcrux.svg.RenderableView.render(RenderableView.java:486)
	at com.horcrux.svg.GroupView.drawGroup(GroupView.java:135)
	at com.horcrux.svg.GroupView.draw(GroupView.java:91)
	at com.horcrux.svg.RenderableView.render(RenderableView.java:486)
	at com.horcrux.svg.SvgView.drawChildren(SvgView.java:335)
	at com.horcrux.svg.SvgView.drawOutput(SvgView.java:281)
	at com.horcrux.svg.SvgView.onDraw(SvgView.java:134)
	at android.view.View.draw(View.java:23889)
	at com.facebook.react.views.view.ReactViewGroup.draw(ReactViewGroup.java:970)
	at android.view.View.updateDisplayListIfDirty(View.java:22756)
	at android.view.View.draw(View.java:23620)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4556)
	at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:1029)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)
	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:980)
	at android.view.View.draw(View.java:23892)
	at com.facebook.react.views.view.ReactViewGroup.draw(ReactViewGroup.java:970)
	at android.view.View.updateDisplayListIfDirty(View.java:22756)
	at android.view.View.draw(View.java:23620)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4556)
	at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:1029)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)
	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:980)
	at android.view.View.updateDisplayListIfDirty(View.java:22747)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
	at android.view.View.updateDisplayListIfDirty(View.java:22712)
	at android.view.View.draw(View.java:23620)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4556)
	at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:1029)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)
	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:980)
	at com.shopify.reactnative.flash_list.AutoLayoutView.dispatchDraw(AutoLayoutView.kt:34)
	at android.view.View.updateDisplayListIfDirty(View.java:22747)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
	at android.view.View.updateDisplayListIfDirty(View.java:22712)
	at android.view.View.draw(View.java:23620)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4556)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)
	at android.view.View.draw(View.java:23892)
	at android.widget.ScrollView.draw(ScrollView.java:1971)
	at com.facebook.react.views.scroll.ReactScrollView.draw(ReactScrollView.java:670)
	at android.view.View.updateDisplayListIfDirty(View.java:22756)
	at android.view.View.draw(View.java:23620)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4556)
	at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:1029)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)

Steps to reproduce

svg

<svg style="vertical-align:-.72px" xmlns="http://www.w3.org/2000/svg" width="93.992px" height="17.8px" viewBox="0 -943.3 5192.9 983.3" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><path id="a" d="M33 157q0 101 76 192t171 92q51 0 90-49 16 30 46 30 13 0 23-8t10-20q0-13-37-160T374 68q0-25 7-33t21-9q9 1 20 9 21 20 41 96 6 20 10 21 2 1 10 1h4q19 0 19-9 0-6-5-27t-20-54-32-50Q436 0 417-8q-8-2-24-2-34 0-57 15t-30 31l-6 15q-1 1-4-1l-4-4q-59-56-120-56-55 0-97 40T33 157m318 171q0 6-5 22t-23 35-46 20q-35 0-67-31t-50-81q-29-79-41-164v-11q0-8-1-12 0-45 18-62t43-18q38 0 75 33t44 51q2 4 27 107t26 111"/><path id="b" d="M118-162q2 0 6-2t11-3 12-1q13 0 24 13t16 29q10 27 34 153t46 240 22 115v3h-47q-47 0-50 2-4 3-4 10l7 28q2 5 8 5t47 1q48 0 48 1 0 2 9 50t12 58q37 165 146 165 37-2 61-22t24-53q0-36-21-52t-42-17q-44 0-44 42 0 19 11 33t24 21l9 5q-16 6-30 6-12 0-23-10t-15-28q-7-29-16-78t-16-83-7-36 55-2q45 0 52-1t11-6q1-4-2-17t-5-16q-2-5-9-5t-54-1h-56l-23-122Q301 15 282-47q-27-85-70-126-37-32-73-32-32 0-58 19t-26 54q0 37 21 54t42 17q44 0 44-42 0-19-11-33t-24-21z"/><path id="c" d="M94 250q0 69 10 131t23 107 37 88 38 67 42 52 33 34 25 21h17q14 0 14-9 0-3-17-21t-41-53-49-86-42-138-17-193 17-192 41-139 49-86 42-53 17-21q0-9-15-9h-16l-28 24q-94 85-137 212T94 250"/><path id="d" d="M52 289q7 42 54 97t116 56q35 0 64-18t43-45q42 63 101 63 37 0 64-22t28-59q0-29-14-47t-27-22-23-4q-19 0-31 11t-12 29q0 46 50 63-11 13-40 13-13 0-19-2-38-16-56-66-60-221-60-258 0-28 16-40t35-12q37 0 73 33t49 81q3 10 6 11t16 2h4q15 0 15-8 0-1-2-11-16-57-62-101T333-11q-70 0-106 63-41-62-94-62h-6q-49 0-70 26T35 71q0 32 19 52t45 20q43 0 43-42 0-20-12-35t-23-20-13-5l-3-1q0-1 6-4t16-7 19-3q36 0 62 45 9 16 23 68t28 108 16 66q5 27 5 39 0 28-15 40t-34 12q-40 0-75-32t-49-82q-2-9-5-10t-16-2H58q-6 6-6 11"/><path id="e" d="m60 749 4 1h22l28-24q94-85 137-212t43-264q0-68-10-131T261 12t-37-88-38-67-41-51-32-33-23-19l-4-4H63q-3 0-5 3t-3 9q1 1 11 13Q221-64 221 250T66 725q-10 12-11 13 0 8 5 11"/><path id="f" d="M84 520q0 8 4 13t8 6l3 1q7 0 154-69t291-137l143-69q7-5 7-15t-7-15q-2-2-292-139L107-40h-6q-18 2-18 20v3q-1 7 15 16 19 10 150 72 78 37 130 61l248 118-248 118Q90 504 86 509q-2 4-2 11"/><path id="g" d="M311 43q-15-13-44-28T206 0q-63 0-101 45T66 160q0 105 77 193t171 89q47 0 87-48l3 4q2 3 5 6t9 8 13 7 16 3q14 0 23-9t10-19q0-15-57-242T363-80q-18-54-77-89t-135-36q-141 0-141 68 0 26 18 46t46 20q15 0 28-9t14-31q0-10-2-19t-7-14-8-10-7-8l-2-2h1q10-3 60-3 38 0 60 12 23 11 43 33t28 47q6 19 16 62 13 48 13 56m73 285-4 11q-3 11-5 15t-6 14-10 14-13 11-18 9-22 3q-44 0-85-53-30-39-50-119t-20-116q0-79 62-79 56 0 110 70l8 10z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0"><g><use data-c="1D44E" xlink:href="#a" transform="scale(1 -1)"/><g data-mjx-texclass="ORD"><use data-c="1D453" xlink:href="#b" transform="scale(1 -1) translate(562 413)scale(.707)"/><use data-c="28" xlink:href="#c" transform="scale(1 -1) translate(562 413)scale(.707) translate(550)"/><use data-c="1D465" xlink:href="#d" transform="scale(1 -1) translate(562 413)scale(.707) translate(939)"/><use data-c="29" xlink:href="#e" transform="scale(1 -1) translate(562 413)scale(.707) translate(1511)"/></g></g><use data-c="3E" xlink:href="#f" transform="scale(1 -1) translate(2233.3)"/><g><use data-c="1D44E" xlink:href="#a" transform="scale(1 -1) translate(3289.1)"/><g data-mjx-texclass="ORD"><use data-c="1D454" xlink:href="#g" transform="scale(1 -1) translate(3289.1) translate(562 413)scale(.707)"/><use data-c="28" xlink:href="#c" transform="scale(1 -1) translate(3289.1) translate(562 413)scale(.707) translate(477)"/><use data-c="1D465" xlink:href="#d" transform="scale(1 -1) translate(3289.1) translate(562 413)scale(.707) translate(866)"/><use data-c="29" xlink:href="#e" transform="scale(1 -1) translate(3289.1) translate(562 413)scale(.707) translate(1438)"/></g></g></g></svg>

use SvgXml xml prop for rendering.

image

Snack or a link to a repository

https://snack.expo.dev/@mj-studio/svg-error-reproduce

Note

I can't reproduce with snack because it doesn't support 15.8.0 yet. But it seems clear how to reproduce it.

SVG version

15.8.0

React Native version

0.76

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

Android emulator

Device model

No response

Acknowledgements

Yes

Copy link

github-actions bot commented Oct 30, 2024

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Description section.

@github-actions github-actions bot added the Missing info The user didn't precise the problem enough label Oct 30, 2024
@mym0404 mym0404 changed the title [Android] getCurrentColor crash DepsView + Use [Android] getCurrentColor crash DepsView + Use, java.lang.ClassCastException: com.horcrux.svg.DefsView cannot be cast to com.horcrux.svg.RenderableView Oct 30, 2024
@jakex7 jakex7 added bug and removed Missing info The user didn't precise the problem enough labels Oct 30, 2024
@jakex7 jakex7 closed this as completed in 2a58016 Oct 31, 2024
@tvooo
Copy link

tvooo commented Nov 14, 2024

Hey, thanks for the fix @jakex7. I continue to get this error with v15.9.0, though: https://rise-calendar.sentry.io/share/issue/ca6e98583d0041aca4d65071d4b6b43a/ - any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants