-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[camera] Finish converting iOS to Pigeon #6601
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] Finish converting iOS to Pigeon #6601
Conversation
[_camera setDescriptionWhileRecording:(call.arguments[@"cameraName"]) result:result]; | ||
} else if ([@"setImageFileFormat" isEqualToString:call.method]) { | ||
NSString *fileFormat = call.arguments[@"fileFormat"]; | ||
[_camera setImageFileFormat:FCPGetFileFormatFromString(fileFormat)]; |
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 was never calling result
(and it doesn't pass it in to the implementation), so that wasn't good :|
|
||
- (void)disposeCamera:(NSInteger)cameraId | ||
completion:(nonnull void (^)(FlutterError *_Nullable))completion { | ||
[_registry unregisterTexture:cameraId]; |
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 made me remove the thread abstraction around the registry—this was one of two meaningful uses of the wrapper, and it was wrong. The old code was calling this in the async handler, which means it was effectively in the captureSessionQueue
dispatch block below. But it was internally moving the call back to the main thread, which while correct, was not awaited before continuing. That meant that unregistering the texture—which ensures that the engine won't keep asking for textures—was not reliably being done before tearing down the camera on the session queue.
It may have worked out later due to the way thread redispatch is done when actually doing the copy, but I didn't try to unwind that since it's clearly better to do in this order.
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.
good call!
- (void)resumeVideoRecording; | ||
- (void)lockCaptureOrientation:(FCPPlatformDeviceOrientation)orientation; | ||
- (void)unlockCaptureOrientation; | ||
- (void)setFlashMode:(FCPPlatformFlashMode)mode |
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 fixed a bunch of weird/unidiomatic naming while touching these signatures.
|
||
/// Sets the exposure point, in a (0,1) coordinate system. | ||
/// | ||
/// If @c point is nil, the exposure point will reset to the center. |
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 logic was in CameraPlugin, but I moved it into this class now that it was easy to pass nil through using the new class.
result(@(_camera.captureDevice.minExposureTargetBias)); | ||
} else if ([@"getMaxExposureOffset" isEqualToString:call.method]) { | ||
result(@(_camera.captureDevice.maxExposureTargetBias)); | ||
} else if ([@"getExposureOffsetStepSize" isEqualToString:call.method]) { |
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 method does not exist in the Pigeon version because hard-coding 0 as the return value is trivial to do in Dart.
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 went through a pretty thorough review and everything looks very clean
|
||
- (void)disposeCamera:(NSInteger)cameraId | ||
completion:(nonnull void (^)(FlutterError *_Nullable))completion { | ||
[_registry unregisterTexture:cameraId]; |
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.
good call!
flutter/packages@cf6d280...fde908d 2024-04-25 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.3 to 4.1.4 (flutter/packages#6609) 2024-04-24 [email protected] [go_router] Add `GoRouterState state` parameter to `GoRouterData.onExit` (flutter/packages#6495) 2024-04-24 [email protected] Add CI steps to test iOS and macOS plugins with both CocoaPods and Swift Package Manager (flutter/packages#6557) 2024-04-24 [email protected] Roll Flutter from 77043ba to dba4f77 (30 revisions) (flutter/packages#6607) 2024-04-24 [email protected] [camera] Finish converting iOS to Pigeon (flutter/packages#6601) 2024-04-24 [email protected] [go_router] Fixes an issue where route future does not complete when � (flutter/packages#6596) 2024-04-24 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (#6591)" (flutter/packages#6605) 2024-04-23 [email protected] [in_app_purchase_android] Readme update for Alternative billing (flutter/packages#6578) 2024-04-23 [email protected] Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (flutter/packages#6591) 2024-04-23 [email protected] Roll Flutter from 140edb9 to 77043ba (21 revisions) (flutter/packages#6599) 2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/packages#6597) 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
Converts all remaining Dart->host communication in the iOS implementation to use Pigeon. Given the boilerplate nature of many of the changes, it seemed easiest to just do the remaining calls all at once now that the structure is in place. Some high-level notes: - Many methods used to send the `cameraId` without it ever being used on the native side, so the Pigeon versions do not send them. - `ThreadSafeTextureRegistry` is removed because I discovered that it was masking a bug, so was more trouble than it was worth (see inline comments in PR). - A number of enums have been removed in favor of using the Pigeon-generated enums to pass data from the plugin class to `FLTCam`. - In many cases where the completion callback (previously `result`) was being passed to `FLTCam` in a call, only to have it always just call `result(nil)`, that's now done in the plugin class since it's easier to reason about completions being called when they aren't passed around. (Long term we should consider moving almost all of the rest out, and using `FlutterError*` out params that the plugin class passes to `completion`, but that is more surgery than I wanted to do in this PR.) Completes the iOS portion of flutter/flutter#117905
Add structured types and convert implementations to use typesafe method calls for platform methods from Dart to native side. Android analog of #6601 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
Converts all remaining Dart->host communication in the iOS implementation to use Pigeon. Given the boilerplate nature of many of the changes, it seemed easiest to just do the remaining calls all at once now that the structure is in place.
Some high-level notes:
cameraId
without it ever being used on the native side, so the Pigeon versions do not send them.ThreadSafeTextureRegistry
is removed because I discovered that it was masking a bug, so was more trouble than it was worth (see inline comments in PR).FLTCam
.result
) was being passed toFLTCam
in a call, only to have it always just callresult(nil)
, that's now done in the plugin class since it's easier to reason about completions being called when they aren't passed around. (Long term we should consider moving almost all of the rest out, and usingFlutterError*
out params that the plugin class passes tocompletion
, but that is more surgery than I wanted to do in this PR.)Completes the iOS portion of flutter/flutter#117905
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.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.