Skip to content

[google_maps_flutter] Started dispatching platform messages from platform thread #6069

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

Merged
merged 10 commits into from
Mar 14, 2024

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Feb 6, 2024

Issue: flutter/flutter#135252

Testing: This adds no new functionality and thus should be covered in tests. The problem is that we are permissive to unsafe platform channel usage in the release flutter engine. We should maybe consider running tests against a debug version of the engine.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan-g
Copy link
Contributor

Testing: This adds no new functionality

The criteria for testing is not that we only test new functionality, it's https://github.com/flutter/flutter/wiki/Tree-hygiene#tests

and thus should be covered in tests.

The thing you are fixing here is not meaningfully covered by current tests, as evidenced by the fact that they pass.

This can be tested via native unit tests. Some relevant examples:

@stuartmorgan-g
Copy link
Contributor

We should maybe consider running tests against a debug version of the engine.

Do the engine builders publish those artifacts?

@gaaclarke
Copy link
Member Author

The criteria for testing is not that we only test new functionality, it's https://github.com/flutter/flutter/wiki/Tree-hygiene#tests

Right, the point is that the code in this PR has test coverage. It is executed inside of a test and it is evaluated to give the correct results, not that the thing that caused issue is asserted to be fixed in a test. Those examples aren't doing exactly this.

I'll be the first one asserting that platform channels are being used from the correct thread. Mocking out platform channels will be a poor substitute for asserting proper platform channel usage across all channels though.

We'd get that with a debug engine, but that's outside of the scope of this PR. It also doesn't solve the problem for 3p customers either since they should have access to this kind of testing without having to build a debug engine.

I'll see if I can come up with a mocking unit test in the meantime.

Do the engine builders publish those artifacts?

I don't think so.

@gaaclarke
Copy link
Member Author

@stuartmorgan I looked into adding a test at /Users/aaclarke/dev/packages/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests. Those tests fail to link:

ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[10](GoogleMapPolylineController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[9](GoogleMapPolygonController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[8](GoogleMapMarkerController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[7](GoogleMapController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[6](GoogleMapCircleController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[5](google_maps_flutter_ios-dummy.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[4](FLTGoogleMapTileOverlayController.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[3](FLTGoogleMapsPlugin.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/aaclarke/Library/Developer/Xcode/DerivedData/Runner-cfyxahhvdbsudtbrisrwbppvdqok/Build/Products/Debug-iphonesimulator/google_maps_flutter_ios/libgoogle_maps_flutter_ios.a[2](FLTGoogleMapJSONConversions.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: Undefined symbols:
  _OBJC_CLASS_$_FLTGoogleMapsPlugin, referenced from:
       in GeneratedPluginRegistrant.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Let me know if there exists a better place to test or if I'm running these wrong.

@gaaclarke
Copy link
Member Author

So we do serve debug builds, but they are jit. So I'm not sure if that will work.

@stuartmorgan-g
Copy link
Contributor

Right, the point is that the code in this PR has test coverage.

I'm not sure why you are asserting things that aren't in dispute and aren't related to the policy for test exemptions. The policy is that changes need to be tested, and this change is not being tested, as evidenced by the fact that no tests are failing in our CI without this PR.

Let me know if there exists a better place to test or if I'm running these wrong.

It looks like you may have an old Cocoapods cache, and are getting an old version of Google Maps even with the iOS 14 example. If so you could update Cocoapods locally, but since this isn't iOS-version specific, it should be in the oldest iOS example per the README in the enclosing directory (which will avoid the issue altogether).

@gaaclarke
Copy link
Member Author

Test against the private API has been added. I still urge the plugin maintainers to consider a more holistic solution to testing the thread safety of platform channels. @hellohuanlin PTAL

@hellohuanlin
Copy link
Contributor

haven't reviewed yet. it doesn't seem to be related to the linked issue. if so, maybe a good idea to create a new issue about calling method channel on the wrong thread, in case of confusion to future readers.

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

i could be missing something, but this doesn't seem to be related to the linked issue on tiles not being displayed, but it's rather a separate issue that you discovered while researching it? Could you update the PR description and maybe link to a new issue, in case of confusion to future readers?


@implementation FLTTileProviderControllerTests

- (void)testCallChannelOnPlatformThread {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: include function name being tested testRequestTileMustCallChannelOnPlatformThread

XCTestExpectation *expectation = [self expectationWithDescription:@"invokeMethod"];
OCMStub([channel invokeMethod:[OCMArg any] arguments:[OCMArg any] result:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
XCTAssertTrue([[NSThread currentThread] isMainThread]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: XCTAssertTrue([[NSThread currentThread] isMainThread], @"Method channel must be called on main thread")

[expectation fulfill];
});
id receiver = OCMProtocolMock(@protocol(GMSTileReceiver));
[controller requestTileForX:0 y:0 zoom:0 receiver:receiver];
Copy link
Contributor

@hellohuanlin hellohuanlin Feb 9, 2024

Choose a reason for hiding this comment

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

nit: can just inline this receiver?

@gaaclarke
Copy link
Member Author

i could be missing something, but this doesn't seem to be related to the linked issue on tiles not being displayed, but it's rather a separate issue that you discovered while researching it?

I cannot rule out that it isn't applicable. This PR fixes a race condition and how it manifests is difficult for me to guess. It may result in lost message or crashes.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM

@jmagman
Copy link
Member

jmagman commented Feb 14, 2024

Looks like once the CHANGELOG conflict is resolved, this is ready to be merged?

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 14, 2024
@gaaclarke
Copy link
Member Author

Looks like once the CHANGELOG conflict is resolved, this is ready to be merged?

rebased and put in the queue

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 14, 2024
Copy link
Contributor

auto-submit bot commented Feb 14, 2024

auto label is removed for flutter/packages/6069, due to - The status or check suite Linux repo_checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 5, 2024
Copy link
Contributor

auto-submit bot commented Mar 5, 2024

auto label is removed for flutter/packages/6069, due to - The status or check suite Linux_web web_build_all_packages master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 5, 2024
@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 14, 2024
@auto-submit auto-submit bot merged commit 2218300 into flutter:main Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 15, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 15, 2024
flutter/packages@b21c542...756dcc1

2024-03-15 [email protected] [go_router] Use `leak_tracker_flutter_testing`  (flutter/packages#6210)
2024-03-15 [email protected] [camera_web][google_maps_flutter] Fix tests throwing errors after test completion with manual roll (flutter/packages#6318)
2024-03-14 [email protected] [pigeon] Fixes double prefixes added to enum names for Objc HostApis and FlutterApis (flutter/packages#6263)
2024-03-14 [email protected] [webview_flutter_android][webview_flutter_wkwebview] Adds platform implementations for onHttpError (flutter/packages#6149)
2024-03-14 [email protected] [image_picker_android] Fix deprecation warnings by branching based on build version, and suppressing only when needed (flutter/packages#6233)
2024-03-14 [email protected] [google_maps_flutter] Started dispatching platform messages from platform thread (flutter/packages#6069)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
…form thread (flutter#6069)

Issue: flutter/flutter#135252

Testing: This adds no new functionality and thus should be covered in tests.  The problem is that we are permissive to unsafe platform channel usage in the release flutter engine.  We should maybe consider running tests against a debug version of the engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: google_maps_flutter platform-ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants