diff --git a/Sources/Common/Debug.swift b/Sources/Common/Debug.swift index 096397683..9a1884f20 100644 --- a/Sources/Common/Debug.swift +++ b/Sources/Common/Debug.swift @@ -40,13 +40,11 @@ public func breakByRaisingSigInt(_ description: String, file: StaticString = #fi #if DEBUG // get symbol from stack trace for a caller of a calling method -public func callingSymbol() -> String { +public func callingSymbol(after lastSymbolName: String? = nil) -> String { let stackTrace = Thread.callStackSymbols // find `callingSymbol` itself or dispatch_once_callout - var callingSymbolIdx = stackTrace.firstIndex(where: { $0.contains("_dispatch_once_callout") }) - ?? stackTrace.firstIndex(where: { $0.contains("callingSymbol") })! - // procedure calling `callingSymbol` - callingSymbolIdx += 1 + var callingSymbolIdx = lastSymbolName.flatMap { lastSymbolName in stackTrace.lastIndex(where: { $0.contains(lastSymbolName) }) } + ?? stackTrace.firstIndex(where: { $0.contains("callingSymbol") })! + 1 // procedure calling `callingSymbol` var symbolName: String repeat { diff --git a/Sources/Navigation/Extensions/WKFrameInfoExtension.swift b/Sources/Navigation/Extensions/WKFrameInfoExtension.swift index b2badbff0..b5698c08b 100644 --- a/Sources/Navigation/Extensions/WKFrameInfoExtension.swift +++ b/Sources/Navigation/Extensions/WKFrameInfoExtension.swift @@ -57,7 +57,8 @@ public extension WKFrameInfo { method_exchangeImplementations(originalRequestMethod, swizzledRequestMethod) // ignore `request` selector calls from `safeRequest` itself - ignoredRequestUsageSymbols.insert(callingSymbol()) + let callingSymbol = callingSymbol(after: "addSafetyCheckForSafeRequestUsageOnce") + ignoredRequestUsageSymbols.insert(callingSymbol) // ignore `-[WKFrameInfo description]` ignoredRequestUsageSymbols.insert("-[WKFrameInfo description]") }() diff --git a/Sources/Navigation/Extensions/WKNavigationActionExtension.swift b/Sources/Navigation/Extensions/WKNavigationActionExtension.swift index 56b35eb94..31ffbce67 100644 --- a/Sources/Navigation/Extensions/WKNavigationActionExtension.swift +++ b/Sources/Navigation/Extensions/WKNavigationActionExtension.swift @@ -60,8 +60,9 @@ extension WKNavigationAction: WebViewNavigationAction { let swizzledSourceFrameMethod = class_getInstanceMethod(WKNavigationAction.self, #selector(WKNavigationAction.swizzledSourceFrame))! method_exchangeImplementations(originalSourceFrameMethod, swizzledSourceFrameMethod) + let callingSymbol = callingSymbol(after: "addSafetyCheckForSafeSourceFrameUsageOnce") // ignore `sourceFrame` selector calls from `safeSourceFrame` itself - ignoredSourceFrameUsageSymbols.insert(callingSymbol()) + ignoredSourceFrameUsageSymbols.insert(callingSymbol) // ignore `-[WKNavigationAction description]` ignoredSourceFrameUsageSymbols.insert("-[WKNavigationAction description]") }()