iOS Question UDPSocket: silent crash of app after using iPhone standby button

Eberhard

Member
Licensed User
Longtime User
Hello,

there seems to be an problem with the iNetwork library at the UDPSocket object.
The iOS object seems not to be valid any longer after pressing the iPhone standy button
(maybe even after the app only gets to background).
The library or iOS seems to handle this fine not in any case.
There is no way to catch an exception inside the B4i code.

When starting to create a test app as short as possible first everything worked fine,
so maybe it is not directly reproducable.
But after the crash happened first it could simply be reproduced downto
only including/initializing the iReleaselogger object into an empty B4i project and doing the following steps:
-Compile app in release-mode
- Run App, press Home, press Standbybutton, press Home-button twice to reactive screen, press app-icon to bring app to foreground
-or Run App, press Standbybutton, press Home-button twice to reactivate screen
- the app appears and directly crashs/disappears; when pressing app-icon again it will be an new App-start instead of activating.

What I notized, maybe it is an hint:
case a) library changes UDP source port at every activate, even if only home button gets pressed
everything worked fine
case b) library does not change UDP source port after home button was pressed
I got above effect (silent crashing app)


B4X:
'Test only using Releaselogger
'Compile app in release-mode
'   Run App, press Home, press Standbybutton, press Home-button twice to reactive screen, press app-icon to bring app to foreground
'or Run App, press Standbybutton, press Home-button twice to reactivate screen
'  the app appears and directly crashs/disappears; when pressing app-icon again it will be an new App-start instead of activating

'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i UDP Test
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait
    #iPadOrientations: Portrait
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 7
#End Region

Sub Process_Globals
    Dim Const cHOST ="192.168.0.5" As String 'IP of UDP-Server
    Dim Const cPORT =1111 As Int
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Dim oReleaseLogger As ReleaseLogger
    Dim Timer1 As Timer
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    NavControl.ShowPage(Page1)
    oReleaseLogger.Initialize(cHOST, cPORT)
    Log("App-Start")
    Timer1.Initialize("Timer", 2000)
End Sub

Private Sub Application_Active
    Timer1.Enabled=True
End Sub

Sub Timer_Tick
    'will only be reached if app doesnt crash at App-Active ReleaseLogger action
    Timer1.Enabled=False
    Log("App-Activate delayed")
End Sub

Before this simple example was enough,
the larger test similar to my real, crashing app was:
After standby button and reactivating the app I sended an UDP packet to the app
(to the old UDP connection, so it doesnt reached the app)
and only after that I sended an UDP packet from the app by pressing an button.
There app crashed silent. (no crash info, no try/catch is working, app simply disappears)
 

Eberhard

Member
Licensed User
Longtime User
Hello Erel,

the problem is still actual to me.
My workaround was and is what your suggestion says but it is not this easy,
it is an VoIP app which also often communicates in background,
when doing audio output or receiving push notifications.
Not in all circumstances I can sense that my socket will get invalid.
So it still hurts a lot that sometimes I will silent crash and not even can't catch an exception.

And I'am not sure it is helpful for using the lib releaselogger ;-)

Shouldn't there be a way to fix it at the origin?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…