iOS app crashed on iOS 16

Hi team,

We have an iOS app. Since July 15, 2022, our users met a kind of app crash due to an invalid memory fetch. The time is when Apple released iOS 16 beta officially. After Sep 12, crash count started to increase drastically. The time is Apple released iOS 16 officially.

Crash backtrace can be seen as follows.

Thread 14 Crashed:
0 libsystem_platform.dylib 0x00000001f8810930 _platform_memmove + 96
1 CoreGraphics 0x00000001adb64104 CGDataProviderCreateWithCopyOfData + 20
2 CoreGraphics 0x00000001adb4cdb4 CGBitmapContextCreateImage + 172
3 VisionKitCore 0x00000001ed813f10 -[VKCRemoveBackgroundResult _createCGImageFromBGRAPixelBuffer:cropRect:] + 348
4 VisionKitCore 0x00000001ed813cc0 -[VKCRemoveBackgroundResult createCGImage] + 156
5 VisionKitCore 0x00000001ed8ab6f8 __vk_cgImageRemoveBackgroundWithDownsizing_block_invoke + 64
6 VisionKitCore 0x00000001ed881474 __63-[VKCRemoveBackgroundRequestHandler performRequest:completion:]_block_invoke.5 + 436
7 MediaAnalysisServices 0x00000001eec58968 __92-[MADService performRequests:onPixelBuffer:withOrientation:andIdentifier:completionHandler:]_block_invoke.38 + 400
8 CoreFoundation 0x00000001abff0a14 __invoking___ + 148
9 CoreFoundation 0x00000001abf9cf2c -[NSInvocation invoke] + 428
10 Foundation 0x00000001a6464d38 __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 16
11 Foundation 0x00000001a64362fc -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 520
12 Foundation 0x00000001a6a10f44 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_5 + 188
13 libxpc.dylib 0x00000001f89053e4 _xpc_connection_reply_callout + 124
14 libxpc.dylib 0x00000001f88f8580 _xpc_connection_call_reply_async + 88
15 libdispatch.dylib 0x00000001b340205c _dispatch_client_callout3 + 20
16 libdispatch.dylib 0x00000001b341ff58 _dispatch_mach_msg_async_reply_invoke + 344
17 libdispatch.dylib 0x00000001b340956c _dispatch_lane_serial_drain + 376
18 libdispatch.dylib 0x00000001b340a214 _dispatch_lane_invoke + 436
19 libdispatch.dylib 0x00000001b3414e10 _dispatch_workloop_worker_thread + 652
20 libsystem_pthread.dylib 0x00000001f88a4df8 _pthread_wqthread + 288
21 libsystem_pthread.dylib 0x00000001f88a4b98 start_wqthread + 8

Last but not the least. The users who met this kind of app crash use iOS16+. We think this crash is related to iOS 16 SDK. We're appreciate that you can provide some clues how to fix this kind of crash.

How about you debug your app in Xcode with iOS 16 and find out where the crash is happening? Perhaps something changed between iOS 15 and 16, and you haven't updated your app to handle it?

+1

+1

Hi, I have the same problem, do you have a solution now?Thanks!

+1

Hey @feiyz , did you get any fix for this? I am also getting same crash, happening in webview screen opened , only for iOS 16.

me too

Me too. Any updates?

Me too. Any updates?

I didn't get the reply from Apple. Do you know how to re-produce the crash? What's your app?

Disable long press selection of the image in webview,you will fix the crash!

Any Update?

Hi everyone!

As the provider of an SDK we are observing exactly the same crash for the iOS app of one of our partners. Only iOS 16 devices affected, but not limited to specific sub versions. Crashes suddenly appeared April 18th, 2023, for several app versions and not related to a release of a new app version or server-side config changes. Stack traces of other threads not showing any method call of app features or our SDK.

30.000 crashes within 3 days affecting 18.600 users so far.

Are there any updates on this topic?

Hi Everyone i find the bug only happend in iOS 16.0.<iOS16.2 because ImageAnalysisutilit has bug . if you don't need copy object from image in WKWebview you can hook the default behavior to ignore long press gesture analysis image until timeout fallback to <=iOS 15.x behavior (only can copy image without copy object from image )

https://github.com/WebKit/WebKit/blob/releases/Apple/Safari-16.1-iOS-16.1.1/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

static void hook2(void) {
    
    Class class = objc_getClass("WKContentView");
    SEL selector = sel_registerName("imageAnalysisGestureDidBegin:");
    Method m = class_getInstanceMethod(class, selector);
    const char *type = method_getTypeEncoding(m);
    IMP newImp = imp_implementationWithBlock(^void(id self,UILongPressGestureRecognizer *ges) {
        // do nothing

    });
    if (m == NULL || class == NULL) {
        return;
    }
    IMP oldImp = class_replaceMethod(class, selector, newImp, type);
}
void hookStart() {
       if (@available (iOS 16.0, *)) {
        if (@available (iOS 16.2, *)) {
            return;
        } else {
           hook2();
        }
    }
iOS app crashed on iOS 16
 
 
Q