Skip to content

Commit 62b623f

Browse files
committed
[Bug Fix] Fix UIHostingViewBase pendingPreferencesUpdate and weak self issue
1 parent 51197b7 commit 62b623f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingViewBase.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,29 +255,26 @@ package class UIHostingViewBase {
255255
return
256256
}
257257
cancelAsyncRendering()
258-
guard updatesAtFullFidelity else {
259-
guard pendingPreferencesUpdate else {
258+
if updatesAtFullFidelity {
259+
view.setNeedsLayout()
260+
CoreTesting.needsRender = true
261+
} else {
262+
guard !pendingPreferencesUpdate else {
260263
return
261264
}
262265
pendingPreferencesUpdate = true
263-
DispatchQueue.main.async { [self] in
264-
guard uiView != nil else {
266+
DispatchQueue.main.async { [weak self] in
267+
guard let self else {
265268
return
266269
}
267270
pendingPreferencesUpdate = false
268-
guard let host else {
269-
return
270-
}
271-
guard canAdvanceTimeAutomatically else {
271+
guard let host, canAdvanceTimeAutomatically else {
272272
return
273273
}
274274
let interval = renderInterval(timestamp: .systemUptime) / Double(UIAnimationDragCoefficient())
275275
host.render(interval: interval, updateDisplayList: false, targetTimestamp: nil)
276276
}
277-
return
278277
}
279-
view.setNeedsLayout()
280-
CoreTesting.needsRender = true
281278
}
282279

283280
package func requestUpdate(after delay: Double) {
@@ -410,8 +407,8 @@ package class UIHostingViewBase {
410407
}
411408
updateTimer?.invalidate()
412409
nextTimerTime = updateTime
413-
updateTimer = withDelay(delay) { [self] in
414-
guard uiView != nil else {
410+
updateTimer = withDelay(delay) { [weak self] in
411+
guard let self else {
415412
return
416413
}
417414
updateTimer = nil

0 commit comments

Comments
 (0)