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

-[RNSVGRenderable renderLayerTo:rect:] | Fatal Exception: CALayerInvalidGeometry | CALayer bounds contains NaN: [0 0; nan nan] #978

Closed
jgcmarins opened this issue Mar 20, 2019 · 15 comments · Fixed by #2220

Comments

@jgcmarins
Copy link

Hello,

I got this error:

Fatal Exception: CALayerInvalidGeometry
CALayer bounds contains NaN: [0 0; nan nan]

Stack:

Fatal Exception: CALayerInvalidGeometry
0  CoreFoundation                 0x1cb045ea4 __exceptionPreprocess
1  libobjc.A.dylib                0x1ca215a50 objc_exception_throw
2  CoreFoundation                 0x1caf4c484 -[NSCache init]
3  QuartzCore                     0x1cf64bbdc CA::Layer::set_bounds(CA::Rect const&, bool)
4  QuartzCore                     0x1cf63c024 -[CALayer setBounds:]
5  UIKitCore                      0x1f87be624 -[UIView(Geometry) setBounds:]
6  app                       0x102c802a8 -[RNSVGRenderable renderLayerTo:rect:]
7  app                       0x102c7fd90 -[RNSVGRenderable renderTo:rect:]
8  app                       0x102c81a38 __33-[RNSVGGroup renderGroupTo:rect:]_block_invoke
9  app                       0x102c85720 -[RNSVGNode traverseSubviews:]
10 app                       0x102c816b8 -[RNSVGGroup renderGroupTo:rect:]
11 app                       0x102c7fd90 -[RNSVGRenderable renderTo:rect:]
12 app                       0x102c81a38 __33-[RNSVGGroup renderGroupTo:rect:]_block_invoke
13 app                       0x102c85720 -[RNSVGNode traverseSubviews:]
14 app                       0x102c816b8 -[RNSVGGroup renderGroupTo:rect:]
15 app                       0x102c7fd90 -[RNSVGRenderable renderTo:rect:]
16 app                       0x102c978d0 -[RNSVGSvgView drawToContext:withRect:]
17 app                       0x102c97bc8 -[RNSVGSvgView drawRect:]
18 UIKitCore                      0x1f87d8da4 -[UIView(CALayerDelegate) drawLayer:inContext:]
19 QuartzCore                     0x1cf64170c -[CALayer drawInContext:]
20 QuartzCore                     0x1cf522ca8 CABackingStoreUpdate_
21 QuartzCore                     0x1cf64828c invocation function for block in CA::Layer::display_()
22 QuartzCore                     0x1cf640fc4 -[CALayer _display]
23 QuartzCore                     0x1cf5a5668 CA::Context::commit_transaction(CA::Transaction*)
24 QuartzCore                     0x1cf5d3ec8 CA::Transaction::commit()
25 QuartzCore                     0x1cf5d4d30 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
26 CoreFoundation                 0x1cafd56bc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
27 CoreFoundation                 0x1cafd0350 __CFRunLoopDoObservers
28 CoreFoundation                 0x1cafd0100 CFRunLoopRunSpecific
29 GraphicsServices               0x1cd249584 GSEventRunModal
30 UIKitCore                      0x1f8330c00 UIApplicationMain
31 app                       0x102a8bc88 main (main.m:14)
32 libdyld.dylib                  0x1caa8ebb4 start

RN Version: 0.59.0
RN Svg Version: 9.3.3
iOS version: 12.1.4

Thanks for this awesome lib \o/

@jgcmarins jgcmarins changed the title Fatal Exception: CALayerInvalidGeometry - CALayer bounds contains NaN: [0 0; nan nan] -[RNSVGRenderable renderLayerTo:rect:] | Fatal Exception: CALayerInvalidGeometry | CALayer bounds contains NaN: [0 0; nan nan] Mar 20, 2019
@almostintuitive
Copy link

We also have the same crash, after upgrading from react-native-svg 5.x to 8.x:
2019-04-16 12:52:04.924957+0900 Drops[64330:12485664] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001128c31bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000111e69735 objc_exception_throw + 48
2 CoreFoundation 0x00000001128c3015 +[NSException raise:format:] + 197
3 QuartzCore 0x000000011091b1a3 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 141
4 QuartzCore 0x000000011090a293 -[CALayer setPosition:] + 57
5 UIKitCore 0x000000011c533ef5 -[UIView setCenter:] + 268
6 Drops 0x000000010acd4aca -[RNSVGRenderable renderLayerTo:rect:] + 2266
7 Drops 0x000000010acd3fe6 -[RNSVGRenderable renderTo:rect:] + 2614
8 Drops 0x000000010acb6a3b __33-[RNSVGGroup renderGroupTo:rect:]_block_invoke + 571
9 Drops 0x000000010acbfc4a -[RNSVGNode traverseSubviews:] + 362
10 Drops 0x000000010acb61a0 -[RNSVGGroup renderGroupTo:rect:] + 384
11 Drops 0x000000010acb600d -[RNSVGGroup renderLayerTo:rect:] + 157
12 Drops 0x000000010acd3fe6 -[RNSVGRenderable renderTo:rect:] + 2614
13 Drops 0x000000010acb6a3b __33-[RNSVGGroup renderGroupTo:rect:]block_invoke + 571
14 Drops 0x000000010acbfc4a -[RNSVGNode traverseSubviews:] + 362
15 Drops 0x000000010acb61a0 -[RNSVGGroup renderGroupTo:rect:] + 384
16 Drops 0x000000010acb600d -[RNSVGGroup renderLayerTo:rect:] + 157
17 Drops 0x000000010acd3fe6 -[RNSVGRenderable renderTo:rect:] + 2614
18 Drops 0x000000010acd8439 -[RNSVGSvgView drawToContext:withRect:] + 1769
19 Drops 0x000000010acd89b7 -[RNSVGSvgView drawRect:] + 1063
20 UIKitCore 0x000000011c558dc6 -[UIView(CALayerDelegate) drawLayer:inContext:] + 550
21 QuartzCore 0x0000000110910729 -[CALayer drawInContext:] + 285
22 QuartzCore 0x000000011080af92 CABackingStoreUpdate
+ 173
23 QuartzCore 0x00000001109173e1 ___ZN2CA5Layer8display_Ev_block_invoke + 44
24 QuartzCore 0x000000011091009b -[CALayer _display] + 2064
25 QuartzCore 0x000000011088e8ee _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 634
26 QuartzCore 0x00000001108c597e _ZN2CA11Transaction6commitEv + 576
27 QuartzCore 0x00000001108c66fa _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
28 CoreFoundation 0x0000000112827c27 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
29 CoreFoundation 0x00000001128220be __CFRunLoopDoObservers + 430
30 CoreFoundation 0x0000000112822751 __CFRunLoopRun + 1537
31 CoreFoundation 0x0000000112821e11 CFRunLoopRunSpecific + 625
32 GraphicsServices 0x0000000115a811dd GSEventRunModal + 62
33 UIKitCore 0x000000011c06f81d UIApplicationMain + 140
34 Drops 0x000000010a9188a0 main + 112
35 libdyld.dylib 0x00000001145d3575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@dmydry
Copy link

dmydry commented May 28, 2019

Have the same error on IOS 10

@msand
Copy link
Collaborator

msand commented Sep 28, 2019

Repro needed.

@msand msand closed this as completed Sep 28, 2019
@deansimcox
Copy link

@jgcmarins @itchingpixels @dmydry Hey fellas, just reaching out to see if any of you had managed to figure this one out?

We've been seeing this sporadically for users on iOS 13.3.1, but I'm struggling to be able to pinpoint this bug. The stack traces we've seen all point towards line 387 of RNSVGRenderable.m, but when place breakpoints there I never seem to be able to reproduce it. This is line 387 by the way:
if (!isnan(center.x) && !isnan(center.y)) {
I feel like there might be something happening at line 382:
CGRect bounds = CGRectMake(0, 0, CGRectGetWidth(clientRect), CGRectGetHeight(clientRect));
And maybe CGReactGetWidth and Height are occasional returning NAN? But I can't confirm that.

Cheers
Dean

@r0b0t3d
Copy link

r0b0t3d commented May 2, 2020

Got this crash via crashlytics
image

Fatal Exception: CALayerInvalidGeometry
CALayer bounds contains NaN: [0 0; nan nan]. Layer: <CALayer:0x281d95b60; position = CGPoint (60.6667 0); bounds = CGRect (0 0; 121.333 0); delegate = <RNSVGPath: 0x10888aa00; frame = (0 0; 121.333 0); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x281d95b60>>; allowsGroupOpacity = YES; >
Fatal Exception: CALayerInvalidGeometry
0  CoreFoundation                 0x1804bc300 (Missing)
1  libobjc.A.dylib                0x1801d0c1c objc_exception_throw
2  CoreFoundation                 0x1803abe68 (Missing)
3  QuartzCore                     0x1871e8cd4 (Missing)
4  QuartzCore                     0x1871e8c04 (Missing)
5  UIKitCore                      0x184ab595c (Missing)
6  Stuneo                         0x1049b4bac -[RNSVGRenderable renderLayerTo:rect:] + 388 (RNSVGRenderable.m:388)
7  Stuneo                         0x1049b4104 -[RNSVGRenderable renderTo:rect:] + 284 (RNSVGRenderable.m:284)
8  Stuneo                         0x1049a2ec8 __33-[RNSVGGroup renderGroupTo:rect:]_block_invoke + 59 (RNSVGGroup.m:59)
9  Stuneo                         0x1049aa644 -[RNSVGNode traverseSubviews:] + 593 (RNSVGNode.m:593)
10 Stuneo                         0x1049a2894 -[RNSVGGroup renderGroupTo:rect:] + 80 (RNSVGGroup.m:80)
11 Stuneo                         0x1049b4104 -[RNSVGRenderable renderTo:rect:] + 284 (RNSVGRenderable.m:284)
12 Stuneo                         0x1049b8e4c -[RNSVGSvgView drawToContext:withRect:] + 196 (RNSVGSvgView.m:196)
13 Stuneo                         0x1049b9158 -[RNSVGSvgView drawRect:] + 228 (RNSVGSvgView.m:228)
14 UIKitCore                      0x184acf24c (Missing)
15 QuartzCore                     0x1871e0e30 (Missing)
16 QuartzCore                     0x1870a9f98 (Missing)
17 QuartzCore                     0x1871e1dcc (Missing)
18 QuartzCore                     0x1871e1874 (Missing)
19 QuartzCore                     0x1871f13e8 (Missing)
20 QuartzCore                     0x187136014 (Missing)
21 QuartzCore                     0x187160b74 (Missing)
22 UIKitCore                      0x18462a5cc (Missing)
23 CoreFoundation                 0x180436ee8 (Missing)
24 CoreFoundation                 0x180431b78 (Missing)
25 CoreFoundation                 0x180432018 (Missing)
26 CoreFoundation                 0x1804318f4 (Missing)
27 GraphicsServices               0x18ad33604 (Missing)
28 UIKitCore                      0x1845ffe5c (Missing)
29 Stuneo                         0x10455f48c main + 14 (main.m:14)
30 libdyld.dylib                  0x1802ad2dc (Missing)

@vomchik
Copy link

vomchik commented May 6, 2020

I also got this error on iPhone 11 Pro Max Simulator.

@deansimcox
Copy link

@r0b0t3d @vomchik , are any of you able to reproduce the error? We've only been seeing this through crashlytics, and have been going in circles trying to figure out how to reproduce it.

@r0b0t3d
Copy link

r0b0t3d commented May 7, 2020

@deansimcox Can't reproduce. just got it via crashlytics.

@vomchik
Copy link

vomchik commented May 7, 2020

I have a problem with translateX, translateY these values are an instance of Animated.Value.

That's all that I found for now.
Still trying to sort out the problem 🕵️

const AnimatedG = Animated.createAnimatedComponent(G);

<Svg>
  <AnimatedG
    style={{
      transform: [
        {perspective: 100},
        {scale: panViewScale},
        {translateX: panViewTranslateX},
        {translateY: panViewTranslateY},
      ],
    }}
  >
    <Rect width={50} height={50} fill="black" />
  <AnimatedG>
</Svg>

Update: So, it seems the crash happens when I use a interpolate method

panViewTranslateY: Animated.add(this.translateY, this.translateYPinch).interpolate({
  inputRange: [-this.contentMaxY, -this.contentMinY],
  outputRange: [-this.contentMaxY, -this.contentMinY],
  extrapolate: 'clamp',
}),

@deansimcox
Copy link

@vomchik that's a pretty good lead - we've used the interpolate method in a few spots in our app too.
So maybe interpolate is occasionally returning NaN under certain conditions?

@sammarks
Copy link

In my case it was because I had some elements that were of 0 width or height (pretty sure the whole SVG was actually), or I was passing NaN as one of the numeric values accidentally.

@wangliang1124
Copy link

Had this issue been fixed? I have the same error and the version is 9.5.1.

@joeyfigaro
Copy link

joeyfigaro commented Jan 14, 2022

Any movement here? Using version 12.1.0 – has started to show up randomly.


Turns out my issue was with LogRocket. I opened a ticket there for it.

@CFPanda
Copy link

CFPanda commented Aug 2, 2023

Has anyone fixed this issue? I have the same error.

@GaeCuure
Copy link

Same issue with "react-native-svg": "13.9.0"

WoLewicki pushed a commit that referenced this issue Feb 26, 2024
This PR adds missing checks whether SVG bounds size values are nan. This PR should fix [this](#978) old issue that still happens sometimes.
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.