Skip to content

_UIHostingView deinit crash #87

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

Open
Kyle-Ye opened this issue Apr 27, 2024 · 4 comments
Open

_UIHostingView deinit crash #87

Kyle-Ye opened this issue Apr 27, 2024 · 4 comments
Labels
crash help wanted PR contribution is appreciated P1 Medium priority platform: iOS test Test related issue

Comments

@Kyle-Ye
Copy link
Member

Kyle-Ye commented Apr 27, 2024

image
@MainActor
@Test
func testDemo() throws {
    struct ContentView: View {
        var name = ""
        var body: some View {
            AnyView(EmptyView())
        }
    }
    let vc = UIHostingController(rootView: ContentView())
    vc.triggerLayout()
}
extension UIHostingController {
    func triggerLayout() {
        let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        window.rootViewController = self
        window.makeKeyAndVisible()
        view.layoutSubviews()
    }
}

Commit Hash: a166851

@Kyle-Ye
Copy link
Member Author

Kyle-Ye commented Apr 27, 2024

Workaround this partially by #88

@Kyle-Ye Kyle-Ye added help wanted PR contribution is appreciated platform: iOS P1 Medium priority crash test Test related issue labels Apr 27, 2024
@Kyle-Ye Kyle-Ye closed this as completed Feb 5, 2025
@Kyle-Ye Kyle-Ye reopened this Feb 22, 2025
@Kyle-Ye
Copy link
Member Author

Kyle-Ye commented Feb 22, 2025

(lldb) settings set target.language objc

# OpenSwiftUI:
# GraphHost.init
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x6000002847c0)
(int) $0 = 3
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x6000002848e0)
(int) $1 = 3

(lldb) mr 0x6000002847c0
0x6000002847c0: 0x01000001ec0cdb09 0x0003000000007080
0x6000002847d0: 0x000060000290dce0 0x0000000000000000
0x6000002847e0: 0x00000001e6b40bc8 0x0000000000000003
0x6000002847f0: 0x0000000103a08318 0x0000000000000000
(lldb) mr 0x6000002848e0
0x6000002848e0: 0x01000001ec0cdb09 0x0003000000007080
0x6000002848f0: 0x000060000290da40 0x0000000000000000
0x600000284900: 0x0000000000000000 0x0000000000000000
0x600000284910: 0x0000000000000000 0x0000000000000000

# GraphHost.invalidate
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x6000002847c0)
(int) $0 = 1
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x6000002848e0)
(int) $1 = 1

# After globalSubgraph.invalidate
# 0x6000002847c0 becomes invalid

# SwiftUI:

# GraphHost.invalidate
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x0000600000204020)
(int) $1 = 1
(lldb) expr (int)CFGetRetainCount((CFTypeRef)0x00006000002040a0)
(int) $2 = 4

# After globalSubgraph.invalidate
# 0x0000600000204020 is still valid and ref count is 1

@Kyle-Ye
Copy link
Member Author

Kyle-Ye commented Feb 22, 2025

The root cause is anywhere else. But fixing the any view issue (#204) on EditModeScopeModifier can temporary workaround it.

@Kyle-Ye
Copy link
Member Author

Kyle-Ye commented Feb 23, 2025

Blocked by OpenGraph's implementation on Subgraph.invalidate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash help wanted PR contribution is appreciated P1 Medium priority platform: iOS test Test related issue
Projects
None yet
Development

No branches or pull requests

1 participant