From 3e3e604f8ccc8b17f22b54a5182ad7feb9596411 Mon Sep 17 00:00:00 2001 From: Coury Ditch Date: Wed, 10 Nov 2021 14:52:07 -0700 Subject: [PATCH 1/2] Skip IndexedDB cleanup on Safari 15 This PR changes our IndexedDB shutdown to skip all remaining work items on Safari 15. It is believed that writing to IndexedDB during unload can trigger a bug on Safari that prevents IndexedDB from loading during the next page load. --- packages/firestore/src/local/indexeddb_persistence.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_persistence.ts b/packages/firestore/src/local/indexeddb_persistence.ts index d4eba6e873c..e8836db9c5f 100644 --- a/packages/firestore/src/local/indexeddb_persistence.ts +++ b/packages/firestore/src/local/indexeddb_persistence.ts @@ -962,10 +962,10 @@ export class IndexedDbPersistence implements Persistence { // to make sure it gets a chance to run. this.markClientZombied(); - if (isSafari() && navigator.appVersion.match(`Version/14`)) { - // On Safari 14, we do not run any cleanup actions as it might trigger - // a bug that prevents Safari from re-opening IndexedDB during the - // next page load. + if (isSafari() && navigator.appVersion.match(/Version\/1[45]/)) { + // On Safari 14 and 15, we do not run any cleanup actions as it might + // trigger a bug that prevents Safari from re-opening IndexedDB during + // the next page load. // See https://bugs.webkit.org/show_bug.cgi?id=226547 this.queue.enterRestrictedMode(/* purgeExistingTasks= */ true); } From 8bb0161036ef842cefc05a7ccbeaca99884889f6 Mon Sep 17 00:00:00 2001 From: Coury Ditch Date: Wed, 10 Nov 2021 15:00:26 -0700 Subject: [PATCH 2/2] Create lovely-bobcats-punch.md --- .changeset/lovely-bobcats-punch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-bobcats-punch.md diff --git a/.changeset/lovely-bobcats-punch.md b/.changeset/lovely-bobcats-punch.md new file mode 100644 index 00000000000..f053ecfc509 --- /dev/null +++ b/.changeset/lovely-bobcats-punch.md @@ -0,0 +1,5 @@ +--- +"@firebase/firestore": patch +--- + +The SDK no longer accesses IndexedDB during a page unload event on Safari 15. This aims to reduce the occurrence of an IndexedDB bug in Safari (https://bugs.webkit.org/show_bug.cgi?id=226547).