Issue Network in Safari when switching from Wifi to Cellular

We are working on a PWA app packaged as a native app using capacitor, that works very well beside one network issue :

  • App is opened while WIFI is ON, works well
  • Wifi is disabled, mobile is now on 4G
  • Network no longer works inside the app, but works fine on the mobile otherwise
  • After a while, network works again inside the app (something like 20s)

After that point, if you go back and forth between Wifi and cellular, the issue do not appear again, it only appear if the is the first time you do it inside the app, after you haven't touch your mobile phone for a while.

If you open or close the app, it wont happen again. If you push a new build, it wont happen again.

But if you dont use your phone for a while (like a few hours it seems), then it will almost always happen the first time you use the app, then wont happen again until next session... That make it very hard to debug.

A few more informations :

Standalone PWA

Same app installed as a Standalone PWA (Add to Home Screen) works fine even when the Native version has the broken network, once the Standalone has been used, then the Native starts to work again.

Catch errors

This is the only error I'm abled to catch when the issue appear :

2022-08-26 10:04:01.863024+0200 App[39920:2421520] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
2022-08-26 10:04:01.863212+0200 App[39920:2421520] [ProcessSuspension] 0x10b0084a0 - ProcessAssertion: Failed to acquire RBS assertion 'GPUProcess Background Assertion' for process with PID=39926, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}

Resulting in Axios failing to connect with that error :

⚡️ [log] - {"message":"timeout of 5000ms exceeded","name":"AxiosError","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":5000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{"FormData":null},"headers":{"Accept":"application/json, text/plain, */*"},"baseURL":"https://api-DOMAIN/","method":"get","url":"v1/ENDPOINT"},"code":"ECONNABORTED","status":null}

Test conditions

  • Required iOS 13
  • Tested with iOS 15.6 on iPhone 13 Pro and iPhone 11 with same issue on both

Any help or opinion on what we could try to fix that is welcome, we are running out of ideas :)

Thanks a lot for reading !

G.

Two days ago we tested our app on Android. Worked fine as a PWA, but impossible to get any connection to our backend once installed at a native app.

After further investigation, we find out that our SSL certificate wasn't properly setup and that the SSL chain was broken.

Weirdly enough, SSL was working fine on iOS on PWA, browser and native, and fine in Android but on native.

We fixed the SSL certificate setup, and the issue on Android was resolved. Since then, we didn't had that broken connection issue on native iOS when switching networks like described in the previous post.

So we assume that it was the same issue on both cases.

Just posting that here in case someone end up here looking for a similar issue, check that your SSL certificate chain is not broken using something like https://www.ssllabs.com/ssltest/analyze.html

Cheers.

Issue Network in Safari when switching from Wifi to Cellular
 
 
Q