App crashes: CA::Render::InterpolatedFunction::encode(CA::Render::Encoder*)

I've started seeing several users getting an app crash that I've been unable to find the root cause for so far. I've tried running the app in release build with address sanitizer and zombie objects checks enabled but have been unable to reproduce it. It only occurs for iOS 17 users. Any ideas on how I can troubleshoot this?

Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

Crashed: com.apple.main-thread
0  libsystem_platform.dylib       0xed4 _platform_memmove + 52
1  QuartzCore                     0x137120 CA::Render::InterpolatedFunction::encode(CA::Render::Encoder*) const + 248
2  QuartzCore                     0x136f40 CA::Render::GradientLayer::encode(CA::Render::Encoder*) const + 44
3  QuartzCore                     0x2e384 CA::Render::Layer::encode(CA::Render::Encoder*) const + 284
4  QuartzCore                     0x2e224 CA::Render::encode_set_object(CA::Render::Encoder*, unsigned long, unsigned int, CA::Render::Object*, unsigned int) + 196
5  QuartzCore                     0x2b654 invocation function for block in CA::Context::commit_transaction(CA::Transaction*, double, double*) + 244
6  QuartzCore                     0x2b4fc CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 368
7  QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
8  QuartzCore                     0x2b4bc CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 304
9  QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
10 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
11 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
12 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
13 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
14 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
15 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
16 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
17 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
18 QuartzCore                     0x2b488 CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) + 252
19 QuartzCore                     0x6fc60 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 11192
20 QuartzCore                     0x66574 CA::Transaction::commit() + 648
21 UIKitCore                      0x31b5ec __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 36
22 CoreFoundation                 0x373a8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
23 CoreFoundation                 0x35b9c __CFRunLoopDoBlocks + 356
24 CoreFoundation                 0x33a9c __CFRunLoopRun + 848
25 CoreFoundation                 0x33668 CFRunLoopRunSpecific + 608
26 GraphicsServices               0x35ec GSEventRunModal + 164
27 UIKitCore                      0x22c2b4 -[UIApplication _run] + 888
28 UIKitCore                      0x22b8f0 UIApplicationMain + 340
29 Coach                          0x799d8 main + 14 (main.m:14)
30 ???                            0x1abefadcc (Missing)
Post not yet marked as solved Up vote post of mdhorda Down vote post of mdhorda
1.9k views

Replies

Here's a full crash report:

We're having the exact same issue. We could isolate the version it started and, for my surprise, the only change in code was the app icon. But we also updated the xcode version from 14.1 to 15.0 in this build. So this is the only reason we could think of. We're rolling back to a build from xcode 14 and we're going to check if it solves the problem. If that's the case, it's kind of a disappointment because Xcode is limited by specific macos versions and it's difficult to be changing it constantly, specially when it's a rollback.

  • @alanraso please let us know what the results when you have them. Would be a real disappointment indeed.

  • @chrisjrex2

    This fixed the crashes. But I couldn't find anything on the internet about crashes being caused only by updating XCode, so I don't know if it has to do with come library or even with some code that is specific of our project. We're still a little in the dark.

  • @alanraso did you notice if this crash was only occurring on iOS 17 devices? This is what we are seeing on our side.

I have the exact same issue. I will try to push a new build with Xcode 14 to see if it fix the crash. Did someone already reported the issue to Apple ?

This exact issue has been happening for us as soon as we switched to Xcode 15 for our deployments. Once we rolled back to Xcode 14, the crash went away. Like others have stated, we only seen the crash affect users with devices using iOS 17.

Same problem in this thread. [https://developer.apple.com/forums/thread/743525)

In case this is helpful for anyone, I got this response from Apple:

Looking through your crash logs the cause appears to be related to the use of gradient layers. This is either causing a memory allocation error or some other problem in your app. Please review your use of gradient layers.

Have seen this crash (amongst various other crashes) but we build from Xcode 14.3. It's also only for iOS 17 users. For our reproduction, we needed the app to be used for about 30 minutes and keep repeating certain operations. Eventually, it'll crash somewhere along the way. A telltale is when the WKWebView we use starts seeing white squares / blotches instead of the actual content, then we know it's about to crash soon. We think it's some kind of memory corruption.

I have the same problem with running on iOS 17. Reading the success with reverting to XC 14, that's what I'll do. I'll see if running from XC14 will allow for crashless running on iOS 17.

Is anyone else seeing "suspiciously large function size"? as an error printout after the crash? I get this or the generic "Terminated due to memory issue". I've found no information online about the "suspiciously large function size", and it happens randomly across many different views.

I've only recently experienced these issues, with no similar crashes in the past ever. Is this the case for everyone else on this thread?

Enabling Extended Virtual Addressing Entitlement seems to be helping with this issue. Still need to test more. Could anyone else confirm?

I had been using the "Shimmer" library (https://github.com/markiv/SwiftUI-Shimmer). In identifying all instances of gradients in my codebase, commenting out all instances of the ".shimmering(...)" property wrapper solved my crashing problem.

Looking at the Shimmer package, it uses some gradients to create the animation. The 21AUG23 release of Shimmer notes that "the shimmer animation no longer worked on the iOS 17 betas." Of course, only seeing that now after I've found the bug.

If you don't have the shimmer library, I'd highly recommend going through each and every instance of a gradient in your codebase. Hope this helps some others on this thread!

  • Thanks for posting this solution! this is the issue for our team (the original post). Did upgrade to the latest version of shimmer and see if it was free from the crash?

    We have removed it from our codebase, but i would like to put it back in it if we can. However we can't use our user base as a test pool for that.

Add a Comment

Our team has this crash reported to Crashlytics, but not reproducible locally. We are not using Shimmer, but we do have some similar code for example

.mask(LinearGradient(gradient: Gradient(stops: [
                    .init(color: .clear, location: 0),
                    .init(color: .black, location: 0.05),
                    .init(color: .black, location: 0.95),
                    .init(color: .clear, location: 1),
                ]),
                startPoint: .leading,
                endPoint: .trailing))

When I looked at the fix on Shimmer repo, it seems adding one line for animation .animation(animation, value: isInitialState) solves it. wondering if it is the same fix for my code. If anyone can help, that would be highly apprecaited!