X Tutup
Skip to content

Fix camera module error handling and remove unnecessary transform#114400

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
shiena:fix/camera_macos
Jan 5, 2026
Merged

Fix camera module error handling and remove unnecessary transform#114400
akien-mga merged 1 commit intogodotengine:masterfrom
shiena:fix/camera_macos

Conversation

@shiena
Copy link
Contributor

@shiena shiena commented Dec 28, 2025

Fixes #114399

Fixes several issues in the macOS camera module:

Unnecessary transform removed:

  • Removed hardcoded Transform2D(-1.0, 0.0, 0.0, -1.0, 1.0, 1.0) in CameraMacOS::update_feeds() that caused incorrect rotation/mirroring on MacBooks
  • Unlike mobile devices, desktop cameras don't require orientation correction

Error handling improvements:

  • activate_feed() now returns proper status instead of always returning true
  • Added early return in MyCaptureSession initForFeed:andDevice: when input/output device acquisition fails
  • Added null check for pixelBuffer in captureOutput:didOutputSampleBuffer:fromConnection:
  • Added error messages for AVAuthorizationStatusDenied and AVAuthorizationStatusRestricted
  • Added plane count check before accessing pixel buffer planes to handle unexpected buffer formats
  • Improved null checks with one-time logging and proper CVPixelBuffer unlock before returning on error

Resource lifecycle improvements:

  • Added destructor ~CameraFeedMacOS() to properly clean up the capture session when the feed is destroyed
  • Deactivate feeds in update_feeds() before removing them to prevent resource leaks

@shiena shiena requested a review from a team as a code owner December 28, 2025 18:07
@bruvzg bruvzg self-requested a review December 28, 2025 19:42
@shiena shiena force-pushed the fix/camera_macos branch 2 times, most recently from 5ee5421 to 3f2a56b Compare January 3, 2026 20:02
@bruvzg bruvzg added this to the 4.7 milestone Jan 5, 2026
@bruvzg bruvzg modified the milestones: 4.7, 4.6 Jan 5, 2026
@bruvzg
Copy link
Member

bruvzg commented Jan 5, 2026

Please squash the commits, see The interactive rebase.

- Add null check for pixelBuffer in camera callback
- Return nil from capture session init on input/output failure
- Fix activate_feed return value and handle permission denied/restricted
- Deactivate camera feeds before removal

Add plane count check before accessing pixel buffer planes to handle
unexpected buffer formats gracefully. Also improve null checks to use
one-time logging and properly unlock the buffer before returning on
error.
@shiena
Copy link
Contributor Author

shiena commented Jan 5, 2026

Squashed.

@akien-mga akien-mga merged commit 7d4396c into godotengine:master Jan 5, 2026
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@shiena shiena deleted the fix/camera_macos branch January 5, 2026 11:19
rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
Fix camera module error handling and remove unnecessary transform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS camera module has incorrect error handling and applies unnecessary transform

3 participants

X Tutup