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

[FBSDKAppEventsDeviceInfo encodedDeviceInfo] block in main thread #2103

Open
4 of 5 tasks
linziyiwj opened this issue Aug 22, 2022 · 32 comments
Open
4 of 5 tasks

[FBSDKAppEventsDeviceInfo encodedDeviceInfo] block in main thread #2103

linziyiwj opened this issue Aug 22, 2022 · 32 comments

Comments

@linziyiwj
Copy link

linziyiwj commented Aug 22, 2022

Checklist before submitting a bug report

Xcode version

13.4

Facebook iOS SDK version

14.1.0

Dependency Manager

CocoaPods

SDK Framework

Core

Goals

We want to solve the block of the main thread

Expected results

There will be no block of main thread

deadlock between thread 1 and thread 8

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00000001b81681a4 libsystem_kernel.dylib`__ulock_wait + 8
    frame #1: 0x00000001f1d969a4 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 196
    frame #2: 0x00000001992fc634 libobjc.A.dylib`objc_sync_enter + 36
    frame #3: 0x000000010d8a7804 FBSDKCoreKit`-[FBSDKAppEventsDeviceInfo encodedDeviceInfo](self=<unavailable>, _cmd=<unavailable>) at FBSDKAppEventsDeviceInfo.m:100:3 [opt]
    frame #4: 0x000000010d8aa908 FBSDKCoreKit`-[FBSDKAppEventsUtility activityParametersDictionaryForEvent:shouldAccessAdvertisingID:userID:userData:](self=0x00000002810e1e00, _cmd=<unavailable>, eventCategory=<unavailable>, shouldAccessAdvertisingID=<unavailable>, userID=<unavailable>, userData=<unavailable>) at FBSDKAppEventsUtility.m:109:63 [opt]
    frame #5: 0x000000010d8a19f0 FBSDKCoreKit`__32-[FBSDKAppEvents publishInstall]_block_invoke(.block_descriptor=0x0000000281f782c0) at FBSDKAppEvents.m:866:59 [opt]
    frame #6: 0x000000010d8a2a40 FBSDKCoreKit`__43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke_2(.block_descriptor=0x0000000280a0e130, serverConfiguration=<unavailable>, error=<unavailable>) at FBSDKAppEvents.m:1023:9 [opt]
    frame #7: 0x000000010d9037c8 FBSDKCoreKit`-[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:](self=<unavailable>, _cmd=<unavailable>, completionBlock=<unavailable>) at FBSDKServerConfigurationManager.m:192:7 [opt]
    frame #8: 0x000000010d8a254c FBSDKCoreKit`__43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke(.block_descriptor=0x0000000280b93840) at FBSDKAppEvents.m:951:5 [opt]
    frame #9: 0x000000010d8a738c FBSDKCoreKit`-[FBSDKAppEventsConfigurationManager _processResponse:error:](self=<unavailable>, _cmd=<unavailable>, response=<unavailable>, error=<unavailable>) at FBSDKAppEventsConfigurationManager.m:138:7 [opt]
    frame #10: 0x000000010d8df8ec FBSDKCoreKit`-[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:](self=<unavailable>, _cmd=<unavailable>, connection=<unavailable>, results=<unavailable>, error=<unavailable>) at FBSDKGraphRequestMetadata.m:32:5 [opt]
    frame #11: 0x000000010d8dc870 FBSDKCoreKit`__82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke(.block_descriptor=0x00000002826c94a0) at FBSDKGraphRequestConnection.m:998:5 [opt]
    frame #12: 0x000000010d8dc764 FBSDKCoreKit`-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:](self=<unavailable>, _cmd=<unavailable>, body=<unavailable>, error=<unavailable>, metadata=<unavailable>, canNotifyDelegate=<unavailable>) at FBSDKGraphRequestConnection.m:1032:3 [opt]
    frame #13: 0x000000010d8dc348 FBSDKCoreKit`__65-[FBSDKGraphRequestConnection _completeWithResults:networkError:]_block_invoke(.block_descriptor=0x000000016eeb22b0, metadata=<unavailable>, i=<unavailable>, stop=<unavailable>) at FBSDKGraphRequestConnection.m:981:5 [opt]
    frame #14: 0x0000000180a45e18 CoreFoundation`__NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    frame #15: 0x0000000180a8434c CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 196
    frame #16: 0x000000010d8dc078 FBSDKCoreKit`-[FBSDKGraphRequestConnection _completeWithResults:networkError:](self=0x0000000282e4d9d0, _cmd=<unavailable>, results=<unavailable>, networkError=<unavailable>) at FBSDKGraphRequestConnection.m:959:3 [opt]
    frame #17: 0x000000010d8db1fc FBSDKCoreKit`-[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:](self=0x0000000282e4d9d0, _cmd=<unavailable>, response=<unavailable>, data=<unavailable>, error=<unavailable>) at FBSDKGraphRequestConnection.m:814:3 [opt]
    frame #18: 0x000000010c96c6d4 libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #19: 0x000000010c96e3b4 libdispatch.dylib`_dispatch_client_callout + 20
    frame #20: 0x000000010c97e898 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1224
    frame #21: 0x0000000180a89d84 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    frame #22: 0x0000000180a43f5c CoreFoundation`__CFRunLoopRun + 2540
    frame #23: 0x0000000180a57468 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #24: 0x000000019c5e338c GraphicsServices`GSEventRunModal + 164
    frame #25: 0x00000001833f9088 UIKitCore`-[UIApplication _run] + 1100
    frame #26: 0x0000000183177958 UIKitCore`UIApplicationMain + 2092
    frame #27: 0x0000000100f54348 `main(argc=1, argv=0x000000016eeb3748) at main.m:19:17
    frame #28: 0x000000010c839aa4 dyld`start + 520
  thread #3, name = 'gputools.smt_poll.0x280558c00'
    frame #0: 0x00000001b8167ae4 libsystem_kernel.dylib`__semwait_signal + 8
    frame #1: 0x000000018b979f00 libsystem_c.dylib`nanosleep + 216
    frame #2: 0x000000018b97ac20 libsystem_c.dylib`usleep + 68
    frame #3: 0x000000010cafc6f0 libMTLCapture.dylib`___lldb_unnamed_symbol3110 + 108
    frame #4: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148
  thread #5
    frame #0: 0x00000001b8167b2c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #6, name = 'com.apple.uikit.eventfetch-thread'
    frame #0: 0x00000001b8167504 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x00000001b8167b9c libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000180a3f738 CoreFoundation`__CFRunLoopServiceMachPort + 372
    frame #3: 0x0000000180a43a2c CoreFoundation`__CFRunLoopRun + 1212
    frame #4: 0x0000000180a57468 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #5: 0x0000000182273c94 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236
    frame #6: 0x00000001822b4dc8 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 92
    frame #7: 0x0000000183372230 UIKitCore`-[UIEventFetcher threadMain] + 524
    frame #8: 0x00000001822c340c Foundation`__NSThread__start__ + 808
    frame #9: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148
  thread #8, queue = 'com.apple.root.default-qos'
    frame #0: 0x00000001b8167f90 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x00000001f1da6254 libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x0000000182318e44 Foundation`-[NSOperation waitUntilFinished] + 584
    frame #3: 0x0000000180a78e44 CoreFoundation`_CFXNotificationPost + 796
    frame #4: 0x0000000182275f68 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 96
    frame #5: 0x000000018119e9bc CoreTelephony`-[CTTelephonyNetworkInfo updateLegacyRat:] + 88
    frame #6: 0x00000001811331fc CoreTelephony`-[CTTelephonyNetworkInfo updateRat:descriptor:] + 692
    frame #7: 0x0000000181132e8c CoreTelephony`-[CTTelephonyNetworkInfo queryRatForDescriptor:] + 236
    frame #8: 0x0000000181132cec CoreTelephony`-[CTTelephonyNetworkInfo queryRat] + 244
    frame #9: 0x00000001811316c4 CoreTelephony`-[CTTelephonyNetworkInfo initWithClient:] + 900
    frame #10: 0x0000000181137fa0 CoreTelephony`-[CTTelephonyNetworkInfo init] + 112
    frame #11: 0x000000010d8a86a4 FBSDKCoreKit`+[FBSDKAppEventsDeviceInfo _getCarrier](self=<unavailable>, _cmd=<unavailable>) at FBSDKAppEventsDeviceInfo.m:260:41 [opt]
    frame #12: 0x000000010d8a7cf8 FBSDKCoreKit`-[FBSDKAppEventsDeviceInfo _collectGroup1Data](self=0x000000028347ad00, _cmd=<unavailable>) at FBSDKAppEventsDeviceInfo.m:165:32 [opt]
    frame #13: 0x000000010d8a783c FBSDKCoreKit`-[FBSDKAppEventsDeviceInfo encodedDeviceInfo](self=<unavailable>, _cmd=<unavailable>) at FBSDKAppEventsDeviceInfo.m:110:7 [opt]
    frame #14: 0x000000010d8a6018 FBSDKCoreKit`-[FBSDKAppEventsATEPublisher publishATE](self=0x00000002810a9800, _cmd=<unavailable>) at FBSDKAppEventsATEPublisher.m:88:63 [opt]
    frame #15: 0x000000010d8a1fc8 FBSDKCoreKit`__28-[FBSDKAppEvents publishATE]_block_invoke(.block_descriptor=<unavailable>) at FBSDKAppEvents.m:902:5 [opt]
    frame #16: 0x000000010c96c6d4 libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #17: 0x000000010c96e3b4 libdispatch.dylib`_dispatch_client_callout + 20
    frame #18: 0x000000010c970f2c libdispatch.dylib`_dispatch_queue_override_invoke + 1052
    frame #19: 0x000000010c982500 libdispatch.dylib`_dispatch_root_queue_drain + 408
    frame #20: 0x000000010c982f0c libdispatch.dylib`_dispatch_worker_thread2 + 196
    frame #21: 0x00000001f1d9f0b8 libsystem_pthread.dylib`_pthread_wqthread + 228
  thread #9
    frame #0: 0x00000001f1d9ee8c libsystem_pthread.dylib`start_wqthread
  thread #13
    frame #0: 0x00000001b8167b2c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #15
    frame #0: 0x00000001f1d9ee8c libsystem_pthread.dylib`start_wqthread
  thread #18, name = 'AVAudioSession Notify Thread'
    frame #0: 0x00000001b8167504 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x00000001b8167b9c libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000180a3f738 CoreFoundation`__CFRunLoopServiceMachPort + 372
    frame #3: 0x0000000180a43a2c CoreFoundation`__CFRunLoopRun + 1212
    frame #4: 0x0000000180a57468 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #5: 0x0000000189e6a308 AudioSession`CADeprecated::GenericRunLoopThread::Entry(void*) + 164
    frame #6: 0x0000000189e73d64 AudioSession`CADeprecated::CAPThread::Entry(CADeprecated::CAPThread*) + 92
    frame #7: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148
  thread #19, name = 'JavaScriptCore bmalloc scavenger'
    frame #0: 0x00000001b8167f90 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x00000001f1da6254 libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001993a6ddc libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
    frame #3: 0x000000018cc2b358 JavaScriptCore`void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108
    frame #4: 0x000000018cc2fb28 JavaScriptCore`bmalloc::Scavenger::threadRunLoop() + 340
    frame #5: 0x000000018cc2f6c8 JavaScriptCore`bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 16
    frame #6: 0x000000018cc30b84 JavaScriptCore`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(bmalloc::Scavenger*), bmalloc::Scavenger*> >(void*) + 48
    frame #7: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148
  thread #23, name = 'com.apple.NSURLConnectionLoader'
    frame #0: 0x00000001b8167504 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x00000001b8167b9c libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000180a3f738 CoreFoundation`__CFRunLoopServiceMachPort + 372
    frame #3: 0x0000000180a43a2c CoreFoundation`__CFRunLoopRun + 1212
    frame #4: 0x0000000180a57468 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #5: 0x00000001814cb3f0 CFNetwork`___lldb_unnamed_symbol14597 + 464
    frame #6: 0x00000001822c340c Foundation`__NSThread__start__ + 808
    frame #7: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148
  thread #24, name = 'com.apple.CFNetwork.CustomProtocols'
    frame #0: 0x00000001b8167504 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x00000001b8167b9c libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000180a3f738 CoreFoundation`__CFRunLoopServiceMachPort + 372
    frame #3: 0x0000000180a43a2c CoreFoundation`__CFRunLoopRun + 1212
    frame #4: 0x0000000180a57468 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #5: 0x00000001814cb3f0 CFNetwork`___lldb_unnamed_symbol14597 + 464
    frame #6: 0x00000001822c340c Foundation`__NSThread__start__ + 808
    frame #7: 0x00000001f1d9f9a4 libsystem_pthread.dylib`_pthread_start + 148

Actual results

It gets stuck in the main thread for a long time

Steps to reproduce

Unfortunately I have not been able to reproduce this block yet.
It is only reported in Xcode hangs.
Hope to recover as soon as possible

Code samples & details

No response

@wwc625
Copy link

wwc625 commented Sep 29, 2022

same problem.have you resolved it?

@linziyiwj
Copy link
Author

same problem.have you resolved it?

@wwc625 No, the official didn't reply, have you solved it?

@pmanuelli
Copy link

We have the same problem!

App Hang: The app was terminated while unresponsive

0  libsystem_kernel.dylib   ___ulock_wait
1  libsystem_platform.dylib __os_unfair_lock_lock_slow
2  libobjc.A.dylib          _objc_sync_enter
3  FBSDKCoreKit             -[FBSDKAppEventsDeviceInfo encodedDeviceInfo] (FBSDKAppEventsDeviceInfo.m:100:3)
4  FBSDKCoreKit             -[FBSDKAppEventsUtility activityParametersDictionaryForEvent:shouldAccessAdvertisingID:userID:userData:] (FBSDKAppEventsUtility.m:109:63)
5  FBSDKCoreKit             __45-[FBSDKAppEvents flushOnMainQueue:forReason:]_block_invoke (FBSDKAppEvents.m:1243:67)
6  FBSDKCoreKit             __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke_2 (FBSDKAppEvents.m:1023:9)
7  FBSDKCoreKit             -[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:] (FBSDKServerConfigurationManager.m:192:7)
8  FBSDKCoreKit             __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke (FBSDKAppEvents.m:951:5)
9  FBSDKCoreKit             -[FBSDKAppEventsConfigurationManager loadAppEventsConfigurationWithBlock:] (FBSDKAppEventsConfigurationManager.m:97:9)
10 FBSDKCoreKit             -[FBSDKAppEvents fetchServerConfiguration:] (FBSDKAppEvents.m:950:3)
11 FBSDKCoreKit             -[FBSDKAppEvents flushOnMainQueue:forReason:] (FBSDKAppEvents.m:1231:3)
12 libdispatch.dylib        __dispatch_call_block_and_release
13 libdispatch.dylib        __dispatch_client_callout
14 libdispatch.dylib        __dispatch_main_queue_drain
15 libdispatch.dylib        __dispatch_main_queue_callback_4CF
16 CoreFoundation           ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
17 CoreFoundation           ___CFRunLoopRun
18 CoreFoundation           _CFRunLoopRunSpecific
19 GraphicsServices         _GSEventRunModal
20 UIKitCore                -[UIApplication _run]
21 UIKitCore                _UIApplicationMain
22 XXXXXXXXXXX              main (main.m:8:22)
23 dyld                     start

@grestuccia1
Copy link

same problem here :(

@linziyiwj
Copy link
Author

We have the same problem!

App Hang: The app was terminated while unresponsive

0  libsystem_kernel.dylib   ___ulock_wait
1  libsystem_platform.dylib __os_unfair_lock_lock_slow
2  libobjc.A.dylib          _objc_sync_enter
3  FBSDKCoreKit             -[FBSDKAppEventsDeviceInfo encodedDeviceInfo] (FBSDKAppEventsDeviceInfo.m:100:3)
4  FBSDKCoreKit             -[FBSDKAppEventsUtility activityParametersDictionaryForEvent:shouldAccessAdvertisingID:userID:userData:] (FBSDKAppEventsUtility.m:109:63)
5  FBSDKCoreKit             __45-[FBSDKAppEvents flushOnMainQueue:forReason:]_block_invoke (FBSDKAppEvents.m:1243:67)
6  FBSDKCoreKit             __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke_2 (FBSDKAppEvents.m:1023:9)
7  FBSDKCoreKit             -[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:] (FBSDKServerConfigurationManager.m:192:7)
8  FBSDKCoreKit             __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke (FBSDKAppEvents.m:951:5)
9  FBSDKCoreKit             -[FBSDKAppEventsConfigurationManager loadAppEventsConfigurationWithBlock:] (FBSDKAppEventsConfigurationManager.m:97:9)
10 FBSDKCoreKit             -[FBSDKAppEvents fetchServerConfiguration:] (FBSDKAppEvents.m:950:3)
11 FBSDKCoreKit             -[FBSDKAppEvents flushOnMainQueue:forReason:] (FBSDKAppEvents.m:1231:3)
12 libdispatch.dylib        __dispatch_call_block_and_release
13 libdispatch.dylib        __dispatch_client_callout
14 libdispatch.dylib        __dispatch_main_queue_drain
15 libdispatch.dylib        __dispatch_main_queue_callback_4CF
16 CoreFoundation           ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
17 CoreFoundation           ___CFRunLoopRun
18 CoreFoundation           _CFRunLoopRunSpecific
19 GraphicsServices         _GSEventRunModal
20 UIKitCore                -[UIApplication _run]
21 UIKitCore                _UIApplicationMain
22 XXXXXXXXXXX              main (main.m:8:22)
23 dyld                     start

@pmanuelli Have you solved the Hang problem?

@pmanuelli
Copy link

Hello @linziyiwj.

No, we haven't.

But we are going to try updating to the 15.1 version of the SDK. Maybe the issue is solved there.

@linziyiwj
Copy link
Author

Hello @pmanuelli The upgrade content of the official sdk does not mention the relevant optimization. Have you made any improvement after the upgrade

@linziyiwj
Copy link
Author

Have you solved the Hang problem?

@grestuccia1 Have you solved the Hang problem?

@kabigon1991
Copy link

@linziyiwj Have you solved the Hang problem?

@pmanuelli
Copy link

Hello. No, we are on version 15.1.0 and the issue persists...

@linziyiwj
Copy link
Author

@linziyiwj Have you solved the Hang problem?

@kabigon1991 No, the Hang problem still exists

@alansteiman
Copy link

Did anyone figure out the root cause? we know it's a deadlock, but why exactly? is it related to a network request?
We got a report that one user reproduced the hang connected to Wifi, but not on mobile data, some kind of IP blocking perhaps? throttling?

@linziyiwj
Copy link
Author

@alansteiman
It should be that the main thread and sub-thread inside the sdk have accessed CTTelephonyNetworkInfo at the same time.
Although the root cause was found, no solution was found, Have you solved the Hang problem?

@alansteiman
Copy link

@linziyiwj we have not solved the issue, we downgraded to previous SDK version for now 😕

@linziyiwj
Copy link
Author

@alansteiman
May I ask which version you downgraded to? Does the lower version not have this problem?

@alansteiman
Copy link

@linziyiwj very very old.
We jumped from 9.0.0 to 14.1.0, we downgraded back to 9.0.0 🤦

@linziyiwj
Copy link
Author

@alansteiman

@alansteiman Really too old version

@Measyaro66
Copy link

ហាយ

@linziyiwj
Copy link
Author

[FBSDKAppEventsDeviceInfo encodedDeviceInfo] , This method should be used for dot statistics,I want to try to hook the method, and return nil.
Not sure if there are other negative effects, such as login authentication, etc.

@mahaghanemamer
Copy link

Any updates?

@FannCyii
Copy link

FannCyii commented Feb 9, 2023

Any solutions?

@gonsee
Copy link

gonsee commented Feb 15, 2023

Many of our users have recently reported app hangs on launch, and we found that this issue is the root cause.
So we replaced -[FBSDKAppEventsDeviceInfo encodedDeviceInfo] with our method that returns nil using method swizzling.
The deadlock issue has been resolved and there are no problems with Facebook login and share functionality so far.
The problem has been temporarily worked around, but we are still waiting for a fix in the SDK.

@linziyiwj
Copy link
Author

Many of our users have recently reported app hangs on launch, and we found that this issue is the root cause. So we replaced -[FBSDKAppEventsDeviceInfo encodedDeviceInfo] with our method that returns nil using method swizzling. The deadlock issue has been resolved and there are no problems with Facebook login and share functionality so far. The problem has been temporarily worked around, but we are still waiting for a fix in the SDK.

YES, we adopted the same hook method two weeks ago, so far, the same lag does not appear online

@MahaGhanem
Copy link

Any solutions?

@MahaGhanem
Copy link

@gonsee how to make the work around ?
can you please mention the steps?

@gonsee
Copy link

gonsee commented Feb 22, 2023

@MahaGhanem Something like this

@class FBSKDAppEventsDeviceInfo

@interface FBSKDAppEventsDeviceInfo (Workaround)
@end
@import Foundation;
@import FBSDKCoreKit;
@import ObjectiveC.runtime;

@implementation FBSDKAppEventsDeviceInfo (Workaround)

+ (void)load
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];

        SEL originalSelector = @selector(encodedDeviceInfo);
        SEL swizzledSelector = @selector(xxx_swizzled_encodedDeviceInfo);

        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);

        IMP originalImp = method_getImplementation(originalMethod);
        IMP swizzledImp = method_getImplementation(swizzledMethod);

        class_replaceMethod(class,
                swizzledSelector,
                originalImp,
                method_getTypeEncoding(originalMethod));
        class_replaceMethod(class,
                originalSelector,
                swizzledImp,
                method_getTypeEncoding(swizzledMethod));
    });
}

- (nullable NSString *)xxx_swizzled_encodedDeviceInfo
{
    return nil;
}

@end

@su855297
Copy link

su855297 commented May 3, 2023

same problem

截圖 2023-04-28 下午2 56 03
截圖 2023-04-28 下午2 55 54

@onursahindur
Copy link

onursahindur commented Aug 3, 2023

Same problem here.

Suddenly after something I do not know why (our guess updating pods), magic happened, our application started to hang on main thread after 2-3 seconds on app open.

Somehow, after some kill&open actions, app may start to work without hanging on main thread.

Since it is so hard to regenerate the issue, we started building&running again on same device.
The most deep information what I found starts here, on one of test, app started to hang on debug mode.

It showed me the exact screen as @su855297 pointed out before me on May 3.

I tried to swizzle as @gonsee pointed out, however I cannot manage to do it.

@gonsee ,
Did you solve the issue?
If not when I try to swizzle it does not compile giving
Cannot define category for undefined class 'FBSDKAppEventsDeviceInfo'
Can you be more specific about how can we swizzle?

The errors are like this;

Screenshot 2023-08-03 at 18 29 54 Screenshot 2023-08-03 at 18 30 06

Thanks.

@gonsee
Copy link

gonsee commented Aug 4, 2023

@onursahindur I can't figure out what is the problem on your code, but the original issue may have been fixed according to this commit log. 6563a8c
I haven't tried to update the SDK yet, so I can't confirm if the new version really solves the issue.

@onursahindur
Copy link

@gonsee Thank you for your response, I really appreciate.
Which SDK are you currently on?
We will lock to that version of SDK.

@gonsee
Copy link

gonsee commented Aug 6, 2023

@onursahindur We are currently on 15.1.0.
The fixing commit seems to be included in version 16.1.1 or newer.
I would appreciate it if you could share the results after trying the new version.

@su855297
Copy link

su855297 commented Aug 7, 2023

We finally resolved it using this method

image

replace FBSDKAppEventsDeviceInfo with our custom function encodedDeviceInfo.

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

No branches or pull requests