camera: NSLog fallback in photo delegate so we can see it fired

User reports macOS photo still rotated AND no `photo:` line in
banlu.jsonl — so either the delegate isn't firing at all or the
event-channel path is broken on the success branch.

Add `NSLog` at the top of `photoOutput(_:didFinishProcessingPhoto:error:)`
and on the CGImage path. NSLog lands in `flutter run` stderr +
macOS Console regardless of channel state, so even if the diag
event drops we'll see the delegate firing + the CGImage's
dimensions. Once we see them we'll know whether it's a delegate
problem or a channel problem.
This commit is contained in:
agra
2026-05-13 20:36:22 +03:00
parent 9ba8ff8e61
commit e03e698caa

View File

@@ -1,6 +1,7 @@
import AVFoundation
import Foundation
import ImageIO
import os.log
/// Wraps `AVCapturePhotoOutput`. One instance per
/// [CameraInstance]; gets added to the session at create time and
@@ -111,6 +112,13 @@ private final class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegat
didFinishProcessingPhoto photo: AVCapturePhoto,
error: Error?
) {
// Belt-and-suspenders logging: the event-channel `diag` is the
// primary path (lands in `banlu.jsonl` via ux.Log), but NSLog
// is a fallback that ALWAYS lands in `flutter run` stderr +
// macOS Console regardless of channel state. Helps confirm
// whether the delegate is even firing when the jsonl shows
// nothing.
NSLog("[ux.camera] photoOutput callback fired error=\(error?.localizedDescription ?? "none")")
if let error = error as NSError? {
diag("photo capture failed: domain=\(error.domain)"
+ " code=\(error.code) desc=\(error.localizedDescription)")
@@ -140,6 +148,7 @@ private final class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegat
)))
return
}
NSLog("[ux.camera] cgImage: %dx%d", cgImage.width, cgImage.height)
diag("photo: \(cgImage.width)x\(cgImage.height) " +
"(cgImageRepresentation, no EXIF)")
let destination = CGImageDestinationCreateWithURL(