Skip to content

Commit

Permalink
feat: decode an image on the main thread (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Oct 13, 2023
1 parent 3576aac commit 18c933d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
4 changes: 4 additions & 0 deletions EmpowerPlant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
674899180B469D888700A555 /* Pods_EmpowerPlant.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74014747DE857D26E9BD7B24 /* Pods_EmpowerPlant.framework */; };
846BEA1C2ABE611A0032F77F /* mobydick.txt in Resources */ = {isa = PBXBuildFile; fileRef = 846BEA1B2ABE611A0032F77F /* mobydick.txt */; };
843BD6272AD7798C00B0098F /* jwt-deep-field.png in Resources */ = {isa = PBXBuildFile; fileRef = 843BD6262AD7798C00B0098F /* jwt-deep-field.png */; };
843BD60F2AD08CE900B0098F /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843BD60E2AD08CE900B0098F /* Utils.swift */; };
8B21663C29D3F8C80009C890 /* RandomErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B21663B29D3F8C80009C890 /* RandomErrors.swift */; };
8BA3AB382A20212C00BE1EA8 /* CartViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA3AB372A20212C00BE1EA8 /* CartViewControllerTests.swift */; };
Expand Down Expand Up @@ -40,6 +41,7 @@
57BE79023D12DCDCB69BA73D /* Pods-EmpowerPlant.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EmpowerPlant.release.xcconfig"; path = "Target Support Files/Pods-EmpowerPlant/Pods-EmpowerPlant.release.xcconfig"; sourceTree = "<group>"; };
74014747DE857D26E9BD7B24 /* Pods_EmpowerPlant.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EmpowerPlant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
843BD60E2AD08CE900B0098F /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
843BD6262AD7798C00B0098F /* jwt-deep-field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "jwt-deep-field.png"; sourceTree = "<group>"; };
846BEA1A2ABE46880032F77F /* upload-symbols.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "upload-symbols.sh"; sourceTree = "<group>"; };
8474F0482ACCE2D800F21E06 /* deploy_project.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = deploy_project.sh; sourceTree = "<group>"; };
846BEA1B2ABE611A0032F77F /* mobydick.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = mobydick.txt; sourceTree = "<group>"; };
Expand Down Expand Up @@ -143,6 +145,7 @@
D17C73BB27D8291D006650AF /* Assets.xcassets */,
D17C73BD27D8291D006650AF /* LaunchScreen.storyboard */,
D17C73C027D8291D006650AF /* Info.plist */,
843BD6262AD7798C00B0098F /* jwt-deep-field.png */,
);
path = EmpowerPlant;
sourceTree = "<group>";
Expand Down Expand Up @@ -249,6 +252,7 @@
846BEA1C2ABE611A0032F77F /* mobydick.txt in Resources */,
D17C73BF27D8291D006650AF /* LaunchScreen.storyboard in Resources */,
D17C73BC27D8291D006650AF /* Assets.xcassets in Resources */,
843BD6272AD7798C00B0098F /* jwt-deep-field.png in Resources */,
D17C73BA27D8291D006650AF /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
34 changes: 25 additions & 9 deletions EmpowerPlant/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="f0u-69-w4x">
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="xnN-Pe-VKe">
<rect key="frame" x="0.0" y="144" width="414" height="718"/>
<subviews>
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="b5N-Es-1yE">
<rect key="frame" x="20" y="0.0" width="374" height="0.0"/>
</progressView>
<stackView opaque="NO" contentMode="scaleToFill" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="CCo-Yo-I2U">
<rect key="frame" x="8" y="0.0" width="398" height="718"/>
<stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="CCo-Yo-I2U">
<rect key="frame" x="8" y="0.0" width="398" height="310.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="99H-zP-cDK">
<rect key="frame" x="0.0" y="0.0" width="199" height="276"/>
Expand Down Expand Up @@ -199,6 +199,14 @@
<action selector="unwrapCrash:" destination="VXN-aD-u60" eventType="touchUpInside" id="1ao-hi-gPI"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KsC-dC-9hy">
<rect key="frame" x="0.5" y="241.5" width="198.5" height="34.5"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Decode image on main"/>
<connections>
<action selector="imageOnMain:" destination="VXN-aD-u60" eventType="touchUpInside" id="3hA-YV-UdC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Yrg-wG-isT">
<rect key="frame" x="5" y="241.5" width="189.5" height="34.5"/>
<state key="normal" title="Button"/>
Expand All @@ -210,27 +218,34 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YJc-z6-Cm2">
<rect key="frame" x="6.5" y="276" width="186.5" height="34.5"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="JSON on main thread"/>
<buttonConfiguration key="configuration" style="plain" title="Decode JSON on main"/>
<connections>
<action selector="jsonMainThread:" destination="VXN-aD-u60" eventType="touchUpInside" id="qQX-nt-eti"/>
<action selector="jsonMainThread:" destination="VXN-aD-u60" eventType="touchUpInside" id="iM7-uu-pjl"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="I0Z-7H-qXj">
<rect key="frame" x="157" y="618" width="100" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="23H-sh-JRG"/>
<constraint firstAttribute="width" secondItem="I0Z-7H-qXj" secondAttribute="height" multiplier="1:1" id="ON2-GZ-qjW"/>
</constraints>
</imageView>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="CaI-jg-IPv"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="f0u-69-w4x" firstAttribute="top" secondItem="CaI-jg-IPv" secondAttribute="top" id="2G6-Ag-USq"/>
<constraint firstItem="f0u-69-w4x" firstAttribute="trailing" secondItem="CaI-jg-IPv" secondAttribute="trailing" id="8xl-wI-gVZ"/>
<constraint firstItem="f0u-69-w4x" firstAttribute="bottom" secondItem="CaI-jg-IPv" secondAttribute="bottom" id="N32-oU-NIS"/>
<constraint firstItem="CaI-jg-IPv" firstAttribute="leading" secondItem="xnN-Pe-VKe" secondAttribute="leading" id="9wl-hN-71I"/>
<constraint firstItem="CaI-jg-IPv" firstAttribute="trailing" secondItem="xnN-Pe-VKe" secondAttribute="trailing" id="MaZ-Wb-7nU"/>
<constraint firstItem="xnN-Pe-VKe" firstAttribute="top" secondItem="CaI-jg-IPv" secondAttribute="top" id="OGI-ac-tOr"/>
<constraint firstItem="b5N-Es-1yE" firstAttribute="leading" secondItem="CaI-jg-IPv" secondAttribute="leading" constant="20" id="XDH-Fb-7N5"/>
<constraint firstItem="CaI-jg-IPv" firstAttribute="bottom" secondItem="xnN-Pe-VKe" secondAttribute="bottom" id="kh4-CY-icP"/>
<constraint firstItem="CaI-jg-IPv" firstAttribute="trailing" secondItem="b5N-Es-1yE" secondAttribute="trailing" constant="20" id="mkA-w9-qys"/>
<constraint firstItem="CaI-jg-IPv" firstAttribute="leading" secondItem="f0u-69-w4x" secondAttribute="leading" id="w2b-p0-b01"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="r5d-gZ-zyX">
Expand All @@ -240,6 +255,7 @@
</barButtonItem>
</navigationItem>
<connections>
<outlet property="imageView" destination="I0Z-7H-qXj" id="rOX-B5-9Ch"/>
<outlet property="progressIndicator" destination="b5N-Es-1yE" id="2AX-n4-293"/>
</connections>
</viewController>
Expand Down
8 changes: 8 additions & 0 deletions EmpowerPlant/ListAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ class ListAppViewController: UIViewController {
SentrySDK.close()
}

@IBOutlet weak var imageView: UIImageView!
@IBAction func imageOnMain(_ sender: Any) {
imageView.isHidden = false
let span = SentrySDK.startTransaction(name: "test", operation: "image-on-main")
imageView.image = UIImage(named: "jwt-deep-field.png")
span.finish()
}

@IBOutlet weak var progressIndicator: UIProgressView!
@IBAction func jsonMainThread(_ sender: Any) {
// build up a huge JSON structure
Expand Down
Binary file added EmpowerPlant/jwt-deep-field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18c933d

Please sign in to comment.