Hello, thanks for you reply!
As I've said, the crashes above have been received on our crash reporter from our Safari App Extension which is running in production on our users' machines. I haven't been able to reproduce any crash locally on my machine. Also, I just suspect that the crashes and the "No context" logs are the same issue, but I don't know this for certain.
With that in mind, I sent a bug submission through Feedback Assistant about this. The submission includes 30 user crashes (from the crash reporter service) that may be relevant, but no crashes from my machine. I've also added a few screenshots.
The feedback submission number is FB14156523.
Post
Replies
Boosts
Views
Activity
In addition, our crash reporting service has recently received many crash logs for the Safari App Extension in question. The crashes are esoteric (no application code, only library code), they don't reproduce locally and I haven't found any information about them online, so I don't know what causes them. But they also happen only on macOS Sonoma 14 for our users and some libray calls from the stack traces mention the word "context", so this makes me think that the two issues are related. I've included some crash snippets below:
Crashed Thread: 3 Dispatch queue: com.apple.NSXPCConnection.user.endpoint
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000002
Exception Codes: 0x0000000000000001, 0x0000000000000002
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [74701]
VM Region Info: 0x2 is not in any region. Bytes before following region: 4340744190
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102ba8000-102c08000 [ 384K] r-x/r-x SM=COW /Applications/myApp.app/Contents/PlugIns/myExtension.appex/Contents/MacOS/myExtension
Thread 3 Crashed:: Dispatch queue: com.apple.NSXPCConnection.user.endpoint
0 libobjc.A.dylib 0x18eeb1c34 objc_msgSend + 52
1 SafariServices 0x1b4925910 -[_SFSafariExtensionContextManager addContext:] + 248
2 SafariServices 0x1b49328d0 -[SFSafariExtensionHandler beginRequestWithExtensionContext:] + 124
3 ExtensionFoundation 0x1eadccbb0 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke.102 + 212
4 CoreFoundation 0x18f346694 __invoking___ + 148
5 CoreFoundation 0x18f346514 -[NSInvocation invoke] + 428
6 Foundation 0x19045c69c __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 16
7 Foundation 0x19045ad3c -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 520
8 Foundation 0x19045a698 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_3 + 188
9 libxpc.dylib 0x18ef96764 _xpc_connection_reply_callout + 116
10 libxpc.dylib 0x18ef9665c _xpc_connection_call_reply_async + 80
11 libdispatch.dylib 0x18f0d6468 _dispatch_client_callout3 + 20
12 libdispatch.dylib 0x18f0f3fc8 _dispatch_mach_msg_async_reply_invoke + 344
13 libdispatch.dylib 0x18f0dd898 _dispatch_lane_serial_drain + 368
14 libdispatch.dylib 0x18f0de578 _dispatch_lane_invoke + 432
15 libdispatch.dylib 0x18f0e92d0 _dispatch_root_queue_drain_deferred_wlh + 288
16 libdispatch.dylib 0x18f0e8b44 _dispatch_workloop_worker_thread + 404
17 libsystem_pthread.dylib 0x18f28300c _pthread_wqthread + 288
18 libsystem_pthread.dylib 0x18f281d28 start_wqthread + 8
And another crash snippet:
Crashed Thread: 3 Dispatch queue: com.apple.NSXPCConnection.user.endpoint
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes: 0x0000000000000001, 0x0000000000000020
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [30310]
VM Region Info: 0x20 is not in any region. Bytes before following region: 4329406432
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 1020d8000-102138000 [ 384K] r-x/r-x SM=COW /Applications/myApp.app/Contents/PlugIns/myExtension.appex/Contents/MacOS/myExtension
Thread 3 Crashed:: Dispatch queue: com.apple.NSXPCConnection.user.endpoint
0 libobjc.A.dylib 0x19d303fbc objc_retain + 16
1 SafariServices 0x1c2d79910 -[_SFSafariExtensionContextManager addContext:] + 248
2 SafariServices 0x1c2d868d0 -[SFSafariExtensionHandler beginRequestWithExtensionContext:] + 124
3 ExtensionFoundation 0x1f9220bb0 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke.102 + 212
4 CoreFoundation 0x19d79a694 __invoking___ + 148
5 CoreFoundation 0x19d79a514 -[NSInvocation invoke] + 428
6 Foundation 0x19e8b069c __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 16
7 Foundation 0x19e8aed3c -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 520
8 Foundation 0x19e8ae698 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_3 + 188
9 libxpc.dylib 0x19d3ea764 _xpc_connection_reply_callout + 116
10 libxpc.dylib 0x19d3ea65c _xpc_connection_call_reply_async + 80
11 libdispatch.dylib 0x19d52a468 _dispatch_client_callout3 + 20
12 libdispatch.dylib 0x19d547fc8 _dispatch_mach_msg_async_reply_invoke + 344
13 libdispatch.dylib 0x19d531898 _dispatch_lane_serial_drain + 368
14 libdispatch.dylib 0x19d532578 _dispatch_lane_invoke + 432
15 libdispatch.dylib 0x19d53d2d0 _dispatch_root_queue_drain_deferred_wlh + 288
16 libdispatch.dylib 0x19d53cb44 _dispatch_workloop_worker_thread + 404
17 libsystem_pthread.dylib 0x19d6d700c _pthread_wqthread + 288
18 libsystem_pthread.dylib 0x19d6d5d28 start_wqthread + 8
jaroslavqwerty, I don't think the application would flood the system with popups if it would always return .replace. The system popup will only appear if the system extension last requested on the system is of a different version to the one you are requesting now. The delegate method wouldn't be called anyway if the versions are the same, as mentioned in the method documentation.
I always return .replace in my extension. In my experience, it seems that nothing happens to the currently loaded extension if you make more activationRequests after the first one.
Another reason you might want to always answer with .replace is that an application can uninstall the corresponding system extension loaded on the system only if it has the same version as the system extension embedded in the application. So choosing not to replace the extension might mean you end up without any way of uninstalling the given system extension (as far as I can tell).
If you are seeing a different behaviour as described in this comment, please make sure that developer mode is turned off (run systemextensionsctl developer off in a terminal)
I've filed a suggestion through Feedback Assistant about this. The submission number is FB8978333.
I've submitted a suggestion with a similar description as this post through Feedback Assistant on the 11th of December 2020. The suggestion number is FB8936914. It has not received any response as of now.