LiveView reconnects on iPhone after iOS 18.1.1 update, losing all assigns

Hi everyone,

Starting Monday, December 2nd, I noticed an issue with one of my LiveView projects affecting iPhone users (apparently after the iOS 18.1.1 update). If a user minimizes their browser—e.g., to retrieve some information from another app—and then returns to the browser, LiveView reconnects and all assigns are lost because the LiveView process restarts.

I implemented a quick workaround by caching the assigns using Cachex, but this issue also affects LiveComponents, making it increasingly complex to manage and resolve.

Has anyone experienced a similar issue? Were you able to find a solution?

Thanks in advance!

iOS will close connections when an application is in a suspended/background state, unless it’s registered for services that would allow it to continue to run in the background.

Safari (any mobile browser) on iOS has always functioned this way for as long as I can remember. No workarounds I am aware of.

Is this part of a form?

I don’t think there are many options. You use the word “minimize,” but that is not what happens in iOS.

When an app is pushed to the background, it is suspended, so things like web sockets will disconnect. It is expected.

If you are a full-fledged iOS app, you can configure some allowances for running things in the background but not by a website running in a browser.

If you search for “safari websockets for backgrounded browser” you’ll find some conversations and hacks, but many do not work anymore.

Hi @jhonathas what assigns specifically are you holding on to you that you expect to be preserved?

This is kind of why I don’t like LiveView for mobile-heavy apps - if someone is using the app infrequently eg. unlock phone, do somestuff stuff, lock phone again, then it will need to reconnect each time and the user will see a flash of an error message while the socket is disconnected :thinking:

2 Likes