-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[google_maps_flutter] Add ability to animate camera with duration #7648
base: main
Are you sure you want to change the base?
[google_maps_flutter] Add ability to animate camera with duration #7648
Conversation
fbf20bc
to
68e52df
Compare
68e52df
to
2c8caf1
Compare
2256a07
to
c39c721
Compare
...ps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart
Outdated
Show resolved
Hide resolved
...ps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart
Outdated
Show resolved
Hide resolved
...maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart
Outdated
Show resolved
Hide resolved
...maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart
Outdated
Show resolved
Hide resolved
.../google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsTests.m
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart
Show resolved
Hide resolved
...flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java
Show resolved
Hide resolved
7c30a33
to
167b519
Compare
167b519
to
6078134
Compare
eb71ec7
to
b6807ec
Compare
...le_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMCATransactionWrapper.h
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMCATransactionWrapper.h
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMCATransactionWrapper.m
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController_Test.h
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController_Test.h
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController_Test.h
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart
Outdated
Show resolved
Hide resolved
.../google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsTests.m
Show resolved
Hide resolved
My comments are all minor, so once the iOS and Android reviewers have signed off this will be ready to split out the first sub-PR. |
b6807ec
to
6bc7717
Compare
6bc7717
to
12856e2
Compare
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.
The changes LGTM :) but left some questions/comments on the stability of the integration test.
_getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); | ||
await controller.animateCamera(cameraUpdate); | ||
|
||
// Check that position is not updated immediately to the target. |
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 not deeply familiar with the APIs here but is it possible this could be flaky? Is it guaranteed that right after we make the call, the position will not update before the check here completes?
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.
Improved tests documentation to explain better why this is done.
Yes, this test could potentially be flaky, but it is unlikely.
On android the default animation duration is approximately 300ms. This should be long enought time to mitigate possible communication or SDK delays.
The reason for testing this is to ensure that the camera is animated rather than instantly moved to a new location. We could have also used stopwatch and wait cameraIdleEvent, and see if the event does not come too soon, but then we would need to hardcode limits.
It this test is removed, we can only test that camera is moved to right position, but cannot be aware if it is animated or not.
NOTE: tests are now skipped on android, but I left the code here to be enabled later. animateCamera method does not work without Maps API key on Android platform.
...gle_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart
Outdated
Show resolved
Hide resolved
// For short animation duration, check that the animation is completed | ||
// faster than the middle point of the animation test durations. | ||
expect(stopwatch.elapsedMilliseconds, | ||
lessThan(animationDurationMiddlePoint)); |
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 not check that the time that has elapsed running the animation is the same as the requested duration 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 solution is based on suggestion by @stuartmorgan #7648 (comment)
Testing with two times mitigate away the possiblity that animateCamera by default animates with same speed.
The duration won't be exactly same as detected by stopwatch, because internal delays on messaging and SDK functionality, so picking proper threshold for testing duration would be really hard.
Most likely having one test run with longer period, lets say 1 second, could work, but this assumes that default animation speed on each platform is different.
); | ||
|
||
// Check that position is not updated immediately to the target. | ||
final CameraPosition beforeFinishedPosition = |
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 have the same question here about flakiness as the test before. Is that concern why this is only checked for the longer animation and not the shorter?
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.
Short period is so short, that there might be possilbity that the latencies on communication and SDK might delay the camera position query so much that it is already animated to target location, causing flaky tests.
For longer duration we could safely say that communication latencies are not causing 1 second delays.
Camera animation is not affected by networking either.
...gle_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart
Outdated
Show resolved
Hide resolved
...gle_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart
Outdated
Show resolved
Hide resolved
1f16fda
to
25cf8ec
Compare
Updated integration tests, by using Completer instead of StreamQueue to detect OnCameraIdle events. Integration tests are also now skipped on Android as they work only with Maps API Key which is not available on CI at the moment. |
2d888c5
to
45f5b8a
Compare
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.
Android changes LGTM! Thanks @jokerttu for the thorough explanations :)
Adds ability to configure camera animation duration on Android and iOS.
Resolves #39810
Resolves #44284
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.