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

Use userAgent instead of depricated appVersion to check for safari indexDB bug. #6899

Merged
merged 6 commits into from
Mar 7, 2023

Conversation

KoryNunn
Copy link
Contributor

@KoryNunn KoryNunn commented Dec 19, 2022

Currently firestore persistance is broken in cordova, as WKWebView's appVersion does not match Version/1[45], and appVersion is a depricated feature. This PR swaps to checking the userAgent, which is something cordova apps can affect, allowing some level of mitigation of this issue.

Fixes #6509

@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2022

🦋 Changeset detected

Latest commit: 85a82ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla
Copy link

google-cla bot commented Dec 19, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@KoryNunn KoryNunn marked this pull request as ready for review January 4, 2023 23:49
@KoryNunn
Copy link
Contributor Author

@dconeybe I have done the CLA, is there a way to re-run these jobs?

@dconeybe
Copy link
Contributor

@dconeybe I have done the CLA, is there a way to re-run these jobs?

I'm not sure. Tagging @cherylEnkidu and @wu-hui, who were working with you on the related bug #6739

@dconeybe
Copy link
Contributor

Hi @KoryNunn. I think you may have linked to the wrong issue number in the description of this PR. You linked to #6739, which is why I tagged my team mates, but that issue doesn't appear to be related to appVersion or user agent at all. I think you meant to link to #6509. Is my thinking correct?

@dconeybe dconeybe self-assigned this Feb 17, 2023
@dconeybe
Copy link
Contributor

Please merge in HEAD of the master branch and push it up. The GitHub actions have likely changed quite a bit.

@dconeybe dconeybe self-requested a review February 17, 2023 01:40
@KoryNunn
Copy link
Contributor Author

I did mean #6509 sorry.

I'll merge head shortly

@dconeybe
Copy link
Contributor

Thanks for updating your PR. Since this dark corner of the Firebase code base is unfamiliar with me, I've reached out to some colleagues for advice.

What do you think about leaving the original "if" condition in place, but adding an "or" clause? Basically, check appVersion and userAgent and applying the workaround if at least one of the conditions is true? That would more likely preserve backwards compatibility IMO.

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changeset using yarn changeset. It should be a patch release of @firebase/firestore and firebase.

For the changeset description, use something like this:

Check navigator.userAgent, in addition to navigator.appVersion, when determining whether to work around an IndexedDb bug in Safari. Notably, this may be helpful for Cordova apps that lack appVersion in their webview yet need to apply the workaround.

packages/firestore/src/local/indexeddb_persistence.ts Outdated Show resolved Hide resolved
@KoryNunn
Copy link
Contributor Author

KoryNunn commented Mar 7, 2023

I've updated this PR to more robustly work in both Safari and in WKWebView (the web view used in native apps).

In Safari, the match is Version/{number}, in WKWebView, the match is Mobile/{number}.

Also, this bug is present in version 16, so I added that to the check.

.changeset/chilled-buckets-sneeze.md Outdated Show resolved Hide resolved
packages/firestore/src/local/indexeddb_persistence.ts Outdated Show resolved Hide resolved
packages/firestore/src/local/indexeddb_persistence.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Will give approval once GitHub Actions pass. Thanks for your time (and a great deal of patience) in making this contribution to the SDK!

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge at your convenience.

@KoryNunn
Copy link
Contributor Author

KoryNunn commented Mar 7, 2023

"Only those with write access to this repository can merge pull requests."

@dconeybe dconeybe merged commit 5099f0f into firebase:master Mar 7, 2023
@KoryNunn KoryNunn deleted the fix-safari-indexdb-bug-detection branch March 9, 2023 23:21
@google-oss-bot google-oss-bot mentioned this pull request Mar 14, 2023
renkelvin pushed a commit that referenced this pull request Mar 21, 2023
renkelvin pushed a commit that referenced this pull request Mar 21, 2023
@firebase firebase locked and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enablePersistance in an iOS WebView causes queries to take minutes to resolve.
2 participants