diff --git a/CovidCertificate.xcodeproj/project.pbxproj b/CovidCertificate.xcodeproj/project.pbxproj index 4598c18b..a9d4db1a 100644 --- a/CovidCertificate.xcodeproj/project.pbxproj +++ b/CovidCertificate.xcodeproj/project.pbxproj @@ -55,6 +55,8 @@ 48CCA621265F93D200887F63 /* CovidCertificateSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 48CCA620265F93D200887F63 /* CovidCertificateSDK */; }; 48CCA623265F93DB00887F63 /* CovidCertificateSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 48CCA622265F93DB00887F63 /* CovidCertificateSDK */; }; 48ECCD2A264F0797008678DD /* StaticContentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8ABDF2264A652800FDE0E1 /* StaticContentViewModel.swift */; }; + 5220AD9C28A3A8BB00460116 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5220AD9B28A3A8BB00460116 /* Client.swift */; }; + 5220AD9E28A3A8D800460116 /* Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5220AD9D28A3A8D800460116 /* Server.swift */; }; 6E0281EF2655022A00582904 /* Impressum in Resources */ = {isa = PBXBuildFile; fileRef = 6E0281EE2655022A00582904 /* Impressum */; }; 6E0281F02655022A00582904 /* Impressum in Resources */ = {isa = PBXBuildFile; fileRef = 6E0281EE2655022A00582904 /* Impressum */; }; 6E0281F226550E1100582904 /* InfoBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E0281F126550E1100582904 /* InfoBoxView.swift */; }; @@ -454,6 +456,8 @@ 274E946A2671E46200110DC5 /* swiss_governmentrootcaii.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = swiss_governmentrootcaii.der; sourceTree = ""; }; 481D1B252685406700A5F804 /* TransferError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferError.swift; sourceTree = ""; }; 4825D131273D5F3E00F4F71E /* SDKOptionsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKOptionsManager.swift; sourceTree = ""; }; + 5220AD9B28A3A8BB00460116 /* Client.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Client.swift; sourceTree = ""; }; + 5220AD9D28A3A8D800460116 /* Server.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Server.swift; sourceTree = ""; }; 6E0281EE2655022A00582904 /* Impressum */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Impressum; sourceTree = ""; }; 6E0281F126550E1100582904 /* InfoBoxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoBoxView.swift; sourceTree = ""; }; 6E0281F42655280500582904 /* InfoBoxButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoBoxButton.swift; sourceTree = ""; }; @@ -1168,6 +1172,8 @@ 6EE55D9F2760A01F001F9E1F /* VerifierHomescreenBottomView.swift */, 6EC1735E2642A1B4002E27DB /* VerifierHomescreenViewController.swift */, 6EA5C3632644298E00EA066F /* VerifierHomescreenInfoView.swift */, + 5220AD9B28A3A8BB00460116 /* Client.swift */, + 5220AD9D28A3A8D800460116 /* Server.swift */, ); path = Homescreen; sourceTree = ""; @@ -1980,6 +1986,7 @@ DCBF64E92679B92C00450D51 /* StackScrollViewController.swift in Sources */, 6EC172E726429E31002E27DB /* DebugLog.swift in Sources */, 6EC172E826429E31002E27DB /* UBButton.swift in Sources */, + 5220AD9C28A3A8BB00460116 /* Client.swift in Sources */, 6EC172E926429E31002E27DB /* UIStackView+CC.swift in Sources */, 6EC172EA26429E31002E27DB /* UBKeyboardObserver.m in Sources */, F8130CE02685B99F00A29326 /* Collection+Safe.swift in Sources */, @@ -2007,6 +2014,7 @@ 6EC172F326429E31002E27DB /* UIDevice+ScreenType.swift in Sources */, 6EA5C37226444E8600EA066F /* VerifyCheckViewController.swift in Sources */, 6EC172F426429E31002E27DB /* StackScrollView.swift in Sources */, + 5220AD9E28A3A8D800460116 /* Server.swift in Sources */, F88DA6B4268C786D001DB072 /* Error+NetworkError.swift in Sources */, F8E6C5632683808F00A9E112 /* DebugSwitchView.swift in Sources */, 6EC172F526429E31002E27DB /* ClickthroughStackView.swift in Sources */, diff --git a/Verifier/Screens/Homescreen/Client.swift b/Verifier/Screens/Homescreen/Client.swift new file mode 100644 index 00000000..54b76bc9 --- /dev/null +++ b/Verifier/Screens/Homescreen/Client.swift @@ -0,0 +1,27 @@ +// +/* + * Copyright (c) 2021 Ubique Innovation AG + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +import Foundation + + +class Client { + var server: Server + + init (server: Server) { + self.server = server + + self.server.add(client: self) //This line creates a Retain Cycle -> Leak! + } + + deinit { + print("Client di init") + } +} diff --git a/Verifier/Screens/Homescreen/LeakyObject.swift b/Verifier/Screens/Homescreen/LeakyObject.swift new file mode 100644 index 00000000..06a09333 --- /dev/null +++ b/Verifier/Screens/Homescreen/LeakyObject.swift @@ -0,0 +1,56 @@ +// +/* + * Copyright (c) 2021 Ubique Innovation AG + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +import Foundation + +class LeakySwiftObject { + var cycle: LeakySwiftObject? + let bigObject = BigObject() + + @inline(never) + init(cycleSize: Int = 0) { + var head = self + + for _ in 0.. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +import Foundation + + +class Server { + + let id: Int + + var clients: [Client] //Because this reference is strong + + func add(client: Client) { + self.clients.append(client) + } + + + init(id: Int) { + self.id = id + self.clients = [] + } + + deinit { + print("Server di init") + } +} + diff --git a/Verifier/Screens/Homescreen/SwiftActionHandler.swift b/Verifier/Screens/Homescreen/SwiftActionHandler.swift new file mode 100644 index 00000000..52a9b907 --- /dev/null +++ b/Verifier/Screens/Homescreen/SwiftActionHandler.swift @@ -0,0 +1,42 @@ +// +/* + * Copyright (c) 2021 Ubique Innovation AG + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +import Foundation + +class SwiftActionHandler { + @inline(never) + private func privateFunction(depth: Int) { + if depth == 0 { + sleep(1) + } else { + privateFunction(depth: depth - 1) + } + } + + @inline(never) + func callRecursiveFunction(depth: Int) { + privateFunction(depth: depth) + } + + @inline(never) + func crash() { + raise(SIGSEGV) + } + + @inline(never) + func doAfterRecursing(depth: Int = 0, action: () -> ()) { + if depth == 0 { + action() + } else { + doAfterRecursing(depth: depth - 1, action: action) + } + } +} diff --git a/Verifier/Screens/Homescreen/VerifierHomescreenViewController.swift b/Verifier/Screens/Homescreen/VerifierHomescreenViewController.swift index 4922f2b1..fb3d4a5a 100644 --- a/Verifier/Screens/Homescreen/VerifierHomescreenViewController.swift +++ b/Verifier/Screens/Homescreen/VerifierHomescreenViewController.swift @@ -19,9 +19,15 @@ extension Notification.Name { class VerifierHomescreenViewController: HomescreenBaseViewController { // MARK: - Init + + init() { super.init(color: .cc_greyish) + print("Creating Server...") + let server = Server(id: 3) + let client = Client(server: server) + server.add(client: client) } // MARK: - Subviews