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

fix: Detecting ANRs as false OOMs #1695

Merged
merged 28 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4bb5904
fix: Detect ANRs as OOMs
philipphofmann Mar 2, 2022
37ac123
Changelog entry
philipphofmann Mar 15, 2022
f099e10
Comments
philipphofmann Mar 15, 2022
fe6c713
Fix tests
philipphofmann Mar 15, 2022
66a2f15
Fix tests
philipphofmann Mar 15, 2022
3f09e6d
Improve samples
philipphofmann Mar 15, 2022
8d47a02
Cleanup
philipphofmann Mar 15, 2022
bce2209
fix patch
philipphofmann Mar 15, 2022
5495c38
Merge branch 'master' into feat/anr
philipphofmann Mar 15, 2022
b0e48b7
Merge branch 'master' into feat/anr
philipphofmann Mar 16, 2022
cd1a698
Remove ANR options
philipphofmann Mar 16, 2022
6565481
Fix test
philipphofmann Mar 16, 2022
f89eecf
Improve logging for ANRTeacker
philipphofmann Mar 16, 2022
526a209
Update Sources/Sentry/SentryANRTracker.m
philipphofmann Mar 16, 2022
353e0c1
More logging improvements
philipphofmann Mar 16, 2022
dca41a5
test directive
philipphofmann Mar 16, 2022
4a4e38a
Reorganize directives
philipphofmann Mar 16, 2022
ab72268
Fix tests
philipphofmann Mar 16, 2022
095d268
Small comment
philipphofmann Mar 16, 2022
3148bfc
Reset container on close
philipphofmann Mar 16, 2022
30f2a46
Remove test check
philipphofmann Mar 16, 2022
02cccf3
Use directive for whole file
philipphofmann Mar 16, 2022
f02d9dd
Fix
philipphofmann Mar 16, 2022
c31163f
Directive fix
philipphofmann Mar 16, 2022
a55318b
Send message to nowhere
philipphofmann Mar 16, 2022
0d22ebc
Update Sources/Sentry/SentryANRTrackingIntegration.m
philipphofmann Mar 16, 2022
d83d3a7
Make container thread safe
philipphofmann Mar 16, 2022
5e32b7f
Fix tests
philipphofmann Mar 16, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- fix: Detecting ANRs as false OOMs (#1695)

## 7.10.2

fix: Crash in UIViewControllerSwizzling (#1692)
Expand Down
8 changes: 4 additions & 4 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
D8269A58274C0FC700BD5BD5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637AFDAD243B02760034958B /* ViewController.swift */; };
D8269A59274C100300BD5BD5 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; };
D8269A5A274C100300BD5BD5 /* Sentry.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D83A30C8279EFD6E00372D0A /* clearTestState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83A30C7279EFD6E00372D0A /* clearTestState.swift */; };
D83A30C8279EFD6E00372D0A /* ClearTestState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83A30C7279EFD6E00372D0A /* ClearTestState.swift */; };
D83A30D1279F0A7C00372D0A /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; };
D83A30D8279F159D00372D0A /* Sentry.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D83A30DC279F16BA00372D0A /* Sentry.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -205,7 +205,7 @@
D8269A42274C095F00BD5BD5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
D8269A49274C096000BD5BD5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D8269A5C274C108100BD5BD5 /* iOS13-Swift.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "iOS13-Swift.entitlements"; sourceTree = "<group>"; };
D83A30C7279EFD6E00372D0A /* clearTestState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = clearTestState.swift; sourceTree = "<group>"; };
D83A30C7279EFD6E00372D0A /* ClearTestState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClearTestState.swift; sourceTree = "<group>"; };
D83A30DF279F1F5C00372D0A /* fatal-error-binary-images-message2.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "fatal-error-binary-images-message2.json"; path = "../../../Tests/Resources/fatal-error-binary-images-message2.json"; sourceTree = "<group>"; };
D83A30E5279FE21F00372D0A /* SentryFileIOTrackingIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SentryFileIOTrackingIntegrationTests.swift; path = ../../../Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift; sourceTree = "<group>"; };
D840D520273A07F400CDF142 /* iOS-SwiftClip.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS-SwiftClip.app"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -345,7 +345,7 @@
D83A30DF279F1F5C00372D0A /* fatal-error-binary-images-message2.json */,
7B64386A26A6C544000D0F65 /* LaunchUITests.swift */,
D83A30E5279FE21F00372D0A /* SentryFileIOTrackingIntegrationTests.swift */,
D83A30C7279EFD6E00372D0A /* clearTestState.swift */,
D83A30C7279EFD6E00372D0A /* ClearTestState.swift */,
7B64386C26A6C544000D0F65 /* Info.plist */,
);
path = "iOS-SwiftUITests";
Expand Down Expand Up @@ -684,7 +684,7 @@
files = (
D83A30E6279FE21F00372D0A /* SentryFileIOTrackingIntegrationTests.swift in Sources */,
7B64386B26A6C544000D0F65 /* LaunchUITests.swift in Sources */,
D83A30C8279EFD6E00372D0A /* clearTestState.swift in Sources */,
D83A30C8279EFD6E00372D0A /* ClearTestState.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
36 changes: 26 additions & 10 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="5CD-RQ-aBU">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="5CD-RQ-aBU">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -18,7 +18,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="480-5y-FtF">
<rect key="frame" x="8" y="188" width="398" height="574.5"/>
<rect key="frame" x="8" y="158" width="398" height="634.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QJW-l9-sD6">
<rect key="frame" x="0.0" y="0.0" width="398" height="30"/>
Expand Down Expand Up @@ -85,54 +85,68 @@
<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">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Yi7-GN-26l">
<rect key="frame" x="0.0" y="270" width="398" height="30"/>
<state key="normal" title="ANR fully blocking"/>
<connections>
<action selector="anrFullyBlocking:" destination="BYZ-38-t0r" eventType="touchUpInside" id="dJy-Fs-khK"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TSF-10-5ts">
<rect key="frame" x="0.0" y="300" width="398" height="30"/>
<state key="normal" title="ANR filling run loop"/>
<connections>
<action selector="anrFillingRunLoop:" destination="BYZ-38-t0r" eventType="touchUpInside" id="13D-io-hVz"/>
</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="330" 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>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cdR-H3-8fr">
<rect key="frame" x="0.0" y="300" width="398" height="30"/>
<rect key="frame" x="0.0" y="360" width="398" height="30"/>
<state key="normal" title="Capture Transaction"/>
<connections>
<action selector="captureTransaction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="kff-pT-Uf4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8CV-WC-ffq">
<rect key="frame" x="0.0" y="330" width="398" height="30"/>
<rect key="frame" x="0.0" y="390" width="398" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="testNavigationTransactionButton"/>
<state key="normal" title="Test Navigation Transaction"/>
<connections>
<segue destination="cay-7M-Gvd" kind="show" id="boD-GG-VVF"/>
</connections>
</button>
<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="360" width="398" height="30"/>
<rect key="frame" x="0.0" y="420" width="398" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="showNibButton"/>
<state key="normal" title="Show Nib"/>
<connections>
<action selector="showNibController:" destination="BYZ-38-t0r" eventType="touchUpInside" id="E8m-GA-zvY"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RjO-LN-eHj">
<rect key="frame" x="0.0" y="390" width="398" height="30"/>
<rect key="frame" x="0.0" y="450" width="398" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="showTableViewButton"/>
<state key="normal" title="Show TableView"/>
<connections>
<action selector="showTableViewController:" destination="BYZ-38-t0r" eventType="touchUpInside" id="u6U-9d-UMi"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ok0-hq-2kK">
<rect key="frame" x="0.0" y="420" width="398" height="30"/>
<rect key="frame" x="0.0" y="480" width="398" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="showSplitViewButton"/>
<state key="normal" title="Show SplitView"/>
<connections>
<segue destination="DGj-BO-BQ5" kind="presentation" id="G2z-UO-upZ"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="UrL-kT-AJU">
<rect key="frame" x="0.0" y="450" width="398" height="124.5"/>
<rect key="frame" x="0.0" y="510" width="398" height="124.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="DSN " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="m3h-wb-Xfa">
<rect key="frame" x="8" y="32" width="382" height="20.5"/>
Expand Down Expand Up @@ -172,6 +186,8 @@
</view>
<navigationItem key="navigationItem" title="Sentry Test App (Swift)" id="Ddh-Ww-vzM"/>
<connections>
<outlet property="anrFillingRunLoopButton" destination="TSF-10-5ts" id="Qp6-8q-IPH"/>
<outlet property="anrFullyBlockingButton" destination="Yi7-GN-26l" id="tMf-U3-onN"/>
<outlet property="dsnTextField" destination="L2a-LY-eQ7" id="TWn-0u-2v7"/>
</connections>
</viewController>
Expand Down
38 changes: 37 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import UIKit
class ViewController: UIViewController {

@IBOutlet weak var dsnTextField: UITextField!
@IBOutlet weak var anrFullyBlockingButton: UIButton!
@IBOutlet weak var anrFillingRunLoopButton: UIButton!

private let dispatchQueue = DispatchQueue(label: "ViewController")

Expand Down Expand Up @@ -49,7 +51,7 @@ class ViewController: UIViewController {
SentrySDK.addBreadcrumb(crumb: crumb)
}

@IBAction func captureMessage(_ sender: Any) {
@IBAction func captureMessage(_ sender: Any) {
let eventId = SentrySDK.capture(message: "Yeah captured a message")
// Returns eventId in case of successfull processed event
// otherwise nil
Expand Down Expand Up @@ -149,6 +151,40 @@ class ViewController: UIViewController {
}
}

@IBAction func anrFullyBlocking(_ sender: Any) {
let buttonTitle = self.anrFullyBlockingButton.currentTitle
var i = 0

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

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

self.anrFullyBlockingButton.setTitle(buttonTitle, for: .normal)
}

@IBAction func anrFillingRunLoop(_ sender: Any) {
let buttonTitle = self.anrFillingRunLoopButton.currentTitle
var i = 0

dispatchQueue.async {
for _ in 0...100_000 {
i += Int.random(in: 0...10)
i -= 1

DispatchQueue.main.async {
self.anrFillingRunLoopButton.setTitle("Work in Progress \(i)", for: .normal)
}
}

DispatchQueue.main.async {
self.anrFillingRunLoopButton.setTitle(buttonTitle, for: .normal)
}
}
}

@IBAction func dsnChanged(_ sender: UITextField) {
let options = Options()
options.dsn = sender.text
Expand Down
Loading