-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_ios] Cache +[GMSServices sharedServices] when first map is created
#6211
Conversation
cyanglaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerTests/GoogleMapsTests.m
Show resolved
Hide resolved
|
If this is expensive enough to warrant precaching, it's probably expensive enough that we don't want to kick it off before I would vote for only automatically caching when the plugin gets its first message, and then adding explicit API to allow precaching, so that app developers can decide when to take that cost. |
This is a good point. I looked at more traces, I was hoping the maps SDK would essentially be doing what you describe and lazily initialize more when the map is actually created, but it does indeed do a bit of work just setting up, which would be a startup cost.
Will move to the first time a map is created. Re: adding an API that's more work than I'm willing to spend on @jonahwilliams's nerd snipe, I'll file a new issue for that. 🙂 |
+[GMSServices sharedServices] during plugin initialization+[GMSServices sharedServices] when first map is created
|
Sounds good! |
…n first map is created (flutter/plugins#6211)
Previously, every MapView creation would reinitialize the underlying Google Maps services:
Retain opaque object
+[GMSServices sharedServices]when the first map is created. This must be called on the main thread, but kicks off background initialization of service syncing. Docs say:Just retaining it is enough to cache for subsequent views, without needing to pass it into the view itself.
See also GM source (internal links)
cs/piper///depot/google3/googlemac/iPhone/Maps/SDK/Maps/GMSServices+Google.h;l=15-20
cs/piper///depot/google3/googlemac/iPhone/Maps/SDK/Maps/GMSServices.mm;l=259-269;bpv=1;bpt=1
Part of flutter/flutter#109057
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.