Skip to content
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

iOS 13, Xcode 11 infinite loop related to the swizzled layoutSubviews() #184

Open
sebastienwindal opened this issue Sep 24, 2019 · 3 comments

Comments

@sebastienwindal
Copy link

We have a custom view and we overrode layoutSubviews() as recommended:

open override func layoutSubviews() {
        super.layoutSubviews()
        // Ensure layout is updated after screen rotation, etc
        self.layoutNode?.view.frame = self.bounds
        // Update frame to match layout
        self.frame.size = self.intrinsicContentSize
    }

and it would appear the app is stuck in some kind of infinite loop, our custom view layoutSubviews () and layout_layoutSubviews() being called forever and blocking the main thread

extension UIView {
    fileprivate static func _swizzle() {
        guard !viewSwizzled else { return }
        replace(#selector(layoutSubviews), of: self, with: #selector(layout_layoutSubviews))
        viewSwizzled = true
    }

    // Swizzled layoutSubviews implementation
    @objc private func layout_layoutSubviews() {
        layout_layoutSubviews()
        _layoutNode?.updateLayout()
    }
}
@matape
Copy link

matape commented Oct 1, 2019

Same here! Endless loop on iOS 13.1.1 with Layout.
Just on loading the first VC using self.loadLayout() the app is running in endless loop.

Bildschirmfoto 2019-10-01 um 09 01 41

@comm1x
Copy link
Contributor

comm1x commented Oct 3, 2019

@matape I got the same issue on 0.6.36.
Updating to 0.6.38 fixed this issue.

@nicklockwood
Copy link
Owner

nicklockwood commented Oct 4, 2019

@sebastienwindal @matape can you provide a larger code sample? I'm having trouble reproducing the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants