Skip to content

Main thread stalled in Functions code  #14230

Open
@jesus-mg-ios

Description

Description

When I call the method to invoke a cloud function from a detached Task in the app extension, the function is called from the main thread. Sometimes, it gets stuck, causing the app extension to freeze.

dispatchGroup.notify(queue: .main) {
      let context = FunctionsContext(authToken: authToken,
                                     fcmToken: self.messaging?.fcmToken,
                                     appCheckToken: appCheckToken,
                                     limitedUseAppCheckToken: limitedUseAppCheckToken)
      completion(context, error)
    } 
Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00000001d91de788 in mach_msg2_trap ()
#1	0x00000001d91e1e98 in mach_msg2_internal ()
#2	0x00000001d91e1db0 in mach_msg_overwrite ()
#3	0x00000001d91e1bfc in mach_msg ()
#4	0x0000000212810f40 in _xpc_pipe_mach_msg ()
#5	0x0000000212810908 in _xpc_send_serializer ()
#6	0x00000002128106c4 in _xpc_pipe_simpleroutine ()
#7	0x00000001a2c9ee1c in ___os_activity_stream_reflect_block_invoke ()
#8	0x000000018f963fa8 in _dispatch_client_callout ()
#9	0x000000018f9679f0 in _dispatch_block_invoke_direct ()
#10	0x000000018f9678c4 in dispatch_block_perform ()
#11	0x00000001a2c9e844 in _os_activity_stream_reflect ()
#12	0x00000001a2ca3be8 in _os_log_impl_stream ()
#13	0x00000001a2c9497c in _os_log_impl_flatten_and_send ()
#14	0x00000001a2c913e0 in _os_log ()
#15	0x00000001a2c96084 in _os_log_debug_impl ()
#16	0x00000001890b49e0 in -[NSURLSessionTask resume] ()
#17	0x0000000104c55b64 in -[GTMSessionFetcher beginFetchMayDelay:mayAuthorize:mayDecorate:] at gtm-session-fetcher/Sources/Core/GTMSessionFetcher.m:957
#18	0x0000000104c51c88 in -[GTMSessionFetcher beginFetchWithCompletionHandler:] at checkouts/gtm-session-fetcher/Sources/Core/GTMSessionFetcher.m:461
#19	0x0000000104c95894 in Functions.callFunction(url:withObject:options:timeout:context:completion:) at firebase-ios-sdk/FirebaseFunctions/Sources/Functions.swift:469
#20	0x0000000104c94240 in closure #1 in Functions.callFunction(name:withObject:options:timeout:completion:) at SourcePackages/checkouts/firebase-ios-sdk/FirebaseFunctions/Sources/Functions.swift:375
#21	0x0000000104c943a4 in partial apply for closure #1 in Functions.callFunction(name:withObject:options:timeout:completion:) ()
#22	0x0000000104ca3584 in closure #4 in FunctionsContextProvider.getContext(options:_:) at firebase-ios-sdk/FirebaseFunctions/Sources/Internal/FunctionsContext.swift:100
#23	0x0000000104c95eb8 in thunk for @escaping @callee_guaranteed () -> () ()
#24	0x000000018f962248 in _dispatch_call_block_and_release ()
#25	0x000000018f963fa8 in _dispatch_client_callout ()
#26	0x000000018f972a34 in _dispatch_main_queue_drain ()
#27	0x000000018f97264c in _dispatch_main_queue_callback_4CF ()
#28	0x0000000187c2dbbc in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#29	0x0000000187c2a1b0 in __CFRunLoopRun ()
#30	0x0000000187c7c274 in CFRunLoopRunSpecific ()
#31	0x00000001867e2b48 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#32	0x00000001867ded10 in -[NSRunLoop(NSRunLoop) run] ()
#33	0x0000000212802e74 in _xpc_objc_main ()
#34	0x00000002128053e0 in _xpc_main ()
#35	0x00000002128055c0 in xpc_main ()
#36	0x00000001869b0438 in -[NSXPCListener resume] ()
#37	0x00000001b88d144c in ___lldb_unnamed_symbol1074 ()
#38	0x00000001b88d12d8 in ___lldb_unnamed_symbol1073 ()
#39	0x00000001b88d0f94 in ___lldb_unnamed_symbol1067 ()
#40	0x00000001b88d17a8 in ___lldb_unnamed_symbol1078 ()
#41	0x0000000196f4b724 in EXExtensionMain ()
#42	0x0000000186a76f48 in NSExtensionMain ()
#43	0x00000001ade37de8 in start ()

Reproducing the issue

No response

Firebase SDK Version

10.25.0

Xcode Version

16.1

Installation Method

Swift Package Manager

Firebase Product(s)

Functions

Targeted Platforms

App Extensions

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions