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

fix(cloud_firestore): Fix crashes on iOS/macOS #11501

Merged
merged 5 commits into from Aug 29, 2023

Conversation

paulw11
Copy link
Contributor

@paulw11 paulw11 commented Aug 21, 2023

Description

This PR changes the FLTFirebaseFirestorePlugin.serverTimestampMap property from an instance of NSMutableDictionary to NSCache. NSCache is inherently thread-safe while NSMutableDictionary is not.

Additionally, this property was not initialised in a consistent manner. It is a static property, but was being initialised in an instance init function as well as opportunistically in the property getter.

The property is now instantiated via a dispatch_once block in the getter.

All access to the property is now via the getter.

Related Issues

Fix flutter/#10715

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

use dispatch_once to instantiate `serverTimestampMap`
Fix firebase#10715
Use thread-safe `NSCache` instead of `NSMutableDictionary`
Do not bypass getter
Consistently use static property
USe `dispatch_once` to ensure single instantiation of cache.
@paulw11 paulw11 changed the title fix(cloud_firestore) Fix crashes on iOS/macOS fix(cloud_firestore): Fix crashes on iOS/macOS Aug 21, 2023
@Salakar Salakar requested review from Lyokone and russellwheatley and removed request for Lyokone August 21, 2023 09:49
@russellwheatley
Copy link
Member

Hey @paulw11, thanks for the fix! Appreciated. To get this over the line, could you merge with master branch? You might have to run melos run format for the project. This would require installing melos which you can do with this command:

dart pub global activate melos

I think this ought to fix CI issues but will see what the result is 😄

@paulw11 paulw11 requested a review from Lyokone August 22, 2023 00:05
@russellwheatley russellwheatley merged commit 3ed5347 into firebase:master Aug 29, 2023
20 checks passed
exaby73 pushed a commit that referenced this pull request Sep 3, 2023
Co-authored-by: russellwheatley <russellwheatley85@gmail.com>
@firebase firebase locked and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants