-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DO NOT MERGE] Add BitmapRegistry #15
base: main
Are you sure you want to change the base?
Conversation
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.
Looks good, few review comments added
packages/google_maps_flutter/google_maps_flutter/lib/src/bitmap_registry.dart
Outdated
Show resolved
Hide resolved
...google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Show resolved
Hide resolved
...google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Outdated
Show resolved
Hide resolved
...google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Show resolved
Hide resolved
...ps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/ImageRegistry.h
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/ImageRegistry.m
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart
Show resolved
Hide resolved
/// Registers a [bitmap] with the registry. | ||
/// | ||
/// Returns a unique identifier for the registered bitmap. | ||
Future<int> register(MapBitmap bitmap) async { |
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.
this could return RegisteredMapBitmap object directly
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.
This is what I was doing initially but then there was a comment to my other PR about not mixing platform and user-facing packages. I think it will be the case here too because RegisteredMapBitmap
is part of platform interface while this comment is about user-facing plugin.
I see these options:
- Use
int
(the way it's done now) - Add
GoogleMapsRegisteredMapBitmap
or something like that to the user-facing plugin - Use
RegisteredMapBitmap
and see what maintainers say
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.
Oh, BitmapDescriptor classes are used already as icon objects etc.
I think the case was more about the internal configuration umbrella objects?
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.
AFAIR it was about using platform interface's MarkerType
in google_maps_flutter
, exposing it for end users. All other objects are exposed but I was asked not to do that because they're changing how federated plugins are doing things.
I'd rather keep it like it is now and wait for review or ask a question when main PR is created. What do you think?
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.
Yes, it is quite easy to change later if they want to
} | ||
|
||
/// Unregisters a bitmap with the given [id]. | ||
Future<void> unregister(int id) { |
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.
should this take RegisteredMapBitmap as a parameter.
@illuminati1911 can you please review the iOS part? Feel free to leave comments about everything else too, I'm just very unsure about the Objective-C code |
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageRegistry.m
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageRegistry.h
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageRegistry.h
Outdated
Show resolved
Hide resolved
I've added some tests. What else should be added/changed before PR can be created in the main repository @jokerttu? |
This is some results of my performance tests (will be copied to the main PR). I've done plenty of tests in different configurations but I think it's important to show that using registry in the example page makes a difference. Performance improvementsThere's a new example page called The data was measured using There are two buttons in the example. First button adds markers and sets their icon by sending each marker's icon to the platform layer. Second button adds bitmap to the registry and adds markers with the registered bitmap.
I've tried this on iOS and Android multiple times with different bitmaps. The results are different depending on current platform, number of markers and bitmap configuration (size, scaling) |
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.
I'll continue with this later... here is first foundings.
App facing package is missing intergration tests as well!
...s_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ImageRegistryTest.java
Outdated
Show resolved
Hide resolved
...s_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ImageRegistryTest.java
Show resolved
Hide resolved
...s_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ImageRegistryTest.java
Show resolved
Hide resolved
...google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Show resolved
Hide resolved
imagePixelRatio: 1.0, | ||
); | ||
|
||
await GoogleMapBitmapRegistry.instance.register(bitmap); |
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.
We should extend the inspector api to have methods
bool supportsBitmapRegistry => false (overrided in platform implementations)
bool hasRegisteredMapBitmap => api call to check if there is registered bitmap...
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.
Why do we need the first method?
I'm hitting an obstacle with these - implementation needs to have mapId
to call inspectorProvider
in google_map_inspector_android.dart
but for bitmap registry mapId
is not used. BitmapRegistry is not attached to a map, it's a singleton which part of the plugin that different map instances could use
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.
even when this is now supported by all platforms, it seems its recommend to have supports queries for certain calls (that are called for example in tests).
We have added similar to other features lately,
not sure if supportsBitmapRegistry
is too generic, it could actually be supportsHasRegisteredMapBitmap
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.
I'm hitting an obstacle with these - implementation needs to have
mapId
to callinspectorProvider
ingoogle_map_inspector_android.dart
but for bitmap registrymapId
is not used. BitmapRegistry is not attached to a map, it's a singleton which part of the plugin that different map instances could use
I can check this next week, but it is always possible to create separate inspector api for bitmapregistry that does not require mapid
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.
I've ended up pumping a map widget and getting a map ID from it for these tests. I've added just the hasRegisteredMapBitmap
because I still don't see why we should have the supportsBitmapRegistry
method if it's never used
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.
You should be able to for example skip tests if supportsBitmapRegistry return false.
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#api-support-queries
Bitmap registry PR for internal review. Idea is simple: register bitmap with a registry then reuse it by using
RegisteredBitmap
as marker icon, this improves performance since bitmaps are cached on the platform side.TODO:
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.