-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOMException: Connection to Indexed Database server lost. Refresh the page to try again #354
Comments
Looks similar to #352 Can you provide more information? like webview plugin version and some code to reproduce? |
Same issue here 😳, seems to have been introduced by iOS |
Update: Saving an image from the camera into IDB seems to trigger this pretty often, whereas selecting an image from the gallery and saving THAT into IDB works fine. My workflow: I have two inputs of type "file". One is set to take a photo from the mobile camera, the other to select a file of type image (one has the "capture" attribute, the other does not). Their 'OnChange' events are both set to the same function which saves the data from the input.file into IDB. (after also resizing it using Canvas). Somehow the camera sourced image is killing the IDB server connection, while the gallery sourced image works fine (even gallery images taken with the same camera and resolution). But once the IDB server connection is killed, all IDB related calls end up with the same error I'm not asking for help here, just reporting what I've found so far. Testing results (all from a fresh page reload, iPhone 12.2):
Sometimes I will be able to take 3 or 4 photos before the crash, sometimes not even 1. |
Our users start seeing this error but it doesn't seem to be connected to images in our cases. My feeling is that it may be triggered under memory pressure. |
I could not reproduce this issue with the iOS 12.3 beta anymore - can anyone confirm this, too? |
Looks like this was an Apple bug and seems to be fixed in 12.3, can you verify? |
It is fixed, but not yet deployed/live in an iOS update, see: |
Nope, not fixed. |
Is there anything we can do, to get around this bug? |
|
Same Here! I can reproduce this issue, if you click to lockscreen with app opened on screen and wait 5 minutes VOYALÁ. Connection server lost, and app goes down (CRASH). Any work around about this? |
We've been getting reports from users and error logs that seem to support what they are seeing. It's definitely iOS specific and it appears the later release of iOS 12 and all of iOS 13. It's hard to say exactly what is occurring, but somehow indexedDB is getting stuck in an unreadable and unwritable state. We use both localForage and Dexie. It's almost impossible to consistently reproduce as it happens very rarely. Here are the suspected error messages we're seeing in our logs with partial stack traces: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
Connection to Indexed Database server lost. Refresh the page to try again
UnknownError An internal error was encountered in the Indexed Database server
My first through was that the database was getting closed. So I added a check to all of our writes to check if the database was closed and then reopen it. Pushed out an update with that, but it's still happening. One of the error messages above mentions |
I don't have the link handy any more but there was a bug logged against webkit related to indexedDB becoming inaccessible after either the hybrid app is suspended and resumes or a web browser window is minimised and brought back to front. I was able to reproduce it consistently, in our case we just stopped using indexedDB as there was no easy fix for it. Sorry I don't have the original bug link on hand any more. |
Any progress on this issue or any fixes that have been discovered? We are receiving the same errors from some of our users as well. |
We get this error consistently when going into flight mode and then updating indexed db multiple times. Using ios 13.1.1 |
Yep, here's the Safari issue: https://bugs.webkit.org/show_bug.cgi?id=197050 |
This seems to be present in iOS 14.4.2 still |
Still experiencing this in iOS 15 |
This is still happening in ios 15+ |
I'm seeing this problem on iOS 15.6 when using the GeniusScan document scanning Cordova plugin. This plugin overlays the Ionic app for an extended period of time. When the plugin returns, IndexedDB has closed the connection and all subsequent store actions fail with "DatabaseClosedError: UnknownError Connection to Indexed Database server lost. Refresh the page to try again". Is there some workaround? Some way to keep IndexedDB alive?
Ionic: Ionic CLI : 6.20.1 (/opt/homebrew/lib/node_modules/@ionic/cli) Cordova: Cordova CLI : 11.0.0 |
Is this issue still occurring on iOS 16 beta? |
I have not yet tried to resolve the problem with iOS 16. However, I do have some further information. To be sure it wasn't a particular Cordova plugin (GeniusScan) that was causing the problem, I swapped in Scanbot - another document scanning plugin. The same thing happened. XCode revealed it was the WebProxyProcess that was crashing and reloading the entire web view -- essentially restarting my Ionic 6 / Cordova web app. I could see the restart messages. I had been running the app on an iPhone XR with latest iOS 15.x I hadn't restarted my phone for weeks. So I restarted it and found that the problem had cleared. Whatever the issue is, it builds up over with extended use, until the WebProxyProcess no longer seems to be able to run memory-intensive (I'm assuming) plugins that have UIs that overlay the background app. I also verified the same pair of plugins on other iOS devices and did not see a problem. Since I restarted the phone the problem has not come back. I did notice that when the problem was occurring it seems to occur more and more often with more severe outcomes - the worst being a restart of the web view. It's quite clear the XCode console logs. |
I saw this problem again using the standard Cordova camera plugin. According to the XCode console, the WebProxyProxyProcess crashed unexpected after closing the camera plugin and the app web view relaunches -- thus severing any context to the pre-crash web view. I am seeing: The problem is not resolved by restarting the app. The only solution is to reboot the OS entirely. I suspect some accumulating failure in the iOS infrastructure that runs the web view within the hybrid app. The issue is revealed more quickly by those plugins that run a modal UI launched from the web view. It's as if the OS believes that the hybrid's web view has become abandoned while the plugin in front most and kills the web view. It would be great if Apple engineering would look at this issue is it doesn't seem to resolvable by programmatic workarounds. Thoughts? |
I agree that this bug is something outside of our control, as Ionic/Capacitor developers. It is an OS-level issue that requires a restart to get working again, and isn't something we can fix or work around as far as I can tell. I'd encourage everyone here to please add your vote and comment on the Safari issue itself. The folks at Apple need to know it's a serious problem: |
The crash of IndexedDB (the Safari bug) is a side-effect of iOS having restarted the web view after it detects the embedded web view in the Cordova hybrid app as a zombie process, perhaps due to lack of response to some polling mechanism while a Cordova plugin is running a modal UI. That's my theory. |
I can confirm that the problem is still happening with iOS 16. It happens even with using the standard camera plugin (cordova-plugin-camera 6.0.0 "Camera"). If you use open the plugin UI (i.e. take a photo) enough times, eventually the "WebProcessProxy" seems to think that the web view died and restarts the web view, effectively reloading the application. Even restarting the app does not remedy the problem. It's some long term cumulative problem that requires booting iOS entirely. This is a show stopper problem, with no workaround for Cordova developers, which Apple needs to fix. Please vote this issue up. == WebProxy source code: https://opensource.apple.com/source/WebKit2/WebKit2-7604.1.38.1.6/UIProcess/WebProcessProxy.cpp.auto.html |
Hi @jasonwinshell-br I would like to upvote this issue ... but I don't see a way to do so on the apple bugzilla site (I am signed in). Is there a way to do so? Also, would you be able to add your recent info to that bugzilla ticket? It was last updated in June 2021 with comments about iOS 14. |
This also happens to me on my application. Maybe we can use the detection of the application in the foreground to recreate the connection if it falls in error?
|
@cschoenecker Interesting idea. What is your That said, I am pretty sure that when this bug happens, it's because Safari's database thread has crashed, and it requires a full device restart to fix. If an application restart fixes the issue, this solution might work. Interested to hear more about how this goes. |
I will rather in my case restart the application if the connection to indexedDB is lost, like this:
appStateChange use Capacitor/app
|
I think that in the end only Apple can fix this problem. This bug has been there for a while and even through iOS 16. The problem is way worse that just crashing IndexedDB - the entire WebView crashes and auto-restarts by a watcher process. It effectively lobotomizes the app, with the only recovery to restart the entire iOS -- not even an application restart works. |
What do you mean the entire WebView crashes? For my part the application remains functional but only the functions calling the IndexedDB storage via @Ionic/storage crash. Would changing the configuration of Ionic-storage to use SQLite instead of IndexedDB solve the problem? |
They mean that the IndexedDB process crashes in the entire Safari OS process and cannot be fixed without a device restart. Yes, with some extra steps, but SQLite is no longer supported in the web. You would need to install the SQLite native cordova/capacitor plugin. Since you'd be bypassing Safari's storage mechanisms entirely, it would likely not be affected by this issue. |
This is an annoying issue on our end. |
This is my workaround that works (so that the user does not stay in front of an application that does not work anymore and does not know that it is necessary to kill and restart the application). When the application comes back to the foreground I check if the DB access is not in error and if yes I reload the current page (which resets the DB)
I use @capacitor/app for appStateChange and storage from Ionic-storage |
I feel confident that this problem is not caused by any particular use of IndexedDB. I can see the nature of the crash in the XCode debug console. IndexedDB crashes because a watchdog process on the web view restarts it just like refreshing a browser web page. It seems to be triggered over time by Cordova plugins with UIs that overlay the hybrid app for an extended period of time. Even the Cordova Camera plugin will trigger it. The problem escalates over time such that not even restarting the app fixes the problem. There's some issue in the bowels in the iOS operating system that goes wrong, requiring a restart of the device. The problem is is documented here: Webview is reloaded sometimes and Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog'apache/cordova-ios#1103 |
IOS 12.2 ( Cordova )
DOMException: Connection to Indexed Database server lost. Refresh the page to try again
the database crashes from time to time
Has anyone encountered this problem?
The text was updated successfully, but these errors were encountered: