Jon_Ogden
(Jon Ogden)
November 30, 2020, 1:44pm
#1
I’ve come across a rather show stopping bug with API2.0 and UDPSockets. I’ve detailed it in this feedback report:
feedback://showreport?report_id=62875
Basically if you have a UDPSocket, it works great until the device is locked. If you attempt to use the UDPSocket after the device is unlocked, the app will crash hard. Exception handling doesn’t catch it. Calling UDPSocket.Write is what triggers the crash.
And this has to be on an actual device. The simulator doesn’t show this behavior.
DerkJ
(DerkJ)
November 30, 2020, 2:00pm
#2
Did you add NSLocalNetworkUsageDescription to your plist file ?
Jon_Ogden
(Jon Ogden)
November 30, 2020, 2:06pm
#3
I’ve never added anything to any plist file. I would assume Xojo should be doing all that. The app requests access to connect to devices on my network and I give it permission. So that should not be the problem. And the socket works fine when the app is open and the screen unlocked. It’s after locking and then unlocking that the problem occurs.
Jon_Ogden
(Jon Ogden)
November 30, 2020, 2:11pm
#4
And I don’t think it’s entitlements either. When I tried to access photos without the entitlement enabled, the app would hard crash. But iOS would generate a crash report with the message that I was trying to access photos. I’m not seeing any crash reports from iOS here.
DerkJ
(DerkJ)
November 30, 2020, 2:41pm
#5
Xojo is not doing every plist entry. If you want you can add a feedback request to add all required plist entries for the classes.
I’m sure apple closes the socket when the screen locks. They do all kinds of stuff to keep the battery level up as much as they can. Keeping sockets open is a thing that you must be careful with. You can use the App.Deactivated event to close sockets. Then reopen/connect or bind on App.Activate
Jon_Ogden
(Jon Ogden)
November 30, 2020, 3:05pm
#6
Problem is, the socket is not closed - at least not what Xojo sees. Here’s some of my code in a write method of a subclass:
If Not MyUDPSocket.IsConnected Then
System.DebugLog "UDPSocket not connected - Connecting."
MyUDPSocket.Connect
If Not MyUDPSocket.JoinMulticastGroup(UDPGroupIP) Then
System.DebugLog "Could not join the UDP group - Leaving."
MyUDPSocket.Close
Return
End If
End
UDPSent = True
system.debuglog("UDP - Writing to UDP Socket: "+txt)
If MyUDPSocket = Nil Then
System.DebugLog "UDPSocket is NIL"
End If
If Not MyUDPSocket.IsConnected Then
System.DebugLog "UDPSocket is not connected."
End If
System.DebugLog "UDP Group: "+UDPGroupIP
System.DebugLog txt
Try
MyUDPSocket.Write(UDPGroupIP,txt+EndOfLine)
Catch
Try
System.DebugLog "Exception - Trying again"
MyUDPSocket.Connect
Call MyUDPSocket.JoinMulticastGroup(UDPGroupIP)
System.DebugLog "Trying the write again."
MyUDPSocket.Write(UDPGroupIP,txt+EndOfLine)
Catch
System.DebugLog "Second Exception."
End Try
End Try
UDPSent = False
End
The DebugLog statements and several IF/Then blocks are all in there trying to figure out where things go awry. Xojo never sees the socket as closed. And the Try/Catch blocks don’t catch the exception/crash. As soon as the write method is called the app crashes.
So I agree that something is being shut down. I can see it happening in the console. Problem is I don’t want it shut down. I still want the app to be able to receive UDP packets when the screen is locked. Minimizing the app by switching back to Springboard and opening another app and then going back into the app doesn’t cause the same problem. It’s a lock that does.
DerkJ
(DerkJ)
November 30, 2020, 4:07pm
#7
Jon_Ogden:
MyUDPSocket.Connect
You cannot just connect and expect it to work. Apple can stop port bindings if the port is already used or inaccessible (even if the batery is low etc). It’s best to check if the isconnected returns true and if the port is actually set only if these conditions are valid, you can join the group and/or write.
DerkJ
(DerkJ)
November 30, 2020, 4:09pm
#8
Perhaps:
If upd.isconnected and udp.port > 0 then
// join the group and/or write
End if
Jon_Ogden
(Jon Ogden)
November 30, 2020, 4:21pm
#9
Uh, I think you missed a lot of my code. See below. There’s also code I didn’t show where I set the port, etc. I’ve used this code without issues for years on the desktop It does work and works fine UNTIL THE SCREEN IS LOCKED AND THEN UNLOCKED. Xojo thinks the socket is still connected. So it does me no good to check if the socket is connected as it is connected! And the port has been set back when the socket is first setup.
Jason_King
(Jason King)
November 30, 2020, 4:35pm
#10
To continue running while the phone is locked I think you need to enable background tasks for your app. I’m not sure if that will work in Xojo.
The best approach is likely to destroy and rebuild the connection in the deactivate and activate events so you definitely have a working connection
Jason_King
(Jason King)
November 30, 2020, 4:36pm
#11
Can you open the device console in Xcode and cause the crash? There may be messages in the console explaining what is happening/going wrong
Jon_Ogden
(Jon Ogden)
November 30, 2020, 4:38pm
#12
Here is the console log from the test app I built and included with the bug report. This is basically everything reported when the screen locks.
debug 16:27:12.984848-0600 TestApp *|machport|* <BSMachPortTransferableSendRight: 0x2823a32a0; usable: YES; (6113:400b:send_mv xpcCode) from (62:82fab:send_mv make) from (62:82fab:receive init)> -> (<NSThread: 0x2836b7380>{number = 12, name = (null)}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c3f3c4 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 238532
2 BaseBoard 0x00000001a2c16c6c BSCreateDeserializedBSXPCEncodableObjectFromXPCDictionary + 164
3 BaseBoard 0x00000001a2c16ba8 BSCreateDeserializedBSXPCEncodableObjectFromXPCDictionaryWithKey + 40
4 BaseBoard 0x00000001a2c08314 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 13076
5 FrontBoardServices 0x00000001ad9ef144 E22FDD4D-3F20-3D60-A568-E82AE2B4151C + 377156
6 BaseBoard 0x00000001a2c16c6c BSCreateDeserializedBSXPCEncodableObjectFromXPCDictionary + 164
7
debug 16:27:12.984945-0600 TestApp *|machport|* <BSMachPortTransferableSendRight: 0x282385040; usable: YES; (6113:400b:send_mv copy) from (6113:400b:send_mv xpcCode) from (62:82fab:send_mv make) from (62:82fab:receive init)> -> (<NSThread: 0x2836b7380>{number = 12, name = (null)}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c089ec 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 14828
2 BaseBoard 0x00000001a2c09330 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 17200
3 BaseBoard 0x00000001a2c08b40 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 15168
4 BaseBoard 0x00000001a2c0833c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 13116
5 FrontBoardServices 0x00000001ad9ef144 E22FDD4D-3F20-3D60-A568-E82AE2B4151C + 377156
6 BaseBoard 0x00000001a2c16c6c BSCreateDeserializedBSXPCEncodableObjectFromXPCDictionary + 164
7 BaseBoard
info 16:27:12.985184-0600 TestApp sceneOfRecord: sceneID: sceneID:com.justaddsoftware.udptest-default persistentID: F08AA976-B8C5-4814-8F65-AD142CCDB261
info 16:27:12.989787-0600 TestApp Deactivation reason added: 12; deactivation reasons: 0 -> 4096; animating application lifecycle event: 0
info 16:27:12.990068-0600 TestApp Deactivation reason added: 11; deactivation reasons: 4096 -> 6144; animating application lifecycle event: 0
info 16:27:12.991461-0600 TestApp <private>: Will add backgroundTask with taskName: <private>, expirationHandler: (null)
info 16:27:12.991506-0600 TestApp <private>: Created background task <private>. Assertion will be assigned soon
info 16:27:12.991552-0600 TestApp <private>: Creating new assertion since assertion is nil
info 16:27:12.991595-0600 TestApp <private>: Created new assertion <BKSProcessAssertion: 0x2800b9040>
info 16:27:12.991779-0600 TestApp Acquiring assertion: <RBSAssertionDescriptor| "Shared Background Assertion 2 for com.justaddsoftware.udptest" ID:(null) target:6113>
debug 16:27:12.992082-0600 TestApp Adding assertion 32-6113-42014 to dictionary
info 16:27:12.999089-0600 TestApp <private>: Will add backgroundTask with taskName: <private>, expirationHandler: <__NSStackBlock__: 0x16dafdd70>
info 16:27:13.005327-0600 TestApp <private>: Created background task <private>. Assertion will be assigned soon
info 16:27:13.005376-0600 TestApp <private>: Reusing assertion <BKSProcessAssertion: 0x2800b9040>
debug 16:27:13.018888-0600 TestApp *|machport|* <BSMachPortReceiveRight: 0x2823a21a0; usable: YES; (6113:630b:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c3f8f0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 239856
2 BaseBoard 0x00000001a2c0c0a8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 28840
3 BaseBoard 0x00000001a2c61cc8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380104
4 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
5 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
6 BaseBoard 0x00000001a2c095d8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 17880
7 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDictionary + 72
8 BaseBoard
debug 16:27:13.019126-0600 TestApp *|machport|* <BSMachPortTransferableSendRight: 0x2823985a0; usable: YES; (6113:630b:send_mv make) from (6113:630b:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c0cd54 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 32084
2 BaseBoard 0x00000001a2c0c0c8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 28872
3 BaseBoard 0x00000001a2c61cc8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380104
4 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
5 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
6 BaseBoard 0x00000001a2c095d8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 17880
7 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDict
debug 16:27:13.019356-0600 TestApp *|machport|* invalidate <BSMachPortTransferableSendRight:0x2823985a0 usable=YES (6113:630b:send_mv make) from (6113:630b:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c3f16c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 237932
1 BaseBoard 0x00000001a2c40834 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 243764
2 BaseBoard 0x00000001a2c3f444 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 238660
3 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDictionary + 72
4 BaseBoard 0x00000001a2c169e4 BSCreateSerializedBSXPCEncodableObject + 64
5 BaseBoard 0x00000001a2c16b34 BSSerializeBSXPCEncodableObjectToXPCDictionaryWithKey + 68
6 BaseBoard 0x00000001a2c61cdc 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380124
7 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9
debug 16:27:13.300539-0600 TestApp *|machport|* invalidate <BSMachPortReceiveRight:0x2823a21a0 usable=YES (6113:630b:receive init)> -> (<NSThread: 0x2836bdd40>{number = 13, name = (null)}) (
0 BaseBoard 0x00000001a2c3f16c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 237932
1 BaseBoard 0x00000001a2c09df0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 19952
2 BaseBoard 0x00000001a2c09734 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 18228
3 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
4 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
5 BaseBoard 0x00000001a2c630b0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 385200
6 libdispatch.dylib 0x000000019e28724c 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 8780
7 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
8 libdispatch.dylib
debug 16:27:13.304554-0600 TestApp *|machport|* <BSMachPortReceiveRight: 0x2823bd000; usable: YES; (6113:a00f:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c3f8f0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 239856
2 BaseBoard 0x00000001a2c0c0a8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 28840
3 BaseBoard 0x00000001a2c61cc8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380104
4 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
5 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
6 BaseBoard 0x00000001a2c095d8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 17880
7 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDictionary + 72
8 BaseBoard
debug 16:27:13.307179-0600 TestApp *|machport|* <BSMachPortTransferableSendRight: 0x2823bcf60; usable: YES; (6113:a00f:send_mv make) from (6113:a00f:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c0b494 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 25748
1 BaseBoard 0x00000001a2c0cd54 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 32084
2 BaseBoard 0x00000001a2c0c0c8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 28872
3 BaseBoard 0x00000001a2c61cc8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380104
4 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
5 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
6 BaseBoard 0x00000001a2c095d8 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 17880
7 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDict
debug 16:27:13.311619-0600 TestApp *|machport|* invalidate <BSMachPortTransferableSendRight:0x2823bcf60 usable=YES (6113:a00f:send_mv make) from (6113:a00f:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c3f16c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 237932
1 BaseBoard 0x00000001a2c40834 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 243764
2 BaseBoard 0x00000001a2c3f444 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 238660
3 BaseBoard 0x00000001a2c16a48 BSSerializeBSXPCEncodableObjectToXPCDictionary + 72
4 BaseBoard 0x00000001a2c169e4 BSCreateSerializedBSXPCEncodableObject + 64
5 BaseBoard 0x00000001a2c16b34 BSSerializeBSXPCEncodableObjectToXPCDictionaryWithKey + 68
6 BaseBoard 0x00000001a2c61cdc 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 380124
7 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9
debug 16:27:13.339870-0600 TestApp Received message from server: async_didChangeInheritances:completion:
debug 16:27:13.340151-0600 TestApp didChangeInheritances: <RBSInheritanceChangeSet: 0x282384e40>
debug 16:27:13.353099-0600 TestApp *|machport|* invalidate <BSMachPortReceiveRight:0x2823bd000 usable=YES (6113:a00f:receive init)> -> (<NSThread: 0x2836b9c80>{number = 14, name = (null)}) (
0 BaseBoard 0x00000001a2c3f16c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 237932
1 BaseBoard 0x00000001a2c09df0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 19952
2 BaseBoard 0x00000001a2c09734 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 18228
3 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
4 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
5 BaseBoard 0x00000001a2c630b0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 385200
6 libdispatch.dylib 0x000000019e28724c 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 8780
7 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
8 libdispatch.dylib
info 16:27:13.353739-0600 TestApp <private>: Ending background task with UIBackgroundTaskIdentifier: 5
info 16:27:13.353794-0600 TestApp <private>: Ending task with identifier 5 and description: <private>, _expireHandler: <__NSMallocBlock__: 0x282db2c40>
info 16:27:13.353842-0600 TestApp <private>: Decrementing reference count for assertion used by background task with identifier 5: <private>
debug 16:27:13.357014-0600 TestApp *|machport|* invalidate <BSMachPortTransferableSendRight:0x2823a32a0 usable=YES (6113:400b:send_mv xpcCode) from (62:82fab:send_mv make) from (62:82fab:receive init)> -> (<NSThread: 0x2836b41c0>{number = 1, name = main}) (
0 BaseBoard 0x00000001a2c3f16c 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 237932
1 BaseBoard 0x00000001a2c09df0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 19952
2 BaseBoard 0x00000001a2c09704 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 18180
3 BaseBoard 0x00000001a2c626a0 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 382624
4 libdispatch.dylib 0x000000019e288db0 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 15792
5 libdispatch.dylib 0x000000019e297428 3277BF1E-B994-3609-9B30-E0186BBF3C25 + 74792
6 BaseBoard 0x00000001a2c085a4 196F8707-8DAF-3D1D-9AD7-D4BED13A52E4 + 13732
7 FrontBoardServices 0x00000001ad9eed90 E22FDD4D-3F
info 16:27:13.411159-0600 TestApp <private>: Ending background task with UIBackgroundTaskIdentifier: 4
info 16:27:13.411207-0600 TestApp <private>: Ending task with identifier 4 and description: <private>, _expireHandler: (null)
info 16:27:13.411257-0600 TestApp <private>: Decrementing reference count for assertion used by background task with identifier 4: <private>
info 16:27:13.411351-0600 TestApp <private>: Will invalidate assertion: <BKSProcessAssertion: 0x2800b9040> for task identifier: 4
info 16:27:21.504542-0600 TestApp Deactivation reason removed: 11; deactivation reasons: 6176 -> 4128; animating application lifecycle event: 1
debug 16:27:21.504740-0600 TestApp Received message from server: async_didChangeInheritances:completion:
info 16:27:21.982947-0600 TestApp sceneOfRecord: sceneID: sceneID:com.justaddsoftware.udptest-default persistentID: F08AA976-B8C5-4814-8F65-AD142CCDB261
info 16:27:21.985078-0600 TestApp Deactivation reason removed: 12; deactivation reasons: 4128 -> 32; animating application lifecycle event: 1
info 16:27:21.992199-0600 TestApp Deactivation reason removed: 5; deactivation reasons: 32 -> 0; animating application lifecycle event: 0
info 16:27:23.270450-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.270498-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.278923-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.278983-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.279072-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 0; ignoreInteractionEvents: 0, systemGestureStateChange: 1
info 16:27:23.279120-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.279170-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.311505-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.311636-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.332627-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.332866-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.351952-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.353277-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.374257-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.374321-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
info 16:27:23.375319-0600 TestApp Dispatching UIEvent type: 0; subtype: 0; backingtype: 11, shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0
info 16:27:23.375489-0600 TestApp Sending UIEvent type: 0; subtype: 0; to windows: 1
Jason_King
(Jason King)
November 30, 2020, 4:47pm
#13
Hmm… nothing there screams crash. There are typically explicit messages about the crash or termination reason. I there more in the log?
1 Like
Jon_Ogden
(Jon Ogden)
November 30, 2020, 4:47pm
#14
The socket definitely seems to be torn down when the phone is locked. Xojo just doesn’t know it. I was exchanging my UDP data between the iOS and desktop app. Then after locking the phone, I tried sending data from the desktop app to the iOS app. After unlocking the phone, nothing was updated.
I’m kinda disappointed as that was part of the whole reason I was excited about having a UDP socket. I do have a protocol where I can request updates. Maybe I’ll have to do as you say and destroy and rebuild the connection.
Xojo can enable background tasks but there’s no entitlement for UDP sockets or networking in general. Just things like VoIP, Notifications, etc.
Now, Xojo should still not crash with this. The odd part is I use TCPSockets a lot as well and those don’t have this problem. They seem to stay connected or at least Xojo can detect that the TCPSocket is disconnected. With UDP, there’s problems.
Jon_Ogden
(Jon Ogden)
November 30, 2020, 4:48pm
#15
Nope. No crash log. Nothing. That’s the problem.
Jason_King
(Jason King)
November 30, 2020, 4:52pm
#16
Are you doing anything that could use a lot of memory? Some limited googling seems to say that if you run out of memory while in the background the app can crash when it comes back to the foreground and leave no crash log. Maybe you have an old iOS device with less RAM?
Jon_Ogden
(Jon Ogden)
November 30, 2020, 4:55pm
#17
It’s an iPhone Xs Max. I’m not doing anything that uses a lot of memory at all. So it can’t be that. It’s an issue with the socket and how Xojo is doing it.
DerkJ
(DerkJ)
November 30, 2020, 4:56pm
#18
When your app is active but off screen, your socket is downed by apple to keep the battery alive. The only way to keep it active is register for mDns (bonjour) use and add a backgroundTask but that’s not possible in xojo. You can however add background pushnotification. That works in xojo now. So if you use a http or tcpsocket you could send data after the background push notification is received. (You’ll have 30 sec before the app shuts the background push notification again).
As far as i know streaming tcp/udp is not possible when the app is in the background normally.
Jason_King
(Jason King)
November 30, 2020, 4:57pm
#19
Some more looking says that an unhandled SIGPIPE will cause the app to crash without leaving a crash report. There is your issue:
DerkJ
(DerkJ)
November 30, 2020, 4:58pm
#20
I bet this is not xojo but apple. Is this iOS 14?
Since apple locked down networking and has some udp bugs.