Skip to content

Commit

Permalink
Merge branch 'master' into ref/sentry-mechanism-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann authored Mar 31, 2021
2 parents 3d0ac16 + 25c76d6 commit 0e4d967
Show file tree
Hide file tree
Showing 20 changed files with 915 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

### Features and Fixes

- feat: Async callstacks are being tracked by wrapping the `dispatch_async` and related APIs. #998
- perf: Avoid allocating dict in BreadcrumbTracker #1027
- feat: Add start and endSession to SentrySDK #1021
- fix: Crash when passing garbage to maxBreadcrumbs #1018
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
<action selector="oomCrash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6Eb-uS-ljp"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lr8-6E-lN6">
<rect key="frame" x="0.0" y="180" width="398" height="30"/>
<state key="normal" title="async crash"/>
<connections>
<action selector="asyncCrash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="c9v-X0-ZOl"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down
15 changes: 15 additions & 0 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ - (IBAction)crash:(id)sender
[SentrySDK crash];
}

- (IBAction)asyncCrash:(id)sender
{
dispatch_async(dispatch_get_main_queue(), ^{ [self asyncCrash1]; });
}

- (void)asyncCrash1
{
dispatch_async(dispatch_get_main_queue(), ^{ [self asyncCrash2]; });
}

- (void)asyncCrash2
{
dispatch_async(dispatch_get_main_queue(), ^{ [SentrySDK crash]; });
}

- (IBAction)oomCrash:(id)sender
{
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down
7 changes: 7 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
<action selector="oomCrash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Oju-om-O6e"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xur-X2-ih4">
<rect key="frame" x="0.0" y="210" width="398" height="30"/>
<state key="normal" title="async crash"/>
<connections>
<action selector="asyncCrash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Mqi-sE-R7d"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down
20 changes: 19 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,30 @@ class ViewController: UIViewController {
SentrySDK.crash()
}

@IBAction func asyncCrash(_ sender: Any) {
DispatchQueue.main.async {
self.asyncCrash1()
}
}

func asyncCrash1() {
DispatchQueue.main.async {
self.asyncCrash2()
}
}

func asyncCrash2() {
DispatchQueue.main.async {
SentrySDK.crash()
}
}

@IBAction func oomCrash(_ sender: Any) {
DispatchQueue.main.async {
let megaByte = 1_024 * 1_024
let memoryPageSize = NSPageSize()
let memoryPages = megaByte / memoryPageSize

while true {
// Allocate one MB and set one element of each memory page to something.
let ptr = UnsafeMutablePointer<Int8>.allocate(capacity: megaByte)
Expand Down
11 changes: 11 additions & 0 deletions Samples/macOS-Swift/macOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,17 @@
<action selector="sentryCrash:" target="XfG-lQ-9wD" id="8gG-2n-QOP"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="onh-qf-HCq" userLabel="asyncCrash">
<rect key="frame" x="180" y="25" width="126" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="async crash" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3ec-oQ-wXv">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="asyncCrash:" target="XfG-lQ-9wD" id="8L4-eE-eEw"/>
</connections>
</button>
</subviews>
</view>
</viewController>
Expand Down
18 changes: 18 additions & 0 deletions Samples/macOS-Swift/macOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ class ViewController: NSViewController {
@IBAction func sentryCrash(_ sender: Any) {
SentrySDK.crash()
}

@IBAction func asyncCrash(_ sender: Any) {
DispatchQueue.main.async {
self.asyncCrash1()
}
}

func asyncCrash1() {
DispatchQueue.main.async {
self.asyncCrash2()
}
}

func asyncCrash2() {
DispatchQueue.main.async {
SentrySDK.crash()
}
}
}
28 changes: 24 additions & 4 deletions Samples/tvOS-Swift/tvOS-Swift/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,25 @@ struct ContentView: View {
transaction.finish()
})
}


func asyncCrash1() {
DispatchQueue.main.async {
self.asyncCrash2()
}
}

func asyncCrash2() {
DispatchQueue.main.async {
SentrySDK.crash()
}
}

var oomCrashAction: () -> Void = {
DispatchQueue.main.async {
let megaByte = 1_024 * 1_024
let memoryPageSize = NSPageSize()
let memoryPages = megaByte / memoryPageSize

while true {
// Allocate one MB and set one element of each memory page to something.
let ptr = UnsafeMutablePointer<Int8>.allocate(capacity: megaByte)
Expand All @@ -63,7 +75,7 @@ struct ContentView: View {
}
}
}

var body: some View {
VStack {
Button(action: addBreadcrumbAction) {
Expand All @@ -89,13 +101,21 @@ struct ContentView: View {
Button(action: captureTransactionAction) {
Text("Capture Transaction")
}

Button(action: {
SentrySDK.crash()
}) {
Text("Crash")
}

Button(action: {
DispatchQueue.main.async {
self.asyncCrash1()
}
}) {
Text("Async Crash")
}

Button(action: oomCrashAction) {
Text("OOM Crash")
}
Expand Down
Loading

0 comments on commit 0e4d967

Please sign in to comment.