Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ProfilingUITests: BaseUITest {
goToTransactions()
startTransaction()

app.buttons["anrFillingRunLoop"].afterWaitingForExistence("Couldn't find button to ANR").tap()
app.buttons["appHangFullyBlocking"].afterWaitingForExistence("Couldn't find button to trigger fully blocking AppHang.").tap()
stopTransaction()

goToProfiling()
Expand Down
12 changes: 6 additions & 6 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/* Begin PBXBuildFile section */
0AAAB8572887F7C60011845C /* PermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2E928855FF80057ED69 /* PermissionsViewController.swift */; };
0AABE2EA28855FF80057ED69 /* PermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2E928855FF80057ED69 /* PermissionsViewController.swift */; };
629EC8AD2B0B537400858855 /* ANRs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629EC8AC2B0B537400858855 /* ANRs.swift */; };
629EC8BB2B0B5BAE00858855 /* ANRs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629EC8AC2B0B537400858855 /* ANRs.swift */; };
629EC8AD2B0B537400858855 /* TriggerAppHang.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629EC8AC2B0B537400858855 /* TriggerAppHang.swift */; };
629EC8BB2B0B5BAE00858855 /* TriggerAppHang.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629EC8AC2B0B537400858855 /* TriggerAppHang.swift */; };
62C07D5C2AF3E3F500894688 /* BaseUITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62C07D5B2AF3E3F500894688 /* BaseUITest.swift */; };
630853532440C60F00DDE4CE /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; };
637AFDAA243B02760034958B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637AFDA9243B02760034958B /* AppDelegate.swift */; };
Expand Down Expand Up @@ -279,7 +279,7 @@

/* Begin PBXFileReference section */
0AABE2E928855FF80057ED69 /* PermissionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsViewController.swift; sourceTree = "<group>"; };
629EC8AC2B0B537400858855 /* ANRs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ANRs.swift; sourceTree = "<group>"; };
629EC8AC2B0B537400858855 /* TriggerAppHang.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerAppHang.swift; sourceTree = "<group>"; };
62C07D5B2AF3E3F500894688 /* BaseUITest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseUITest.swift; sourceTree = "<group>"; };
6308532C2440C44F00DDE4CE /* Sentry.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Sentry.xcodeproj; path = ../../Sentry.xcodeproj; sourceTree = "<group>"; };
637AFDA6243B02760034958B /* iOS-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -607,7 +607,7 @@
7B5525B22938B5B5006A2932 /* DiskWriteException.swift */,
D8F01DF02A1377D0008F4996 /* SentryExposure.h */,
D8832B192AF4FE2000C522B0 /* SentryUIApplication.h */,
629EC8AC2B0B537400858855 /* ANRs.swift */,
629EC8AC2B0B537400858855 /* TriggerAppHang.swift */,
);
path = Tools;
sourceTree = "<group>";
Expand Down Expand Up @@ -954,7 +954,7 @@
7B79000429028C7300A7F467 /* MetricKitManager.swift in Sources */,
D8D7BB4A2750067900044146 /* UIAssert.swift in Sources */,
D8F3D057274E574200B56F8C /* LoremIpsumViewController.swift in Sources */,
629EC8AD2B0B537400858855 /* ANRs.swift in Sources */,
629EC8AD2B0B537400858855 /* TriggerAppHang.swift in Sources */,
D8AE48C92C57DC2F0092A2A6 /* WebViewController.swift in Sources */,
D8DBDA78274D5FC400007380 /* SplitViewController.swift in Sources */,
84ACC43C2A73CB5900932A18 /* ProfilingNetworkScanner.swift in Sources */,
Expand Down Expand Up @@ -1011,7 +1011,7 @@
D8F3D055274E572F00B56F8C /* RandomErrors.swift in Sources */,
0AAAB8572887F7C60011845C /* PermissionsViewController.swift in Sources */,
D8269A3C274C095E00BD5BD5 /* AppDelegate.swift in Sources */,
629EC8BB2B0B5BAE00858855 /* ANRs.swift in Sources */,
629EC8BB2B0B5BAE00858855 /* TriggerAppHang.swift in Sources */,
D80D021B29EE9E3D0084393D /* ErrorsViewController.swift in Sources */,
D8444E53275F792A0042F4DE /* UIAssert.swift in Sources */,
D8269A3E274C095E00BD5BD5 /* SceneDelegate.swift in Sources */,
Expand Down
10 changes: 5 additions & 5 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
<action selector="stopTransaction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="r2S-U5-Af9"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LvU-yx-01i" userLabel="triggerANRRunLoop">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LvU-yx-01i">
<rect key="frame" x="0.0" y="84" width="259" height="28"/>
<accessibility key="accessibilityConfiguration" identifier="anrFillingRunLoop"/>
<accessibility key="accessibilityConfiguration" identifier="appHangFullyBlocking"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="ANR filling run loop"/>
<state key="normal" title="AppHangFullyBlocking"/>
<connections>
<action selector="anrFillingRunLoop:" destination="BYZ-38-t0r" eventType="touchUpInside" id="uqP-sv-C4a"/>
<action selector="appHangFullyBlocking:" destination="BYZ-38-t0r" eventType="touchUpInside" id="uqP-sv-C4a"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5IM-MG-9GW">
Expand Down Expand Up @@ -167,7 +167,7 @@
<tabBarItem key="tabBarItem" title="Transactions" image="clock.fill" catalog="system" selectedImage="clock.fill" id="ypv-KA-BBe"/>
<navigationItem key="navigationItem" title="Sentry Test App (Swift)" id="Ddh-Ww-vzM"/>
<connections>
<outlet property="anrFillingRunLoopButton" destination="LvU-yx-01i" id="Epa-mo-uMP"/>
<outlet property="appHangFullyBlockingButton" destination="LvU-yx-01i" id="Epa-mo-uMP"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
2 changes: 1 addition & 1 deletion Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ExtraViewController: UIViewController {

@IBAction func anrFillingRunLoop(_ sender: UIButton) {
highlightButton(sender)
triggerANRFillingRunLoop(button: self.anrFillingRunLoopButton)
triggerNonFullyBlockingAppHang()
}

@IBAction func getPasteBoardString(_ sender: Any) {
Expand Down
37 changes: 0 additions & 37 deletions Samples/iOS-Swift/iOS-Swift/Tools/ANRs.swift

This file was deleted.

34 changes: 34 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/Tools/TriggerAppHang.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Foundation
import UIKit

/// Triggers a non-fully blocking app hang by blocking the app for 0.5 seconds,
/// then allowing it to draw a couple of frames, and blocking it again. While the app
/// is not fully blocked because it renders a few frames, it still seems blocked to the
/// user and should be considered an app hang.
func triggerNonFullyBlockingAppHang() {

DispatchQueue.global().async {
for _ in 0...10 {
Thread.sleep(forTimeInterval: 0.001)
DispatchQueue.main.sync {
Thread.sleep(forTimeInterval: 0.5)
}
}
}
}

/// Schedules heavy UI rendering work on the main thread in a tight loop, which causes
/// a fully blocking app hang without frames being rendered.
func triggerFullyBlockingAppHang(button: UIButton) {
let buttonTitle = button.currentTitle
var i = 0

for _ in 0...5_000_000 {
i += Int.random(in: 0...10)
i -= 1

button.setTitle("\(i)", for: .normal)
}

button.setTitle(buttonTitle, for: .normal)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UIKit

class TransactionsViewController: UIViewController {

@IBOutlet weak var anrFillingRunLoopButton: UIButton!
@IBOutlet weak var appHangFullyBlockingButton: UIButton!

private let dispatchQueue = DispatchQueue(label: "ViewController", attributes: .concurrent)
private var timer: Timer?
Expand Down Expand Up @@ -127,8 +127,8 @@ class TransactionsViewController: UIViewController {
present(alert, animated: true)
}

@IBAction func anrFillingRunLoop(_ sender: Any) {
triggerANRFillingRunLoop(button: self.anrFillingRunLoopButton)
@IBAction func appHangFullyBlocking(_ sender: Any) {
triggerFullyBlockingAppHang(button: self.appHangFullyBlockingButton)
}

@IBAction func captureTransaction(_ sender: UIButton) {
Expand Down