Skip to content

Commit 62307da

Browse files
committed
fix(ios): dispose retry runtime outside state lock
1 parent ead7fa0 commit 62307da

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

sdks/flutter/packages/tugboat/ios/Classes/TugboatPlugin.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,15 @@ public class TugboatPlugin: NSObject, FlutterPlugin, NativeCaptureHostApi {
116116
/// so this attempt uses only the time left in the original request budget.
117117
private func makeHierarchyRuntime(timeoutMs: Int64) -> CaptureRuntime? {
118118
stateLock.lock()
119-
defer { stateLock.unlock() }
120-
guard !disposed else { return nil }
119+
guard !disposed else {
120+
stateLock.unlock()
121+
return nil
122+
}
121123
let created = CaptureRuntime(timeoutMs: timeoutMs, coverage: .viewHierarchy)
122-
hierarchyRuntime?.dispose()
124+
let previous = hierarchyRuntime
123125
hierarchyRuntime = created
126+
stateLock.unlock()
127+
previous?.dispose()
124128
return created
125129
}
126130

0 commit comments

Comments
 (0)