Skip to content

Commit

Permalink
noisy callstack frame debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
heckj committed May 7, 2024
1 parent 6ffcf5b commit cf60fe3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/Automerge/BoundTypes/AutomergeText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ extension AutomergeText: CustomStringConvertible {
extension AutomergeText: CustomDebugStringConvertible {
public var debugDescription: String {
guard let doc, let objId else {
return "AutomergeText(unbound): \(self._unboundStorage)"
return "AutomergeText(unbound): \(_unboundStorage)"
}
do {
let path = try doc.path(obj: objId).stringPath()
Expand All @@ -399,6 +399,9 @@ extension AutomergeText: ObservableObject {
if #available(macOS 11, iOS 14, *) {
let logger = Logger(subsystem: "Automerge", category: "AutomergeText")
logger.trace("\(self.debugDescription) sending ObjectWillChange")
for callStackFrame in Thread.callStackSymbols[0 ... 6] {
logger.trace(" - \(callStackFrame)")
}
}
#endif
objectWillChange.send()
Expand Down
16 changes: 16 additions & 0 deletions Sources/Automerge/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,25 @@ struct WrappedDoc {

#if canImport(Combine)
import Combine
import OSLog

extension Document: ObservableObject {
fileprivate func sendObjectWillChange() {
#if canImport(os)
if #available(macOS 11, iOS 14, *) {
let logger = Logger(subsystem: "Automerge", category: "AutomergeText")

logger.trace("Document \(String(describing: self)) sending ObjectWillChange")
// concurrency violation
// let headsString = self.heads().map { ch in
// ch.debugDescription
// }.joined(separator: ".")
// logger.trace("heads: \(headsString)")
for callStackFrame in Thread.callStackSymbols[0 ... 5] {
logger.trace(" - \(callStackFrame)")
}
}
#endif
objectWillChange.send()
}
}
Expand Down

0 comments on commit cf60fe3

Please sign in to comment.