You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Workflow/Sources/SubtreeManager.swift
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,10 @@
16
16
17
17
import Dispatch
18
18
19
+
#if DEBUG
20
+
import IssueReporting
21
+
#endif
22
+
19
23
extensionWorkflowNode{
20
24
/// Manages the subtree of a workflow. Specifically, this type encapsulates the logic required to update and manage
21
25
/// the lifecycle of nested workflows across multiple render passes.
@@ -76,6 +80,16 @@ extension WorkflowNode {
76
80
77
81
wrapped.invalidate()
78
82
83
+
#if DEBUG
84
+
// Try to ensure it didn't escape from the invocation.
85
+
diagnoseEscapedReference(to: consume wrapped){ objectID in
86
+
"Detected escape of a RenderContext<\(WorkflowType.self)> instance from a `render()` method. A RenderContext is only valid to use within render(); allowing it to escape may lead to incorrect behavior. Search for the address of '\(objectID)' in the memory graph debugger to determine why it may have escaped."
87
+
}
88
+
#else
89
+
// For binding lifetime consistency
90
+
_ = consume wrapped
91
+
#endif
92
+
79
93
/// After the render is complete, assign children using *only the children that were used during the render
80
94
/// pass.* This means that any pre-existing children that were *not* used during the render pass are removed
result =performSimpleActionApplication(markStateAsChanged:true)
304
303
}
304
+
305
+
// N.B. This logic would perhaps be nicer to put in a defer
306
+
// statement, but that seems to mess with the precise control
307
+
// we need over binding lifetimes to perform these checks.
308
+
_ = consume wrappedContext
309
+
context.invalidate()
310
+
#if DEBUG
311
+
// Try to ensure it didn't escape from the invocation.
312
+
diagnoseEscapedReference(to: consume context){ objectID in
313
+
"Detected escaped reference to an ApplyContext<\(A.WorkflowType.self)> when applying action '\(action)'. An ApplyContext is only valid for the duration of its associated action application, and should not escape. Search for the address of '\(objectID)' in the memory graph debugger to investigate."
0 commit comments