Hello,
Sometimes I need to send a message via sendMessageToProvider to tell the proxy service in NetworkExtension that it should be restarted
It looks like this:
self.sendMessageToProvider("restart"...) { resp
if resp != "ok" {
// stopVPNTunnel()...
}
}
Then accept the request in NetworkExtension, which looks like:
open override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)?) {
reasserting = true
setTunnelNetworkSettings(nil) { error in
startTunnel() {
reasserting = false
completionHandler("ok"...)
}
}
}
But NetworkExtension crashes occasionally and I spent a long time looking for the cause but found nothing. Where should I start?
Date/Time: 2023-06-17 08:01:38.2104 +0800
Launch Time: 2023-06-17 08:01:06.5706 +0800
OS Version: iPhone OS 16.5 (20F66)
Release Type: User
Baseband Version: 3.70.01
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000022a76b2d0
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [38097]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libxpc.dylib 0x000000022a76b2d0 _xpc_api_misuse + 80 (debug.c:71)
1 libxpc.dylib 0x000000022a75c918 xpc_dictionary_set_value + 128 (dictionary.c:1849)
2 libxpc.dylib 0x000000022a75d888 xpc_dictionary_set_data + 60 (dictionary.c:1983)
3 NetworkExtension 0x00000001e1d69978 __35-[NEIPC handleMessage:withHandler:]_block_invoke + 112 (NEIPC.m:47)
4 PacketTunnel 0x0000000104f5be7c thunk for @escaping @callee_unowned @convention(block) (@unowned NSData?) -> () + 60 (<compiler-generated>:0)
5 PacketTunnel 0x0000000104f5bd4c MyPacketTunnelProvider.responseMessage(msg:completionHandler:) + 96 (MyPacketTunnelProvider.swift:188)
6 PacketTunnel 0x0000000104f5bd4c closure #1 in closure #1 in MyPacketTunnelProvider.handleAppMessage(_:completionHandler:) + 244 (MyPacketTunnelProvider.swift:178)
7 PacketTunnel 0x0000000104f5d808 closure #1 in closure #1 in closure #1 in MyPacketTunnelProvider.startTunnel(config:completionHandler:) + 12 (MyPacketTunnelProvider.swift:54)
8 PacketTunnel 0x0000000104f5d808 partial apply for closure #1 in closure #1 in closure #1 in MyPacketTunnelProvider.startTunnel(config:completionHandler:) + 32 (<compiler-generated>:0)
9 PacketTunnel 0x0000000104f5f720 closure #1 in closure #1 in xxxx.start(config:packetFlow:startCompletion:stoppedCompletion:) + 188 (xxxx.swift:140)
10 PacketTunnel 0x0000000104f5b4f0 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
11 libdispatch.dylib 0x00000001d1e21320 _dispatch_call_block_and_release + 32 (init.c:1518)
12 libdispatch.dylib 0x00000001d1e22eac _dispatch_client_callout + 20 (object.m:560)
13 libdispatch.dylib 0x00000001d1e316a4 _dispatch_main_queue_drain + 928 (queue.c:7794)
14 libdispatch.dylib 0x00000001d1e312f4 _dispatch_main_queue_callback_4CF + 44 (queue.c:7954)
15 CoreFoundation 0x00000001ca9ebc28 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
16 CoreFoundation 0x00000001ca9cd560 __CFRunLoopRun + 1992 (CFRunLoop.c:3147)
17 CoreFoundation 0x00000001ca9d23ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
18 Foundation 0x00000001c4c52fd4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
19 Foundation 0x00000001c4c52e68 -[NSRunLoop(NSRunLoop) run] + 64 (NSRunLoop.m:398)
20 libxpc.dylib 0x000000022a761678 _xpc_objc_main + 496 (main.m:246)
21 libxpc.dylib 0x000000022a763924 xpc_main + 156 (init.c:1258)
22 Foundation 0x00000001c4c9a930 -[NSXPCListener resume] + 312 (NSXPCListener.m:460)
23 PlugInKit 0x00000001f1177e90 -[PKService run] + 356 (PKService.m:197)
24 PlugInKit 0x00000001f1164628 +[PKService main] + 536 (PKService.m:119)
25 PlugInKit 0x00000001f116393c +[PKService _defaultRun:arguments:] + 16 (PKService.m:244)
26 ExtensionFoundation 0x00000001d7fa5540 EXExtensionMain + 252 (EXExtensionMain.m:34)
27 Foundation 0x00000001c4cdee00 NSExtensionMain + 204 (NSExtensionMain.m:21)
28 dyld 0x00000001e9ed2dec start + 2220 (dyldMain.cpp:1165)
Post
Replies
Boosts
Views
Activity
Since upgrading the system to iOS 16.5+, when the device storage space is seriously insufficient, the VPN will be forcibly disconnected and stopTunnel will not be called.
A few colleagues and I tested products from several different companies and all had the same problem. How should we get around it?
23:01:26.000901+0800 PacketTunnel nw_protocol_tcp_log_summary [C10.1.1:3]
[5663B3D8-E097-4FE1-8E53-B56B45A8F902 <private>:49887<-><private>:443]
Init: 1, Conn_Time: 44.751ms, SYNs: 1, WR_T: 0/0, RD_T: 0/0, TFO: 0/0/0, ECN: 0/0/0, TS: 1, TSO: 0
rtt_cache: process, rtt_upd: 4, rtt: 20.875ms, rtt_var: 12.000ms rtt_nc: 38.593ms, rtt_var_nc: 21.437ms base rtt: 8ms
ACKs-compressed: 0, ACKs delayed: 0 delayed ACKs sent: 0
23:01:26.000935+0800 PacketTunnel nw_protocol_tcp_disconnect [C10.1.1:3] send disconnect to input protocol
23:01:26.000972+0800 PacketTunnel nw_flow_disconnected [C10 IPv4#10918632:443 cancelled parent-flow ((null))] Output protocol disconnected
23:01:26.000999+0800 PacketTunnel nw_endpoint_handler_cancel [C10.1 Hostname#099ac075:443 ready resolver (satisfied (Path is satisfied), interface: en0[802.11], scoped, ipv4, dns)]
23:01:26.001223+0800 PacketTunnel nw_association_schedule_deactivation <nw_association Hostname#099ac075:443> will become dormant after 10000ms of inactivity
23:01:26.001247+0800 PacketTunnel nw_endpoint_handler_cancel [C10.1.1 IPv4#10918632:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0[802.11], scoped, ipv4, dns)]
23:01:26.001336+0800 PacketTunnel nw_association_schedule_deactivation <nw_association IPv4#10918632:443> will become dormant after 10000ms of inactivity
23:01:26.001365+0800 PacketTunnel nw_protocol_tcp_disconnect [C10.1.1:3] input protocol initiated disconnect
23:01:26.001427+0800 PacketTunnel nw_connection_report_state_with_handler_on_nw_queue [C10] reporting state cancelled
23:01:26.001527+0800 PacketTunnel Connection 10: done
23:01:26.001573+0800 PacketTunnel [C10 Hostname#099ac075:443 tcp, url hash: f279b86d, tls, definite, attribution: developer] dealloc
23:01:26.001650+0800 PacketTunnel tcp_output [C10.1.1:3] flags=[F.] seq=2497755765, ack=631888768, win=2048 state=FIN_WAIT_1 rcv_nxt=631888768, snd_una=2497755734
23:01:26.022263+0800 PacketTunnel tcp_input [C10.1.1:3] flags=[F.] seq=631888768, ack=2497755765, win=245 state=FIN_WAIT_1 rcv_nxt=631888768, snd_una=2497755734
23:01:26.022464+0800 PacketTunnel tcp_output [C10.1.1:3] flags=[F.] seq=2497755765, ack=631888769, win=2048 state=CLOSING rcv_nxt=631888769, snd_una=2497755765
23:01:36.014524+0800 PacketTunnel nw_association_schedule_deactivation_block_invoke <nw_association Hostname#099ac075:443> becoming dormant
23:01:36.014708+0800 PacketTunnel nw_association_schedule_deactivation_block_invoke <nw_association IPv4#10918632:443> becoming dormant
23:01:44.587233+0800 runningboardd Requesting plugIn hold for <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"x.y.z.Shortcuts",
"x.y.z",
"x.y.z.PacketTunnel"
)}>>
23:01:44.587261+0800 runningboardd skipping plugin hold for termination request without bundle ID or beforeTranslocationBundlePath <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"x.y.z.Shortcuts",
"x.y.z",
"x.y.z.PacketTunnel"
)}>>
23:01:44.587543+0800 runningboardd Acquiring assertion targeting system from originator [osservice<com.apple.mobile.cache_delete_app_container_caches>:400] with description <RBSAssertionDescriptor| "CacheDeleteAppContainerCaches requesting termination assertion for x.y.z" ID:31-400-9890 target:system attributes:[
<RBSPreventLaunchLimitation| <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"x.y.z.Shortcuts",
"x.y.z",
"x.y.z.PacketTunnel"
)}>> allow:(null)>
]>
23:01:44.588473+0800 runningboardd Executing termination request for: <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"x.y.z.Shortcuts",
"x.y.z",
"x.y.z.PacketTunnel"
)}>>
23:01:44.590075+0800 runningboardd [xpcservice<x.y.z.PacketTunnel([osservice<com.apple.neagent-ios>:998:998])>:1455] Terminating with context: <RBSTerminateContext| code:0xBADDD15C explanation:CacheDeleteAppContainerCaches requesting termination assertion for x.y.z reportType:None maxTerminationResistance:NonInteractive attrs:[
<RBSPreventLaunchLimitation| <RBSProcessPredicate <RBSProcessBundleIdentifiersPredicate| {(
"x.y.z.Shortcuts",
"x.y.z",
"x.y.z.PacketTunnel"
)}>> allow:(null)>
]>
23:01:44.591253+0800 neagent Extension x.y.z.PacketTunnel died unexpectedly
I'm researching to develop a VPN application on tvOS 17.0, but even if I set the dev target version to 17.0, it still prompts me that the API is not available.
'NEPacketTunnelProvider' is only available in tvOS 17.
0 or newer
I have 2 xcodes installed on my computer, I tried switching to sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer, but it still doesn't work. Is there anything else I need to set?