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

Feature/crashloop #100

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
36 changes: 30 additions & 6 deletions Backtrace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@
AFCCCE232625392300B83A28 /* ReportMetadataStorageMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCCCE222625392300B83A28 /* ReportMetadataStorageMock.swift */; };
AFCCCE242625392300B83A28 /* ReportMetadataStorageMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCCCE222625392300B83A28 /* ReportMetadataStorageMock.swift */; };
AFCCCE252625392300B83A28 /* ReportMetadataStorageMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCCCE222625392300B83A28 /* ReportMetadataStorageMock.swift */; };
B50C5A8028E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50C5A7F28E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift */; };
B50C5A8128E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50C5A7F28E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift */; };
B50C5A8228E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50C5A7F28E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift */; };
B5E58C6928E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E58C6828E1A843001F9650 /* BacktraceCrashLoopDetector.swift */; };
B5E58C6A28E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E58C6828E1A843001F9650 /* BacktraceCrashLoopDetector.swift */; };
B5E58C6B28E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E58C6828E1A843001F9650 /* BacktraceCrashLoopDetector.swift */; };
DAF627C0CA0FE995B581C33B /* Pods_Backtrace_tvOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD097A22120C3DCE08382BA5 /* Pods_Backtrace_tvOSTests.framework */; };
F21211A5222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */; };
F21211A6222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */; };
Expand Down Expand Up @@ -449,6 +455,8 @@
AF7833BA2613D1B400530A10 /* AttachmentsStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentsStorage.swift; sourceTree = "<group>"; };
AFCCCE222625392300B83A28 /* ReportMetadataStorageMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportMetadataStorageMock.swift; sourceTree = "<group>"; };
AFCCCEC126260BC400B83A28 /* AttachmentBookmarkHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentBookmarkHandler.swift; sourceTree = "<group>"; };
B50C5A7F28E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BacktraceCrashLoopDetectorTests.swift; sourceTree = "<group>"; };
B5E58C6828E1A843001F9650 /* BacktraceCrashLoopDetector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BacktraceCrashLoopDetector.swift; sourceTree = "<group>"; };
B7B445FAC6841A65683F35E9 /* Pods-Backtrace-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Backtrace-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-Backtrace-tvOS/Pods-Backtrace-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
BECDC44D2F82A1F1FD5CD9D1 /* Pods_Backtrace_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Backtrace_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BFAF826CD2E1314532AD4FF6 /* Pods_Example_iOS_ObjC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example_iOS_ObjC.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -813,6 +821,7 @@
A24A4B4928B595D8004F5052 /* BacktraceWatcherTests.swift */,
A24A4B5528B595D8004F5052 /* CrashReporterTests.swift */,
A24A4B5228B595D8004F5052 /* DispatcherTests.swift */,
B50C5A7F28E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift */,
F21DD3AF2255E99E00404CC3 /* Resources */,
F2AB6370224647F000939BC9 /* Helpers */,
F2AB636F224647DE00939BC9 /* Mocks */,
Expand Down Expand Up @@ -932,6 +941,7 @@
F2AFB59622274E1400AAA1D7 /* Public */ = {
isa = PBXGroup;
children = (
B5E58C6828E1A843001F9650 /* BacktraceCrashLoopDetector.swift */,
6E45A3A6273095E500DB0BAC /* BacktraceMetricsSettings.swift */,
F29CD79321FDD5E900216C59 /* BacktraceClientDelegate.swift */,
F2AFB59922274E5400AAA1D7 /* BacktraceClientCustomizing.swift */,
Expand Down Expand Up @@ -1917,6 +1927,7 @@
AF5AB0BB262622730003698C /* AttachmentBookmarkHandler.swift in Sources */,
28F95BD022526064003936E0 /* BacktraceClient.swift in Sources */,
28F95BCD2252605A003936E0 /* BacktraceClientDelegate.swift in Sources */,
B5E58C6B28E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */,
28F95BC92252602C003936E0 /* Foundation+Extensions.swift in Sources */,
28F95BD622526078003936E0 /* DebuggerChecker.swift in Sources */,
28A65308285D1BF700306631 /* Date+Extensions.swift in Sources */,
Expand Down Expand Up @@ -1981,6 +1992,7 @@
A24A4B7728B595D9004F5052 /* DispatcherTests.swift in Sources */,
A24A4B6828B595D9004F5052 /* BacktraceOomWatcherTests.swift in Sources */,
F21DD39F2255666F00404CC3 /* WatcherRepositoryMock.swift in Sources */,
B50C5A8228E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */,
A24A4B5C28B595D9004F5052 /* BacktraceWatcherTests.swift in Sources */,
A24A4B7A28B595D9004F5052 /* AttributesTests.swift in Sources */,
A24A4B6E28B595D9004F5052 /* AttachmentTests.swift in Sources */,
Expand Down Expand Up @@ -2021,6 +2033,7 @@
F2AFB59E22274EDA00AAA1D7 /* Dispatching.swift in Sources */,
2846E1F9222F1DE60035F98C /* NetworkReachability.swift in Sources */,
F21211A9222348C2000B3692 /* SignalContext.swift in Sources */,
B5E58C6A28E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */,
F2AB639D22479A3600939BC9 /* Model.xcdatamodeld in Sources */,
F259E4E3222AD9F100F282C7 /* AttributesProvider.swift in Sources */,
F266B83321C77B9600D14417 /* BacktraceClient.swift in Sources */,
Expand Down Expand Up @@ -2075,6 +2088,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B50C5A8128E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */,
A24A4B7C28B595D9004F5052 /* AttachmentStorageTests.swift in Sources */,
F2AB637F22464FD500939BC9 /* DebuggerCheckerMock.swift in Sources */,
A24A4B7328B595D9004F5052 /* BacktraceApiTests.swift in Sources */,
Expand Down Expand Up @@ -2150,6 +2164,7 @@
6E896E912727627C0005CDF2 /* BacktraceMetrics.swift in Sources */,
6EB713EC275ED4EF0075D1C1 /* SummedEventsPayload.swift in Sources */,
28A652F2285C6C1500306631 /* BacktraceBreadcrumbsLogManager.swift in Sources */,
B5E58C6928E1A843001F9650 /* BacktraceCrashLoopDetector.swift in Sources */,
F28F164621E28441008E4B96 /* BacktraceReporter.swift in Sources */,
F21211A5222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */,
0B6B4CFD25CD8331002DA15C /* BacktraceOomWatcher.swift in Sources */,
Expand Down Expand Up @@ -2185,6 +2200,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B50C5A8028E4740A004BB1DA /* BacktraceCrashLoopDetectorTests.swift in Sources */,
A24A4B7B28B595D9004F5052 /* AttachmentStorageTests.swift in Sources */,
F2AB637E22464FD500939BC9 /* DebuggerCheckerMock.swift in Sources */,
A24A4B7228B595D9004F5052 /* BacktraceApiTests.swift in Sources */,
Expand Down Expand Up @@ -2381,7 +2397,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -2460,7 +2476,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = Backtrace.io.Backtrace;
Expand Down Expand Up @@ -2692,7 +2708,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -2774,7 +2790,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = Backtrace.io.Backtrace;
Expand Down Expand Up @@ -2979,6 +2995,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -3002,6 +3019,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -3058,6 +3076,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
ENABLE_NS_ASSERTIONS = NO;
Expand All @@ -3075,6 +3094,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = apptailors.co.backtrace.swift.tvos.example;
Expand Down Expand Up @@ -3185,7 +3205,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -3269,7 +3289,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.4-beta2;
MARKETING_VERSION = "1.7.4-beta2";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = Backtrace.io.Backtrace;
Expand Down Expand Up @@ -3483,6 +3503,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = LZGFT5UUA9;
ENABLE_BITCODE = NO;
Expand All @@ -3507,6 +3528,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -3562,6 +3584,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = LZGFT5UUA9;
ENABLE_BITCODE = NO;
Expand All @@ -3580,6 +3603,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = apptailors.co.backtrace.swift.ios.example;
Expand Down
13 changes: 13 additions & 0 deletions Examples/Example-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Enable crash loop detector, it crashes count threshold is not specified - default will be used
konst-sauce marked this conversation as resolved.
Show resolved Hide resolved
BacktraceClient.enableCrashLoopDetection()

let isSafeModeRequired = BacktraceClient.isSafeModeRequired()

if isSafeModeRequired {
// Remove current crash file for not to be trapped in a loop of crash detections
BacktraceClient.resetCrashLoopDetection()
// Perform custom checks if necessary and decide if Backtrace should be launched
return true
}

let backtraceCredentials = BacktraceCredentials(endpoint: URL(string: Keys.backtraceUrl as String)!,
token: Keys.backtraceToken as String)

Expand Down
2 changes: 2 additions & 0 deletions Examples/Example-iOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

textView.text = "BadEvents: " + BacktraceClient.consecutiveCrashesCount().description
+ "\nIs Safe to Launch: " + (BacktraceClient.isInSafeMode() ? "FALSE" : "TRUE")
}

@IBAction func outOfMemoryReportAction(_ sender: Any) {
Expand Down
8 changes: 8 additions & 0 deletions Examples/Example-macOS-ObjC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[BacktraceClient enableCrashLoopDetection: 0];
if([BacktraceClient isSafeModeRequired]) {
// Remove current crash file for not to be trapped in a loop of crash detections
[BacktraceClient resetCrashLoopDetection];
// Perform custom checks if necessary and decide if Backtrace should be launched
return;
}

BacktraceCredentials *credentials = [[BacktraceCredentials alloc]
initWithSubmissionUrl: [NSURL URLWithString: Keys.backtraceSubmissionUrl]];
BacktraceDatabaseSettings *backtraceDatabaseSettings = [[BacktraceDatabaseSettings alloc] init];
Expand Down
15 changes: 10 additions & 5 deletions Examples/Example-macOS-ObjC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -619,7 +620,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
Expand Down Expand Up @@ -710,7 +711,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Snf-7p-7db">
<rect key="frame" x="4" y="3" width="472" height="61"/>
<rect key="frame" x="3" y="3" width="474" height="62"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="wS4-BS-4BZ"/>
</constraints>
Expand All @@ -719,7 +720,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="liveReportButtonAction:" target="XfG-lQ-9wD" id="r4X-yE-pnP"/>
<action selector="crashAction:" target="XfG-lQ-9wD" id="OfJ-Ce-bpL"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't liveReportButton stay here?

</connections>
</button>
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FmX-dS-tKd">
Expand All @@ -739,6 +740,10 @@
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="KrE-Pr-E3e">
<rect key="frame" x="-100" y="-100" width="460" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="7RO-Uj-aNq">
<rect key="frame" x="444" y="0.0" width="16" height="190"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
13 changes: 13 additions & 0 deletions Examples/Example-tvOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Enable crash loop detector, it crashes count threshold is not specified - default will be used
BacktraceClient.enableCrashLoopDetection()

let isSafeModeRequired = BacktraceClient.isSafeModeRequired()

if isSafeModeRequired {
// Remove current crash file for not to be trapped in a loop of crash detections
BacktraceClient.resetCrashLoopDetection()
// Perform custom checks if necessary and decide if Backtrace should be launched
return true
}

let backtraceCredentials = BacktraceCredentials(endpoint: URL(string: Keys.backtraceUrl as String)!,
token: Keys.backtraceToken as String)
let backtraceDatabaseSettings = BacktraceDatabaseSettings()
Expand Down
Loading