iOS Question UDP Broadcast crashes after beeing in background

Blueforcer

Well-Known Member
Licensed User
Longtime User
My app uses UDP broadcast to find another device.
It works good but i found a crash wich i could reporduce:

- open the app
- move it to background
- lock phone
- wait 30s
- unlock phone
- open app again -> Crash

I reduced the app to the minimum and found that UDPSocket1.SendBroadcast(Packet) causes the crash after being in background

crashreport:
B4X:
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001bc70daac 0x1bc70d000 + 2732 (mach_msg_trap + 8)
1   libsystem_kernel.dylib          0x00000001bc70e07c 0x1bc70d000 + 4220 (mach_msg + 72)
2   CoreFoundation                  0x0000000181dd3cc8 0x181dcd000 + 27848 (<redacted> + 368)
3   CoreFoundation                  0x0000000181dd7fd0 0x181dcd000 + 45008 (<redacted> + 1160)
4   CoreFoundation                  0x0000000181deb194 0x181dcd000 + 123284 (CFRunLoopRunSpecific + 572)
5   GraphicsServices                0x00000001a28fe988 0x1a28fd000 + 6536 (GSEventRunModal + 160)
6   UIKitCore                       0x00000001845eea88 0x184109000 + 5134984 (<redacted> + 1080)
7   UIKitCore                       0x0000000184387fc8 0x184109000 + 2617288 (UIApplicationMain + 336)
8   AWTRIX Light                    0x0000000102d28408 0x102d24000 + 17416 ( + 100)
9   (null) 0x00000001035384d0 0x0 + 4350772432

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private BroadcastTimer As Timer
    Dim UDPSocket1 As UDPSocket
    Dim Packet As UDPPacket
End Sub

Public Sub Initialize

End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    BroadcastTimer.Initialize("broadcast",1000)
    UDPSocket1.Initialize("UDP", 4211, 8000)
    Packet.Initialize("TEST".GetBytes("UTF8"),UDPSocket1.GetBroadcastAddress,4210)
End Sub

Sub B4XPage_Appear
    BroadcastTimer.Enabled=True
End Sub

Sub B4XPage_Disappear
    BroadcastTimer.Enabled=False
End Sub

Sub broadcast_tick
    UDPSocket1.SendBroadcast(Packet)
End Sub
 

Blueforcer

Well-Known Member
Licensed User
Longtime User
SOLVED:

i found this in the "Similar Threads"
 
Upvote 0
Top