packages icon indicating copy to clipboard operation
packages copied to clipboard

[Camera] Add lens type information (iOS)

Open lenzpaul opened this issue 1 year ago • 16 comments
trafficstars

This PR adds lens type information. The goal is to identify whether the lens type is wide, ultra-wide, telephoto, etc., as discussed in https://github.com/flutter/flutter/issues/119908. The iOS implementation is complete, so lens data will now be populated on iOS.

  • Introduces a new CameraLensType enum to provide lens type information about the camera (e.g.: ultra-wide, telephoto, ...)
  • Adds lensType in the PlatformCameraDescription and CameraDescription classes
  • Implements utility functions to convert between PlatformCameraLensType and CameraLensType.
  • Updates auto-generated code (using Pigeon) to reflect these changes.

Current CameraDescription for iPhone 11

[
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:0,
        CameraLensDirection.back,
        90
    ),
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:1,
        CameraLensDirection.front,
        90
    ),
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:5,
        CameraLensDirection.back,
        90
    )
]

New CameraDescription for iPhone 11

[
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:0,
        CameraLensDirection.back,
        90,
        CameraLensType.wide
    ),
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:1,
        CameraLensDirection.front,
        90,
        CameraLensType.wide
    ),
    CameraDescription(
        com.apple.avfoundation.avcapturedevice.built-in_video:5,
        CameraLensDirection.back,
        90,
        CameraLensType.ultraWide
    )
]

Pre-launch Checklist

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

lenzpaul avatar Sep 16 '24 20:09 lenzpaul

Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins for information on how to make this PR pass CI checks, which is important for review.

stuartmorgan-g avatar Sep 17 '24 16:09 stuartmorgan-g

Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins for information on how to make this PR pass CI checks, which is important for review.

I made changes as specified by the docs, please let me if there's anything else I need to do

lenzpaul avatar Sep 18 '24 15:09 lenzpaul

  • [x] All existing and new tests are passing.

This PR is currently failing a substantial number of our CI checks, so this checkbox state is not accurate. If you click through the details of each CI task failure you can see the specific issues that will need to be fixed before this would be ready for review.

stuartmorgan-g avatar Sep 18 '24 16:09 stuartmorgan-g

Hi @stuartmorgan, I fixed tests and most CI errors.

One of the remaining errors is related to versions and the changelog not being updated. But I think that some packages don't require version bumps since there are no changes. Could you confirm if this assumption is correct?

  • camera_avfoundation, camera_platform_interface: Version already bumped and CHANGELOG.md updated.
  • camera, camera_android, camera_android_camerax, camera_web, camera_windows: No changes, no version bump needed.

The other issue is with formatting. I ran the format command using Flutter Plugin Tools, but there's still an error in camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/QueueUtils.h. Should I manually update the formatting for this file?

lenzpaul avatar Sep 21 '24 17:09 lenzpaul

But I think that some packages don't require version bumps since there are no changes. Could you confirm if this assumption is correct?

Yes; for packages that don't require any changes at all, you can just revert the dependency_override changes in those packages, at which point the CI will stop flagging them as issue.

The other issue is with formatting. I ran the format command using Flutter Plugin Tools, but there's still an error in camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/QueueUtils.h. Should I manually update the formatting for this file?

This is probably due to a clang-format difference between your local tools and the CI; the CI is the authoritative version, so you'll need to match it by hand in this case, yes.

stuartmorgan-g avatar Sep 27 '24 14:09 stuartmorgan-g

From triage: @lenzpaul Are you still planning on the discussion related to the enum values?

stuartmorgan-g avatar Dec 10 '24 20:12 stuartmorgan-g

Note that there seems to be an error in the CI related to Package.resolved. I'm not sure how to resolve this. Could this maybe be related to the XCode version on the build machine? XCode 16.2 was just released...

lenzpaul avatar Dec 18 '24 19:12 lenzpaul

Hi @stuartmorgan, this is now approved by @hellohuanlin. What are the next steps to merge it? And when would this be available for us to use? Thanks!

lenzpaul avatar Jan 07 '25 15:01 lenzpaul

What are the next steps to merge it?

The cross-platform aspects (especially this discussion) still need to be reviewed by @bparrishMines

And when would this be available for us to use?

I'm not sure what you are asking exactly; when it lands depends on the review process, so I can't provide a date.

stuartmorgan-g avatar Jan 07 '25 16:01 stuartmorgan-g

I'm unsubscribing from this, since as @lenzpaul mentioned in his compatibility table, this is not supported at all on the web platform. The web changes are only "pathified" dependencies so this PR can run tests.

ditman avatar Jan 07 '25 21:01 ditman

@stuartmorgan I noticed is that camera_platform_interface 2.9.0 was released so I think I should bump my change to 2.10.0?

Is there anything I'd need to do to make this pass?

lenzpaul avatar Jan 21 '25 17:01 lenzpaul

@lenzpaul The analyze error should have been fixed by https://github.com/flutter/packages/pull/8344/files. You should be able to merge in main to fix it.

bparrishMines avatar Jan 22 '25 21:01 bparrishMines

@stuartmorgan @bparrishMines @ditman FYI I created https://github.com/flutter/packages/pull/8723

lenzpaul avatar Feb 26 '25 16:02 lenzpaul

Status update from triage: The platform interface PR landed, so this is waiting for the implementation package PR to be extracted.

stuartmorgan-g avatar Apr 01 '25 19:04 stuartmorgan-g

From triage: based on Discord discussion, updating this for the camera Swift conversion is in progress

stuartmorgan-g avatar May 13 '25 19:05 stuartmorgan-g

From triage: the camera Swift conversion churn should be nearly complete; we will revisit this after that.

stuartmorgan-g avatar Jun 24 '25 18:06 stuartmorgan-g

Greetings from stale PR triage! 👋 Is this still waiting on Swift conversion churn?

Piinks avatar Aug 25 '25 21:08 Piinks

The relevant code has been converted to Swift, so this just needs to be reconciled against the current source and then can be landed.

stuartmorgan-g avatar Aug 26 '25 11:08 stuartmorgan-g

I reconciled this with the changes that have landed in the meantime, most notably the native code file that was changed to Swift and the introduction of the protocols around the SDK types. @hellohuanlin Could you review my conversion of the CameraPlugin changes to Swift?

stuartmorgan-g avatar Sep 26 '25 20:09 stuartmorgan-g

Thanks again @lenzpaul ! Sorry that the timing of this PR and the Swift migration ended up causing this to take a lot of extra time to land.

stuartmorgan-g avatar Oct 02 '25 15:10 stuartmorgan-g

Great to see this merged! Thanks for your help with this

lenzpaul avatar Oct 24 '25 18:10 lenzpaul