Skip to content

[camera] Convert iOS event channel to Pigeon#11109

Merged
auto-submit[bot] merged 5 commits intoflutter:mainfrom
stuartmorgan-g:camera-ios-pigeon-event-channel
Feb 25, 2026
Merged

[camera] Convert iOS event channel to Pigeon#11109
auto-submit[bot] merged 5 commits intoflutter:mainfrom
stuartmorgan-g:camera-ios-pigeon-event-channel

Conversation

@stuartmorgan-g
Copy link
Collaborator

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 the camera_avfoundation_objc no longer exists.

Fixes flutter/flutter#182542

Pre-Review Checklist

Footnotes

  1. 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

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

@gemini-code-assist
Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

}

var lensAperture: Float { 0 }
var lensAperture: Float { 1.8 }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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
Copy link
Collaborator 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 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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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).

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 25, 2026
@auto-submit auto-submit bot merged commit 7fe183f into flutter:main Feb 25, 2026
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 26, 2026
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Feb 26, 2026
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
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Feb 26, 2026
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
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
…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
xxxOVALxxx pushed a commit to xxxOVALxxx/flutter that referenced this pull request Mar 10, 2026
…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
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.

[camera_avfoundation] Migration to pigeon event channel

2 participants