Skip to content

Commit

Permalink
Make webview ref weak
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayterDev committed Mar 22, 2024
1 parent 2f64ae6 commit 60d5768
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PerformanceMetricsSubfeature: Subfeature {
public var featureName: String = "performanceMetrics"
public var broker: UserScriptMessageBroker?

private var targetWebview: WKWebView
private weak var targetWebview: WKWebView?
private var timer: Timer?
private var completionHandler: (([Double]?) -> Void)?

Expand All @@ -53,6 +53,7 @@ public class PerformanceMetricsSubfeature: Subfeature {

public func notifyHandler(completion: @escaping ([Double]?) -> Void) {
guard let broker else { completion(nil); return }
guard let targetWebview else { completion(nil); return }

completionHandler = completion
broker.push(method: "getVitals", params: nil, for: self, into: targetWebview)
Expand Down

0 comments on commit 60d5768

Please sign in to comment.