-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Xcode 16 #4066
Support Xcode 16 #4066
Changes from 5 commits
636a8fb
d13fc70
ebdef6f
d2b0008
fe7fe54
153e55f
6fe8fa3
35c8353
22cbcac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,9 +356,9 @@ class ScanBaseViewController: UIViewController, AVCaptureVideoDataOutputSampleBu | |
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
ScanBaseViewController.isAppearing = true | ||
/// Set beginning of scan session | ||
// Set beginning of scan session | ||
ScanAnalyticsManager.shared.setScanSessionStartTime(time: Date()) | ||
/// Check and log torch availability | ||
// Check and log torch availability | ||
Comment on lines
+359
to
+361
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swiftlint fix |
||
ScanAnalyticsManager.shared.logTorchSupportTask( | ||
supported: videoFeed.hasTorchAndIsAvailable() | ||
) | ||
|
@@ -413,22 +413,20 @@ class ScanBaseViewController: UIViewController, AVCaptureVideoDataOutputSampleBu | |
from connection: AVCaptureConnection | ||
) { | ||
if self.machineLearningSemaphore.wait(timeout: .now()) == .success { | ||
ScanBaseViewController.machineLearningQueue.async { | ||
self.captureOutputWork(sampleBuffer: sampleBuffer) | ||
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer), | ||
let fullCameraImage = pixelBuffer.cgImage() else { | ||
self.machineLearningSemaphore.signal() | ||
return | ||
} | ||
} | ||
} | ||
|
||
func captureOutputWork(sampleBuffer: CMSampleBuffer) { | ||
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { | ||
return | ||
} | ||
|
||
guard let fullCameraImage = pixelBuffer.cgImage() else { | ||
return | ||
ScanBaseViewController.machineLearningQueue.async { [weak self] in | ||
self?.captureOutputWork(fullCameraImage: fullCameraImage) | ||
self?.machineLearningSemaphore.signal() | ||
} | ||
} | ||
} | ||
Comment on lines
415
to
+427
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both I'm unsure if this is the intended behavior – if it's expensive to convert CMSampleBuffer -> CVImageBuffer -> CIImage, then we're now doing that work on the main thread. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on my memory from implementing the equivalent for Identity, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. In fact, this is what it's designed for. Generally the camera feed is faster than the ML model can process images, so the idea is that you want to block the thread that is reading from the camera in order to finish processing the image in CoreML before asking for more camera frames, otherwise you end queuing up so much of the video buffer that the displayed camera feed begins to drop frames and the app lags. Here's an excerpt from the copy of the CoreML survival guide that gives a basic example: Public link (page 400): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So yeah, given that we're explicitly calling |
||
|
||
func captureOutputWork(fullCameraImage: CGImage) { | ||
// confirm videoGravity settings in previewView. Calculations based on .resizeAspectFill | ||
DispatchQueue.main.async { | ||
assert(self.previewView?.videoPreviewLayer.videoGravity == .resizeAspectFill) | ||
|
@@ -472,9 +470,9 @@ class ScanBaseViewController: UIViewController, AVCaptureVideoDataOutputSampleBu | |
// MARK: - OcrMainLoopComplete logic | ||
func complete(creditCardOcrResult: CreditCardOcrResult) { | ||
ocrMainLoop()?.mainLoopDelegate = nil | ||
/// Stop the previewing when we are done | ||
// Stop the previewing when we are done | ||
self.previewView?.videoPreviewLayer.session?.stopRunning() | ||
/// Log total frames processed | ||
// Log total frames processed | ||
ScanAnalyticsManager.shared.logMainLoopImageProcessedRepeatingTask( | ||
.init(executions: self.getScanStats().scans) | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ stages: | |
workflows: | ||
- framework-tests: {} | ||
- test-builds-xcode-15: {} | ||
- test-builds-xcode-16: {} | ||
- test-builds-vision: {} | ||
- install-tests-non-carthage: {} | ||
- lint-tests: {} | ||
|
@@ -53,7 +54,9 @@ stages: | |
workflows: | ||
- framework-tests-no-mocks: {} | ||
- test-builds-xcode-15: {} | ||
- test-builds-xcode-16: {} | ||
- test-builds-xcode-15-release: {} | ||
- test-builds-xcode-16-release: {} | ||
Comment on lines
+57
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds tests to ensure the frameworks build on both Xcode 15 and 16 |
||
- test-builds-vision: {} | ||
- deploy-docs: {} | ||
- install-tests-non-carthage: {} | ||
|
@@ -71,6 +74,7 @@ stages: | |
stage-nightly-all: | ||
workflows: | ||
- test-builds-xcode-15-release: {} | ||
- test-builds-xcode-16-release: {} | ||
- framework-tests-no-mocks: {} | ||
- check-docs: {} | ||
- legacy-tests-15: {} | ||
|
@@ -348,6 +352,21 @@ workflows: | |
bitrise.io: | ||
stack: osx-xcode-15.0.x | ||
machine_type_id: g2-m1.8core | ||
test-builds-xcode-16: | ||
steps: | ||
- xcode-build-for-test@2: | ||
inputs: | ||
- scheme: AllStripeFrameworks | ||
- destination: generic/platform=iOS Simulator | ||
- deploy-to-bitrise-io@2: {} | ||
envs: | ||
- DEFAULT_TEST_DEVICE: platform=iOS Simulator,name=iPhone 15,OS=18.0 | ||
before_run: | ||
- prep_all | ||
meta: | ||
bitrise.io: | ||
stack: osx-xcode-16.0.x | ||
machine_type_id: g2-m1.8core | ||
test-builds-xcode-15-release: | ||
steps: | ||
- script@1: | ||
|
@@ -360,6 +379,18 @@ workflows: | |
bitrise.io: | ||
stack: osx-xcode-15.0.x | ||
machine_type_id: g2-m1.8core | ||
test-builds-xcode-16-release: | ||
steps: | ||
- script@1: | ||
inputs: | ||
- content: xcodebuild build -workspace "Stripe.xcworkspace" -scheme "AllStripeFrameworks" -configuration "Release" -sdk "iphonesimulator" | xcpretty | ||
title: Build release builds | ||
before_run: | ||
- prep_all | ||
meta: | ||
bitrise.io: | ||
stack: osx-xcode-16.0.x | ||
machine_type_id: g2-m1.8core | ||
test-builds-vision: | ||
steps: | ||
- xcode-build-for-test@2: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds StripeConnect to
AllStripeFrameworks
so we'll get CI failures when this module doesn't compile