Skip to content
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

Unknown error occurs on iOS PWA (UnknownError / DatabaseClosedError / Need to reopen db) #2008

Open
AlexanderMelde opened this issue Jun 13, 2024 · 9 comments

Comments

@AlexanderMelde
Copy link

AlexanderMelde commented Jun 13, 2024

Hello, In our PWA which is compiled for iOS using Capacitor some users are experiencing the following error:

  • DatabaseClosedError UnknownError Connection to Indexed Database server lost. Refresh the page to try again

We assume that this error occurs after the app is in the background for a while (e.g. the user locked the screen or used multitasking), as similar errors occur for other PWAs as well.

In addition to this first error, two Dexie specific errors are thrown:

  • Dexie: Workaround for Chrome UnknownError on open() (thrown here)
  • Dexie: Need to reopen db (thrown here)

When researching the reason for the "chrome specific" workaround we found this comment in #543, however in our case its neither chrome (instead it's Mobile Safari UI/WKWebView) nor "clear cookies and site data", just normal app use.

As a result of these errors, our app becomes unstable until properly restarted.

Do you have an idea of how to prevent/resolve or catch these errors?

Console Log
image

Thank you for your help and this amazing library!

@AlexanderMelde AlexanderMelde changed the title Chrome-specific Error occured on iPhone PWA chrome-specific error occurs on iOS PWA Jun 13, 2024
@AlexanderMelde AlexanderMelde changed the title chrome-specific error occurs on iOS PWA chrome-specific error occurs on iOS PWA (UnknownError / DatabaseClosedError / Need to reopen db) Jun 13, 2024
@dfahlander
Copy link
Collaborator

The warning logs from dexie are not thrown errors but console.warning() when dexie need to workaround a situation that can occur on Chrome. In this case we get a similar issue with the underlying Safari engine that cordova runs the webapp on (if I'm correct). According to the logs, Dexie's workarounds does not help in this case as the database continue to complain.

It would be interesting if you could log some number from StorageManager.estimate() on your clients to see whether low storage on the device could be something that could trigger this.

Another theory would be memory pressure on the device: ionic-team/cordova-plugin-ionic-webview#354 (comment). Don't know if there are any way in cordova to log available RAM - that would also be very interesting data to collect.

If you would be able to get more info about storage or memory in when the issue happens, please share!

@AlexanderMelde
Copy link
Author

Thank you for your assessment of the situation! As the issue only occurs occasionally, we unfortunately were not able to reproduce it yet and hence could not measure the storage or memory so far. I will send an update once we capture one of these errors with storage and memory estimates.

@lincolnthree
Copy link

lincolnthree commented Jul 26, 2024

For us, this has happened to over 1,900 users over 21,000 times. It only occurs when the app has been in the background, then returns to the foreground later. There is an open WebKit bug for this as well:

It was a regression in Safari 17.4+ and it seems like they think they've fixed it for 17.6. All we can do is wait, unfortunately -- but the good news is there may be hope on the horizon.

https://bugs.webkit.org/show_bug.cgi?id=273827

image

In truth, this is the liability of building web-apps as native replacements. Browsers are still a huge source of unreliability and compatibility concerns and Safari is the new Internet Explorer.

Reporting, commenting and voting on bugs, providing trace info, and reproductions is the best course of action I've found.

@aeharding
Copy link

Seemingly not resolved in 17.6: https://bugs.webkit.org/show_bug.cgi?id=277615

@lincolnthree
Copy link

Ugh.

@aeharding
Copy link

Can anyone share a workaround they are using? I am getting regular user reports on my Capacitor app.

@louis123562
Copy link

louis123562 commented Oct 14, 2024

Can anyone share a workaround they are using? I am getting regular user reports on my Capacitor app.

I would like to know a workaround, too. Our capacitor users report the same problem. All that we can do at least is to show an alert, if the storage couldnt be initialized, read or write.

import { Storage } from '@ionic/storage-angular';

...

try {
      const storage = await this.storage.create();
      this._storage = storage;
    } catch (e) {
      console.error("STORAGE INITIALIZE ERROR");
      console.error(e);
      alert("Storage Initialize Error. Please close the app completly and open again.");
    }

This cannot be a permanent way of handling this...

@dfahlander
Copy link
Collaborator

I put a comment on one of the webkit issues this regards to, https://bugs.webkit.org/show_bug.cgi?id=273827, but that one is closed in belief of this having been resolved in iOS 17.6. Alexey Proskuryakov kindly replied directly asking us to file a new bug in their bugzilla where we could refer to this issue.

@louis123562, @AlexanderMelde or @lincolnthree, could anyone of you file the issue on https://bugs.webkit.org ? I will weigh in also! And I know at least one more dexie user having the same issue when running their app on iOS so we could together do our best to give this issue attention!

@louis123562
Copy link

louis123562 commented Oct 14, 2024

I put a comment on one of the webkit issues this regards to, https://bugs.webkit.org/show_bug.cgi?id=273827, but that one is closed in belief of this having been resolved in iOS 17.6. Alexey Proskuryakov kindly replied directly asking us to file a new bug in their bugzilla where we could refer to this issue.

@louis123562, @AlexanderMelde or @lincolnthree, could anyone of you file the issue on https://bugs.webkit.org ? I will weigh in also! And I know at least one more dexie user having the same issue when running their app on iOS so we could together do our best to give this issue attention!

Hey man, i think there is already an issue on WebKit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=277615
I found it here: ionic-team/ionic-storage#317

@dfahlander dfahlander changed the title chrome-specific error occurs on iOS PWA (UnknownError / DatabaseClosedError / Need to reopen db) Unknown error occurs on iOS PWA (UnknownError / DatabaseClosedError / Need to reopen db) Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants