Skip to content
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

Add support to disable "Thread Performance Checker" #1380

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added `scheme.enableGPUValidationMode` #1294 @LouisLWang
- Added visionOS support #1379 @shiba1014
- Added ability to disable Thread performance checker in Schemes #1380 @piellarda

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ This is a convenience used to automatically generate schemes for a target based
- [ ] **coverageTargets**: **[[Testable Target Reference](#testable-target-reference) - a list of targets to gather code coverage. Each entry can either be a simple string, a string using [Project Reference](#project-reference) or [Testable Target Reference](#testable-target-reference)
- [ ] **disableMainThreadChecker**: **Bool** - a boolean that indicates if this scheme should disable the Main Thread Checker. This defaults to false
- [ ] **stopOnEveryMainThreadCheckerIssue**: **Bool** - a boolean that indicates if this scheme should stop at every Main Thread Checker issue. This defaults to false
- [ ] **disableThreadPerformanceChecker**: **Bool** - a boolean that indicates if this scheme should disable the Thread Performance Checker. This defaults to false
- [ ] **buildImplicitDependencies**: **Bool** - Flag to determine if Xcode should build implicit dependencies of this scheme. By default this is `true` if not set.
- [ ] **language**: **String** - a String that indicates the language used for running and testing. This defaults to nil
- [ ] **region**: **String** - a String that indicates the region used for running and testing. This defaults to nil
Expand Down Expand Up @@ -937,6 +938,7 @@ The different actions share some properties:
- [ ] **enableGPUValidationMode**: **GPUValidationMode** - Property value set for `Metal API Validation`. Possible values are `enabled`, `disabled`, `extended`. Default is `enabled`.
- [ ] **disableMainThreadChecker**: **Bool** - `run` and `test` actions can define a boolean that indicates that this scheme should disable the Main Thread Checker. This defaults to false
- [ ] **stopOnEveryMainThreadCheckerIssue**: **Bool** - a boolean that indicates if this scheme should stop at every Main Thread Checker issue. This defaults to false
- [ ] **disableThreadPerformanceChecker**: **Bool** - `run` action can define a boolean that indicates that this scheme should disable the Thread Performance Checker. This defaults to false
- [ ] **language**: **String** - `run` and `test` actions can define a language that is used for Application Language
- [ ] **region**: **String** - `run` and `test` actions can define a language that is used for Application Region
- [ ] **debugEnabled**: **Bool** - `run` and `test` actions can define a whether debugger should be used. This defaults to true.
Expand Down
9 changes: 9 additions & 0 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public struct Scheme: Equatable {
public struct Run: BuildAction {
public static let disableMainThreadCheckerDefault = false
public static let stopOnEveryMainThreadCheckerIssueDefault = false
public static let disableThreadPerformanceCheckerDefault = false
public static let debugEnabledDefault = true

public var config: String?
Expand All @@ -138,6 +139,7 @@ public struct Scheme: Equatable {
public var enableGPUValidationMode: XCScheme.LaunchAction.GPUValidationMode
public var disableMainThreadChecker: Bool
public var stopOnEveryMainThreadCheckerIssue: Bool
public var disableThreadPerformanceChecker: Bool
public var language: String?
public var region: String?
public var askForAppToLaunch: Bool?
Expand All @@ -160,6 +162,7 @@ public struct Scheme: Equatable {
enableGPUValidationMode: XCScheme.LaunchAction.GPUValidationMode = XCScheme.LaunchAction.GPUValidationMode.enabled,
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault,
stopOnEveryMainThreadCheckerIssue: Bool = stopOnEveryMainThreadCheckerIssueDefault,
disableThreadPerformanceChecker: Bool = disableThreadPerformanceCheckerDefault,
language: String? = nil,
region: String? = nil,
askForAppToLaunch: Bool? = nil,
Expand All @@ -179,6 +182,7 @@ public struct Scheme: Equatable {
self.enableGPUFrameCaptureMode = enableGPUFrameCaptureMode
self.enableGPUValidationMode = enableGPUValidationMode
self.stopOnEveryMainThreadCheckerIssue = stopOnEveryMainThreadCheckerIssue
self.disableThreadPerformanceChecker = disableThreadPerformanceChecker
self.language = language
self.region = region
self.askForAppToLaunch = askForAppToLaunch
Expand Down Expand Up @@ -480,6 +484,7 @@ extension Scheme.Run: JSONObjectConvertible {
}
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? Scheme.Run.disableMainThreadCheckerDefault
stopOnEveryMainThreadCheckerIssue = jsonDictionary.json(atKeyPath: "stopOnEveryMainThreadCheckerIssue") ?? Scheme.Run.stopOnEveryMainThreadCheckerIssueDefault
disableThreadPerformanceChecker = jsonDictionary.json(atKeyPath: "disableThreadPerformanceChecker") ?? Scheme.Run.disableThreadPerformanceCheckerDefault
language = jsonDictionary.json(atKeyPath: "language")
region = jsonDictionary.json(atKeyPath: "region")
debugEnabled = jsonDictionary.json(atKeyPath: "debugEnabled") ?? Scheme.Run.debugEnabledDefault
Expand Down Expand Up @@ -535,6 +540,10 @@ extension Scheme.Run: JSONEncodable {
dict["stopOnEveryMainThreadCheckerIssue"] = stopOnEveryMainThreadCheckerIssue
}

if disableThreadPerformanceChecker != Scheme.Run.disableThreadPerformanceCheckerDefault {
dict["disableThreadPerformanceChecker"] = disableThreadPerformanceChecker
}

if debugEnabled != Scheme.Run.debugEnabledDefault {
dict["debugEnabled"] = debugEnabled
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/ProjectSpec/TargetScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public struct TargetScheme: Equatable {
public static let gatherCoverageDataDefault = false
public static let disableMainThreadCheckerDefault = false
public static let stopOnEveryMainThreadCheckerIssueDefault = false
public static let disableThreadPerformanceCheckerDefault = false
public static let buildImplicitDependenciesDefault = true

public var testTargets: [Scheme.Test.TestTarget]
Expand All @@ -17,6 +18,7 @@ public struct TargetScheme: Equatable {
public var region: String?
public var disableMainThreadChecker: Bool
public var stopOnEveryMainThreadCheckerIssue: Bool
public var disableThreadPerformanceChecker: Bool
public var buildImplicitDependencies: Bool
public var commandLineArguments: [String: Bool]
public var environmentVariables: [XCScheme.EnvironmentVariable]
Expand All @@ -36,6 +38,7 @@ public struct TargetScheme: Equatable {
region: String? = nil,
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault,
stopOnEveryMainThreadCheckerIssue: Bool = stopOnEveryMainThreadCheckerIssueDefault,
disableThreadPerformanceChecker: Bool = disableThreadPerformanceCheckerDefault,
buildImplicitDependencies: Bool = buildImplicitDependenciesDefault,
commandLineArguments: [String: Bool] = [:],
environmentVariables: [XCScheme.EnvironmentVariable] = [],
Expand All @@ -53,6 +56,7 @@ public struct TargetScheme: Equatable {
self.region = region
self.disableMainThreadChecker = disableMainThreadChecker
self.stopOnEveryMainThreadCheckerIssue = stopOnEveryMainThreadCheckerIssue
self.disableThreadPerformanceChecker = disableThreadPerformanceChecker
self.buildImplicitDependencies = buildImplicitDependencies
self.commandLineArguments = commandLineArguments
self.environmentVariables = environmentVariables
Expand Down Expand Up @@ -104,6 +108,7 @@ extension TargetScheme: JSONObjectConvertible {
region = jsonDictionary.json(atKeyPath: "region")
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? TargetScheme.disableMainThreadCheckerDefault
stopOnEveryMainThreadCheckerIssue = jsonDictionary.json(atKeyPath: "stopOnEveryMainThreadCheckerIssue") ?? TargetScheme.stopOnEveryMainThreadCheckerIssueDefault
disableThreadPerformanceChecker = jsonDictionary.json(atKeyPath: "disableThreadPerformanceChecker") ?? TargetScheme.disableThreadPerformanceCheckerDefault
buildImplicitDependencies = jsonDictionary.json(atKeyPath: "buildImplicitDependencies") ?? TargetScheme.buildImplicitDependenciesDefault
commandLineArguments = jsonDictionary.json(atKeyPath: "commandLineArguments") ?? [:]
environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary)
Expand Down Expand Up @@ -142,6 +147,10 @@ extension TargetScheme: JSONEncodable {
dict["stopOnEveryMainThreadCheckerIssue"] = stopOnEveryMainThreadCheckerIssue
}

if disableThreadPerformanceChecker != TargetScheme.disableThreadPerformanceCheckerDefault {
dict["disableThreadPerformanceChecker"] = disableThreadPerformanceChecker
}

if buildImplicitDependencies != TargetScheme.buildImplicitDependenciesDefault {
dict["buildImplicitDependencies"] = buildImplicitDependencies
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public class SchemeGenerator {
enableGPUFrameCaptureMode: scheme.run?.enableGPUFrameCaptureMode ?? XCScheme.LaunchAction.defaultGPUFrameCaptureMode,
enableGPUValidationMode: scheme.run?.enableGPUValidationMode ?? XCScheme.LaunchAction.defaultGPUValidationMode,
disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault,
disablePerformanceAntipatternChecker: scheme.run?.disableThreadPerformanceChecker ?? Scheme.Run.disableThreadPerformanceCheckerDefault,
stopOnEveryMainThreadCheckerIssue: scheme.run?.stopOnEveryMainThreadCheckerIssue ?? Scheme.Run.stopOnEveryMainThreadCheckerIssueDefault,
commandlineArguments: launchCommandLineArgs,
environmentVariables: launchVariables,
Expand Down Expand Up @@ -468,6 +469,7 @@ extension Scheme {
environmentVariables: targetScheme.environmentVariables,
disableMainThreadChecker: targetScheme.disableMainThreadChecker,
stopOnEveryMainThreadCheckerIssue: targetScheme.stopOnEveryMainThreadCheckerIssue,
disableThreadPerformanceChecker: targetScheme.disableThreadPerformanceChecker,
language: targetScheme.language,
region: targetScheme.region,
storeKitConfiguration: targetScheme.storeKitConfiguration
Expand Down
2 changes: 2 additions & 0 deletions Tests/ProjectSpecTests/ProjectSpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ class ProjectSpecTests: XCTestCase {
storeKitConfiguration: "Configuration.storekit",
disableMainThreadChecker: true,
stopOnEveryMainThreadCheckerIssue: false,
disableThreadPerformanceChecker: true,
commandLineArguments: ["foo": true],
environmentVariables: [XCScheme.EnvironmentVariable(variable: "environmentVariable",
value: "bar",
Expand Down Expand Up @@ -601,6 +602,7 @@ class ProjectSpecTests: XCTestCase {
configVariants: ["foo"],
gatherCoverageData: true,
disableMainThreadChecker: true,
disableThreadPerformanceChecker: true,
commandLineArguments: ["foo": true],
environmentVariables: [XCScheme.EnvironmentVariable(variable: "environmentVariable",
value: "bar",
Expand Down
4 changes: 4 additions & 0 deletions Tests/ProjectSpecTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ class SpecLoadingTests: XCTestCase {
"region": "US",
"disableMainThreadChecker": true,
"stopOnEveryMainThreadCheckerIssue": true,
"disableThreadPerformanceChecker": true,
"environmentVariables": [
"TEST_VAR": "TEST_VAL",
],
Expand Down Expand Up @@ -903,6 +904,7 @@ class SpecLoadingTests: XCTestCase {
region: "US",
disableMainThreadChecker: true,
stopOnEveryMainThreadCheckerIssue: true,
disableThreadPerformanceChecker: true,
commandLineArguments: ["ENV1": true],
environmentVariables: [XCScheme.EnvironmentVariable(variable: "TEST_VAR", value: "TEST_VAL", enabled: true)],
preActions: [.init(name: "Do Thing", script: "dothing", settingsTarget: "test")],
Expand Down Expand Up @@ -941,6 +943,7 @@ class SpecLoadingTests: XCTestCase {
"launchAutomaticallySubstyle": 2,
"enableGPUFrameCaptureMode": "disabled",
"storeKitConfiguration": "Configuration.storekit",
"disableThreadPerformanceChecker": true,
],
"test": [
"config": "debug",
Expand Down Expand Up @@ -995,6 +998,7 @@ class SpecLoadingTests: XCTestCase {
let expectedRun = Scheme.Run(
config: "debug",
enableGPUFrameCaptureMode: .disabled,
disableThreadPerformanceChecker: true,
launchAutomaticallySubstyle: "2",
storeKitConfiguration: "Configuration.storekit"
)
Expand Down