Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CameraView fix for iOS: orientation and video recording - #3167

#3167
Merged
TheCodeTraveler merged 15 commits into
CommunityToolkit:mainCommunityToolkit/Maui:mainfrom
zhitaop:fix/camera-update-ioszhitaop/CommunityToolkitMaui:fix/camera-update-iosCopy head branch name to clipboard
Apr 2, 2026
Merged

CameraView fix for iOS: orientation and video recording#3167
TheCodeTraveler merged 15 commits into
CommunityToolkit:mainCommunityToolkit/Maui:mainfrom
zhitaop:fix/camera-update-ioszhitaop/CommunityToolkitMaui:fix/camera-update-iosCopy head branch name to clipboard

Conversation

@zhitaop

@zhitaop zhitaop commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Description of Change

  • This PR fixes a bug on iOS where camera preview is stopped after video recording, and attempting to capture an image would crash the app. This is done by fixing video recording clean up logic so only recording-specific resources (audioInput, videoOutput) are added and removed.

  • Simplifies video recording session management by removing the separate video input and reusing the existing capture input

  • Improves iOS camera orientation handling for both photo capture and video recording. Centralized orientation handling logic in ConfigureAVCaptureConnection():

    • Uses AVCaptureDeviceRotationCoordinator on iOS 17+
    • Falls back to CMMotionManager on iOS 16 and below

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

Copilot AI review requested due to automatic review settings March 20, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves iOS CameraView behavior by centralizing orientation configuration for photo/video capture and refining video recording resource management to prevent post-recording crashes.

Changes:

  • Centralizes photo/video orientation configuration via a new ConfigureAVCaptureConnection() helper (iOS 17+ rotation coordinator; iOS ≤16 accelerometer fallback).
  • Simplifies iOS video recording by reusing the existing camera input and only adding/removing recording-specific resources (audioInput, videoOutput).
  • Adds lifecycle cleanup for rotation coordinator and motion manager resources in Dispose().

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
@TheCodeTraveler

Copy link
Copy Markdown
Collaborator

Thanks @zhitaop! Could you take a second to review CoPilot's recommendations and implement the fix if you deem it appropriate?

@zhitaop

zhitaop commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @TheCodeTraveler, I've reviewed Copilot's feedback and implement the fix accordingly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs
Comment thread src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Outdated
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
TheCodeTraveler
TheCodeTraveler previously approved these changes Apr 2, 2026

@TheCodeTraveler TheCodeTraveler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @zhitaop!!

@TheCodeTraveler
TheCodeTraveler merged commit 8a2ab3c into CommunityToolkit:main Apr 2, 2026
9 of 10 checks passed
matt-goldman pushed a commit to matt-goldman/Maui-1 that referenced this pull request Apr 2, 2026
…lkit#3167)

* CameraView update for iOS: orientation, video recording

* Address Copilot review

* Update mirroring handle

* Address Copilot review

* Reduce scope of `OnLoaded` and `IsInitialized`

* Use `ICommand` for `StopCameraPreviewCommand`

* Refactor `TryConfigureAVCaptureConnection`

* Update CameraManager.windows.cs

* Update CameraManager.macios.cs

* Update XML docs

* `dotnet format`

---------

Co-authored-by: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
@zhitaop
zhitaop deleted the fix/camera-update-ios branch April 3, 2026 02:06
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.