Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #8227: When launching the QR code scanning UI while in the Landsc…
Browse files Browse the repository at this point in the history
…ape mode, the camera view is rotated 90 degrees (#8472)
  • Loading branch information
soner-yuksel authored and Brandon-T committed Dec 14, 2023
1 parent 6edc842 commit e8580ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class RecentSearchQRCodeScannerController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

scannerView.cameraView.stopRunning()
}

override func viewDidAppear(_ animated: Bool) {
if let orientation = view.window?.windowScene?.interfaceOrientation {
scannerView.cameraView.videoPreviewLayer?.connection?.videoOrientation = AVCaptureVideoOrientation(ui: orientation)
}
scannerView.cameraView.startRunning()
}

Expand Down
14 changes: 11 additions & 3 deletions Sources/Brave/Frontend/Sync/SyncCameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SyncCameraView: UIView, AVCaptureMetadataOutputObjectsDelegate {
videoPreviewLayer?.frame = layer.bounds
layer.addSublayer(videoPreviewLayer!)

captureSession.startRunning()
startRunning()
bringSubviewToFront(cameraOverlayView)

AVCaptureDevice.requestAccess(
Expand All @@ -143,11 +143,19 @@ class SyncCameraView: UIView, AVCaptureMetadataOutputObjectsDelegate {
}

func startRunning() {
captureSession?.startRunning()
DispatchQueue.global(qos: .default).async { [weak self] in
guard let self else { return }

if self.captureSession?.isRunning == false {
self.captureSession?.startRunning()
}
}
}

func stopRunning() {
captureSession?.stopRunning()
if captureSession?.isRunning == true {
captureSession?.stopRunning()
}
}

func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
Expand Down

0 comments on commit e8580ad

Please sign in to comment.