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

RUM-1978 Fix RUM ViewController leak #1533

Merged
merged 7 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
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
Next Next commit
RUM-1978 Initial fix
maciejburda committed Oct 31, 2023

Verified

This commit was signed with the committer’s verified signature.
maciejburda Maciej Burda
commit 8462dc242e5530e03496ea4581873b1cbfd1a8ff
2 changes: 1 addition & 1 deletion DatadogRUM/Sources/RUMMonitor/Monitor.swift
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ extension Monitor: RUMMonitorProtocol {
process(
command: RUMStartViewCommand(
time: dateProvider.now,
identity: viewController,
identity: viewController.asRUMViewIdentity(),
name: name,
path: nil,
attributes: attributes
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ extension String: RUMViewIdentifiable {
// MARK: - `RUMViewIdentity`

/// Manages the `RUMViewIdentifiable` by using either reference or value semantic.
internal struct RUMViewIdentity {
internal struct RUMViewIdentity: RUMViewIdentifiable {
private weak var object: AnyObject?
private let value: Any?

@@ -104,4 +104,20 @@ internal struct RUMViewIdentity {
var identifiable: RUMViewIdentifiable? {
return (object as? RUMViewIdentifiable) ?? (value as? RUMViewIdentifiable)
}

// MARK: - RUMViewIdentifiable

func asRUMViewIdentity() -> RUMViewIdentity {
self
}

var defaultViewPath: String {
if let selfObject = object as? RUMViewIdentifiable {
return selfObject.defaultViewPath
} else if let selfValue = value as? RUMViewIdentifiable {
return selfValue.defaultViewPath
} else {
return ""
}
}
}