When the user sends the app to the background and returns after a long period of time, the app displays a white screen and the WebView fails to reload any data. Once this white screen appears, the app becomes unusable. Previously, the only way for users to recover from this state was to reinstall the app.
I implemented a workaround that restarts the local server each time the app is launched. This prevents the app from getting permanently stuck if the user force-quits the app manually. However, the original issue still occurs: if user sends the app in background and open it on next day , the app shows a white screen and the WebView does not load any content.
This behaviour started appearing on iOS 18.5.
I am currently using Flutter 3.38.3 and flutter_inappwebview version 6.1.5.
My questions are:
- Is this a Flutter issue?
- Is this behavior expected when using a WebView-based app on iOS?
you could restart the server after x seconds when resumed, if I understand correctly right now it only restarts if the app is stopped.
take a look here at line 112, it sets the _refresh true after 300 seconds and when resumed it starts a refresh. This is only for when the app is not stopped just runs in the background. Didn’t try it on iOS or with longer durations, you could also save the paused time if you have issues with Duration.
Thank you for your response. Unfortunately, that workaround didn’t solve the issue for a one-hour time period. I need the UI to restart only if the user has been inactive for at least one hour.
it should work after an hour too, maybe not with duration, but with saving the time when the app was paused and compare it to current time when resumed, idk
you also need WidgetBindings for this to work https://mailharshkhatri.medium.com/understanding-applifecycle-states-in-flutter-a-comprehensive-guide-d97cf3e61881
1 Like