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

[camera] Initial iOS Pigeon conversion #6553

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

stuartmorgan
Copy link
Contributor

Converts one platform channel method to Pigeon, setting up all the Pigeon plumbing and test scaffolding.

The Camera API surface is relatively large, so this lays a foundation for incremental conversion, minimizing the mixing of Pigeon setup with the individual method conversions.

Part of flutter/flutter#117905

Pre-launch Checklist

Converts one platform channel method to Pigeon, setting up all the
Pigeon plumbing and test scaffolding.

The Camera API surface is relatively large, so this lays a foundation
for incremental conversion, minimizing the mixing of Pigeon setup with
the individual method conversions.

Part of flutter/flutter#117905
@@ -15,8 +15,7 @@ @implementation AvailableCamerasTest

- (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone {
CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil];
XCTestExpectation *expectation =
[[XCTestExpectation alloc] initWithDescription:@"Result finished"];
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change to the utility method allows using waitForExpectationsWithTimeout: instead of having to list every expectation.

resultValue = result;
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why we weren't actually using the expectation before, but now it's necessary because the queue dispatch isn't being bypassed in the test like it was before, so the block above is no longer run synchronously in the test.

if (@available(iOS 13.0, *)) {
XCTAssertTrue([dictionaryResult count] == 4);
XCTAssertEqual(resultValue.count, 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a quality of life improvement for when the test fails. (I had a failure initially because I didn't add the wait, so resultValue was nil, and I got a failure with no actual info.)

FlutterError *_Nullable))completion {
// This doesn't interact with FLTCam, so can use an arbitrary thread rather than
// captureSessionQueue. It should still not be done on the main thread, however.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will unfortunately need to have the thread dispatch in every individual method in the Pigeon version (instead of handleMethodCall doing it for everything at once). Almost everything needs to use captureSessionQueue, since FLTCam sometimes needs to redispatch to that queue in internal callbacks to interact with instance state, which means we can't just use task queues.

(Also IIRC task queues aren't implemented for macOS, and we want to enable this plugin for macOS at some point.)

It'll just be a couple of lines in each method though, so it shouldn't be too bad. I think we can simplify when we migrate to Swift.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's still better to use captureSessionQueue for all session configurations, in case Apple made any assumptions in its internal implementation (e.g. I wouldn't be surprised if multiple capture session related API access some common internal states).

(AVCaptureDeviceDiscoverySession's API doc doesn't say anything, but Apple's sample project uses this convention)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. It hadn't occurred to me that in theory the unique device IDs could be thread-specific; that would be weird, but not implausible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya I bet we should be fine either way, but just wanna be extra safe here.

CameraLensDirection.external,
);
});

test(
'Should throw ArgumentException when invalid value is supplied when parsing camera lens direction',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer possible, so we don't need a test for it.

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2024
@auto-submit auto-submit bot merged commit ba1e24b into flutter:main Apr 17, 2024
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 18, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 18, 2024
flutter/packages@d39830e...0e3809d

2024-04-18 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.0 to 3.25.1 (flutter/packages#6562)
2024-04-18 [email protected] [ci] Add Linux desktop support to Linux custom_package_tests (flutter/packages#6551)
2024-04-17 [email protected] [two_dimensional_scrollables] Refactor Spans for common use (flutter/packages#6550)
2024-04-17 [email protected] [in_app_purchase] Add api to expose country code (flutter/packages#6540)
2024-04-17 [email protected] [camera] Initial iOS Pigeon conversion (flutter/packages#6553)
2024-04-17 [email protected] [in_app_purchase] Add countryCode implementation to android and storekit (flutter/packages#6556)
2024-04-17 [email protected] [google_sign_in_ios] Upgrade GoogleSignIn iOS SDK to 7.1 (flutter/packages#6404)
2024-04-17 [email protected] [in_app_purchase_platform_interface] Adds countryCode API (flutter/packages#6548)
2024-04-17 [email protected] [google_maps_flutter] Update app-facing package iOS requirements (flutter/packages#6552)

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
@@ -20,13 +20,15 @@ dependencies:
camera_platform_interface: ^2.7.0
flutter:
sdk: flutter
pigeon: ^18.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it come as dev dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see #6563

@stuartmorgan stuartmorgan deleted the camera-ios-pigeon branch April 18, 2024 18:29
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
flutter/packages@d39830e...0e3809d

2024-04-18 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.0 to 3.25.1 (flutter/packages#6562)
2024-04-18 [email protected] [ci] Add Linux desktop support to Linux custom_package_tests (flutter/packages#6551)
2024-04-17 [email protected] [two_dimensional_scrollables] Refactor Spans for common use (flutter/packages#6550)
2024-04-17 [email protected] [in_app_purchase] Add api to expose country code (flutter/packages#6540)
2024-04-17 [email protected] [camera] Initial iOS Pigeon conversion (flutter/packages#6553)
2024-04-17 [email protected] [in_app_purchase] Add countryCode implementation to android and storekit (flutter/packages#6556)
2024-04-17 [email protected] [google_sign_in_ios] Upgrade GoogleSignIn iOS SDK to 7.1 (flutter/packages#6404)
2024-04-17 [email protected] [in_app_purchase_platform_interface] Adds countryCode API (flutter/packages#6548)
2024-04-17 [email protected] [google_maps_flutter] Update app-facing package iOS requirements (flutter/packages#6552)

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
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
Converts one platform channel method to Pigeon, setting up all the Pigeon plumbing and test scaffolding.

The Camera API surface is relatively large, so this lays a foundation for incremental conversion, minimizing the mixing of Pigeon setup with the individual method conversions.

Part of flutter/flutter#117905
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
Converts one platform channel method to Pigeon, setting up all the Pigeon plumbing and test scaffolding.

The Camera API surface is relatively large, so this lays a foundation for incremental conversion, minimizing the mixing of Pigeon setup with the individual method conversions.

Part of flutter/flutter#117905
yaakovschectman added a commit that referenced this pull request Oct 9, 2024
Convert one method to use Pigeon to setup the backbone of future
conversions. Android analog of
#6553

Part of flutter/flutter#117905

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] page, which explains my
responsibilities.
- [x] I read and followed the [relevant style guides] and ran the
auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages
repo does use `dart format`.)
- [ ] I signed the [CLA].
- [x] The title of the PR starts with the name of the package surrounded
by square brackets, e.g. `[shared_preferences]`
- [x] I [linked to at least one issue that this PR fixes] in the
description above.
- [x] I updated `pubspec.yaml` with an appropriate new version according
to the [pub versioning philosophy], or this PR is [exempt from version
changes].
- [x] I updated `CHANGELOG.md` to add a description of the change,
[following repository CHANGELOG style], or this PR is [exempt from
CHANGELOG changes].
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[relevant style guides]:
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style
[CLA]: https://cla.developers.google.com/
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
[linked to at least one issue that this PR fixes]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[pub versioning philosophy]: https://dart.dev/tools/pub/versioning
[exempt from version changes]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version
[following repository CHANGELOG style]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style
[exempt from CHANGELOG changes]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
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: camera platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants