Skip to content

[camera] Add macOS support #41708

Open
Open

Description

@stuartmorgan-g

Since laptops commonly have cameras built in, this would be potentially useful.

Blocked on #30717

Activity

  1. added
    P3Issues that are less important to the Flutter project
    on Jun 10, 2020
  2. larryaasen commented on Oct 21, 2020

    @larryaasen
  3. larryaasen commented on Oct 19, 2021

    @larryaasen
  4. stuartmorgan-g commented on Oct 19, 2021

    @stuartmorgan-g
    Author
  5. larryaasen commented on Oct 19, 2021

    @larryaasen
  6. stuartmorgan-g commented on Oct 19, 2021

    @stuartmorgan-g
    Author
  7. larryaasen commented on Oct 19, 2021

    @larryaasen
  8. stuartmorgan-g commented on Oct 19, 2021

    @stuartmorgan-g
    Author
  9. mykola-blu commented on Jun 6, 2022

    @mykola-blu
  10. moham96 commented on Aug 19, 2022

    @moham96
  11. 20 remaining items

  12. naedx commented on Jun 10, 2024

    @naedx
  13. cdeil commented on Mar 12, 2026

    @cdeil

    @stuartmorgan-g - Should camera MacOS support be implemented by extending camera_avfoundation ? Are there any blockers/refactors that should be done before adding it? Is it possible to only support MacOS 26 or would we have to make it work and test on older versions to be accepted?

  14. stuartmorgan-g commented on Mar 12, 2026

    @stuartmorgan-g
    ContributorAuthor

    Should camera MacOS support be implemented by extending camera_avfoundation ?

    Yes. See the diffs from my comment above as an (outdated) example of the expected approach.

    Are there any blockers/refactors that should be done before adding it?

    I'm not aware of any blockers, but the issues with my initial WIP were never investigated so it's possible there's an unknown issue. I would not expect one though, given the other plugins that are already support macOS.

    Is it possible to only support MacOS 26 or would we have to make it work and test on older versions to be accepted?

    I am not aware of anything that has changed since my initial prototype, which compiled all the way back to 10.15, that would make limiting support to 26 useful.

  15. cdeil commented on Mar 13, 2026

    @cdeil

    I'll take a stab at this. I only have a MacBook with MacOS 26 locally, so can't do real-device testing on older platforms.

  16. cdeil commented on Mar 13, 2026

    @cdeil

    I did a spike with a coding agent to add MacOS support. Branch is HERE .

    It's partially working on MacOS. Photos and preview is showing but preview is rotated by 90 deg (and photo 90 deg rotated the other direction for iPhone continuity camera shown in MacOS) for so far unknown reason. Haven't tested yet at audio or recorded videos.

    @stuartmorgan-g - I presume one huge PR isn't a good idea? Maybe refactor to shared Darwin layout and refactoring core camera_avfoundation classes that are iOS specific as first step? Or some other approach?

    Image
  17. stuartmorgan-g commented on Mar 13, 2026

    @stuartmorgan-g
    ContributorAuthor

    Maybe refactor to shared Darwin layout and refactoring core camera_avfoundation classes that are iOS specific as first step? Or some other approach?

    Converting from ios/ to darwin/ should be its own PR without any other changes, because combining moves with non-trivial edits causes git to think files are being deleted and created, destroying history.

    Without knowing anything about the scope of the changes beyond that, I don't know if one PR or multiple PRs makes more sense. If you are asking me to review the branch you linked to make that determination, please see our AI contribution guidelines; we aren't going to review raw AI output.

  18. cdeil commented on Mar 13, 2026

    @cdeil

    Rotation issue fixed ( flutter/packages@afb6179 ) by using AVCaptureConnection.videoRotationAngle (available macOS 14.0+) instead of the deprecated videoOrientation enum. For me in the example app now everything basic seems to work (images, videos, preview, audio for internal/USB/continuity cameras).

    That branch was just an exploration if I can get it to work and if the shared darwin approach is a good one. I think the answer is "yes" so I'll start with a PR that just does the ios to darwin conversion to hopefully preserve git history on every file.

  19. stuartmorgan-g commented on Mar 16, 2026

    @stuartmorgan-g
    ContributorAuthor

    if the shared darwin approach is a good one

    Shared darwin source is still how we handle plugins that can share most of their source code, yes.

  20. Mairramer commented on May 31, 2026

    @Mairramer
    Contributor

    @cdeil Are you still working on this?

    I'm currently building a PoC for camera effects on both iOS and Android, and while investigating it I ran into the lack of camera support on macOS. Your implementation looks promising, so I was curious whether it's still being actively developed.

  21. Mairramer commented on Jun 1, 2026

    @Mairramer
    Contributor

    Hello @stuartmorgan,

    I'm currently working locally on adding macOS support to camera_avfoundation based on the previous experiments. To make this migration as safe and reviewable as possible, I'd like to propose splitting the work into three focused PRs instead of one large PR. This structure could also be useful if someone else decides to contribute the same effort in the future.

    The goal is to preserve Git history where possible and isolate risk:

    PR 1: Directory Rename Only (ios → darwin)

    This PR would contain only the directory move (git mv ios darwin) and the corresponding sharedDarwinSource: true configuration change, with no functional code changes.

    PR 2: iOS Platform/UI Abstractions

    This PR would introduce the necessary #if os(iOS) guards to isolate UIKit-specific dependencies (such as UIDeviceOrientation) from the core AVFoundation logic. It could be validated entirely on iOS, ensuring that existing behavior remains unchanged and minimizing the risk of regressions.

    PR 3: macOS Implementation

    The final PR would add the macOS deployment configuration, camera entitlements, and macOS-specific handling for hardware rotation (videoRotationAngle). If any unexpected macOS issues arise, this PR could be reverted independently without affecting the directory modernization introduced in the previous PRs.

    WDYT?

  22. stuartmorgan-g commented on Jun 1, 2026

    @stuartmorgan-g
    ContributorAuthor

    As established in the comments just above, what you labelled as PR 1 must be a separate PR. PR 2 sounds fine as well.

    As I said above, whether what you describe as PR 3 should actually be one PR or multiple PRs depends on how large that is, and how separable the parts are.

  23. cdeil commented on Jun 4, 2026

    @cdeil

    @Mairramer - thanks for taking this on! I didn't submit PRs for this since I'm still learning about AVFoundation and Flutter and didn't feel that I met the bar set by the AI contribution guideline. My impression was that coding agents give a good solution directly here, but I wasn't sure e.g. if there's some non-obvious differences in MacOS vs iOS lifecycles or cases that would need to be handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopc: new featureNothing broken; request for a new capabilityhas partial patchThere is a PR awaiting someone to take it across the finish linep: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-macosBuilding on or for macOS specificallyteam-macosOwned by the macOS platform teamtriaged-macosTriaged by the macOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions