[camera] Convert iOS event channel to Pigeon#11109
[camera] Convert iOS event channel to Pigeon#11109auto-submit[bot] merged 5 commits intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
The pull request successfully migrates the iOS event channel to use Pigeon for type-safe image streaming. This change improves code quality by leveraging Pigeon's type safety, which was previously blocked due to Swift migration. The removal of camera_avfoundation_objc imports and related test files indicates a good cleanup of dead code. The changes to CHANGELOG.md and pubspec.yaml are also appropriate. I've identified a few areas for improvement regarding mock values and consistency in test assertions.
packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj
Show resolved
Hide resolved
packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDevice.swift
Show resolved
Hide resolved
packages/camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift
Show resolved
Hide resolved
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
Show resolved
Hide resolved
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
Show resolved
Hide resolved
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
| } | ||
|
|
||
| var lensAperture: Float { 0 } | ||
| var lensAperture: Float { 1.8 } |
There was a problem hiding this comment.
I changed these to more realistic values to make the updated tests easier to write (see comment there).
| // found in the LICENSE file. | ||
|
|
||
| @testable import camera_avfoundation | ||
| import UIKit |
There was a problem hiding this comment.
I'm not sure why we were getting away without this before; it should be here because of the UIDeviceOrientation usage, and it caused compile issues for me.
| XCTAssertGreaterThan(imageBuffer.formatCode, 0) | ||
| XCTAssertGreaterThan(imageBuffer.lensAperture, 0) | ||
| XCTAssertGreaterThan(imageBuffer.sensorExposureTimeNanoseconds, 0) | ||
| XCTAssertGreaterThan(imageBuffer.sensorSensitivity, 0) |
There was a problem hiding this comment.
I did these as GreaterThan because it was the easiest upgrade from the very loose is NSNumber tests that was not worthless (checking the types would be pointless now that it's structured data). Ideally we would check that the correct values come through, but the way the mocks are set up with hard-coded values, it would require non-trivial restructuring of the tests (to allow passing in values from here) to do anything other than check magic numbers from another file, and I didn't want to make significant test changes with the implementation change.
| ImageDataStreamStreamHandler.register(with: messenger, streamHandler: imageStreamHandler) | ||
| self.imageStreamHandler = imageStreamHandler | ||
| self.captureSessionQueue.async { [weak self] in | ||
| if let self = self { |
There was a problem hiding this comment.
Slightly restructured here to avoid having two different completion codepaths.
| self.imageStreamHandler = imageStreamHandler | ||
| threadSafeEventChannel.setStreamHandler(imageStreamHandler) { [weak self] in | ||
| guard let strongSelf = self else { | ||
| ensureToRunOnMainQueue { [weak self] in |
There was a problem hiding this comment.
This replaces the entire thread-safe event channel subclass we used to have. This was the only thing we were doing that needed to be on the main thread that wasn't already dispatched to the main thread, so rewriting the whole thread safe class structure for Pigeon seemed like overkill.
|
|
||
| ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) { | ||
| ImageFormatGroup _imageFormatGroupFromPlatformImageFormat(int data) { | ||
| switch (data) { |
There was a problem hiding this comment.
Normally I would make the enum part of the Pigeon definition, but since we are also passing the raw code through the public API anyway I didn't bother. I could do both though if anyone prefers that; it would have the slight advantage we wouldn't need magic numbers in this file (even though they would still be passed out publicly).
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
Outdated
Show resolved
Hide resolved
flutter/packages@acd9adb...e1d0169 2026-02-26 [email protected] [rfw] Remove outdated info from README (flutter/packages#11123) 2026-02-25 [email protected] [local_auth] Federate READMEs (flutter/packages#11112) 2026-02-25 [email protected] [google_sign_in] Remove usersCleartextTraffic (flutter/packages#11121) 2026-02-25 [email protected] Tidy up some contributing text, and note tools needed for formatting. (flutter/packages#11113) 2026-02-25 [email protected] [video_player_android] Remove usesCleartextTraffic (flutter/packages#11075) 2026-02-25 [email protected] Adjust the version/changelog checklist entries (flutter/packages#11120) 2026-02-25 [email protected] [camera] Convert iOS event channel to Pigeon (flutter/packages#11109) 2026-02-25 8490712[email protected] [camera] add video stabilization (flutter/packages#7108) 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] 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
flutter/packages@acd9adb...e1d0169 2026-02-26 [email protected] [rfw] Remove outdated info from README (flutter/packages#11123) 2026-02-25 [email protected] [local_auth] Federate READMEs (flutter/packages#11112) 2026-02-25 [email protected] [google_sign_in] Remove usersCleartextTraffic (flutter/packages#11121) 2026-02-25 [email protected] Tidy up some contributing text, and note tools needed for formatting. (flutter/packages#11113) 2026-02-25 [email protected] [video_player_android] Remove usesCleartextTraffic (flutter/packages#11075) 2026-02-25 [email protected] Adjust the version/changelog checklist entries (flutter/packages#11120) 2026-02-25 [email protected] [camera] Convert iOS event channel to Pigeon (flutter/packages#11109) 2026-02-25 8490712[email protected] [camera] add video stabilization (flutter/packages#7108) 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] 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
…r#182946) flutter/packages@acd9adb...e1d0169 2026-02-26 [email protected] [rfw] Remove outdated info from README (flutter/packages#11123) 2026-02-25 [email protected] [local_auth] Federate READMEs (flutter/packages#11112) 2026-02-25 [email protected] [google_sign_in] Remove usersCleartextTraffic (flutter/packages#11121) 2026-02-25 [email protected] Tidy up some contributing text, and note tools needed for formatting. (flutter/packages#11113) 2026-02-25 [email protected] [video_player_android] Remove usesCleartextTraffic (flutter/packages#11075) 2026-02-25 [email protected] Adjust the version/changelog checklist entries (flutter/packages#11120) 2026-02-25 [email protected] [camera] Convert iOS event channel to Pigeon (flutter/packages#11109) 2026-02-25 8490712[email protected] [camera] add video stabilization (flutter/packages#7108) 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] 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
…r#182946) flutter/packages@acd9adb...e1d0169 2026-02-26 [email protected] [rfw] Remove outdated info from README (flutter/packages#11123) 2026-02-25 [email protected] [local_auth] Federate READMEs (flutter/packages#11112) 2026-02-25 [email protected] [google_sign_in] Remove usersCleartextTraffic (flutter/packages#11121) 2026-02-25 [email protected] Tidy up some contributing text, and note tools needed for formatting. (flutter/packages#11113) 2026-02-25 [email protected] [video_player_android] Remove usesCleartextTraffic (flutter/packages#11075) 2026-02-25 [email protected] Adjust the version/changelog checklist entries (flutter/packages#11120) 2026-02-25 [email protected] [camera] Convert iOS event channel to Pigeon (flutter/packages#11109) 2026-02-25 8490712[email protected] [camera] add video stabilization (flutter/packages#7108) 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] 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
Replaces direct event channel usage with type-safe Pigeon event channels now that the plugin has been migrated to Swift (Pigeon doesn't have event channel support in the Obj-C generator, so this had been blocked).
Also includes opportunistic cleanup of conditional import of
camera_avfoundation_objc, since I noticed it in the files I was working in; this is dead code now that the Swift migration is complete, because thecamera_avfoundation_objcno longer exists.Fixes flutter/flutter#182542
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3