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

Layout.swift: Fatal error: Attempted to read an unowned reference but the object was already deallocated #440

Closed
mschonvogel opened this issue Feb 18, 2021 · 5 comments · Fixed by #441

Comments

@mschonvogel
Copy link

Sometimes when dismissing the panel with a swipe gesture, it crashes in Layout.swift, line 307.

image

I'm using version 2.2.0

This is how create the panel:

    static func createPanel(userId: String) -> FloatingPanelController {
        let panelViewController = FloatingPanelController()
        let viewController = ProfileViewController(userId: userId)
        viewController.panelController = panelViewController
        panelViewController.layout = IntrinsicFloatingPanelLayout()
        let behavior = FloatingPanelDefaultBehavior()
        behavior.removalInteractionVelocityThreshold = 2.5
        panelViewController.behavior = behavior
        panelViewController.set(contentViewController: viewController)
        panelViewController.isRemovalInteractionEnabled = true
        panelViewController.surfaceView.appearance.cornerRadius = Metrics.Panel.cornerRadius
        panelViewController.surfaceView.backgroundColor = UIColor.defaultBackground
        panelViewController.backdropView.dismissalTapGestureRecognizer.isEnabled = true
        panelViewController.surfaceView.grabberHandle.isHidden = true
        return panelViewController
    }

And this is the layout I'm using:

class IntrinsicFloatingPanelLayout: FloatingPanelLayout {
    let position: FloatingPanelPosition = .bottom
    let initialState: FloatingPanelState = .full
    var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
        [
            .full: FloatingPanelIntrinsicLayoutAnchor(absoluteOffset: 0, referenceGuide: .superview),
        ]
    }
}
@scenee
Copy link
Owner

scenee commented Feb 19, 2021

Thank you for your report. I've been wondering about a possibility of a memory leak in updateScrollView() since before but I've had no evidence. But now I'm convinced the inner function must be change thanks to your report. I will take care of this crash this weekend.

@scenee
Copy link
Owner

scenee commented Feb 20, 2021

Hello, @mschonvogel. I've created a branch to attempt to fix this issue(PR #441). Could you please check whether this branch fixes your reporting issue or not?

@mschonvogel
Copy link
Author

Yes, will do. As I am not really able to reproduce the bug, I'd say I'll just use the app and let you know in 2-3 days if it crashed again or not?

@mschonvogel
Copy link
Author

Looking good, no crash so far @scenee 👍

@scenee
Copy link
Owner

scenee commented Feb 23, 2021

Thank you so much, @mschonvogel 🎉 I will merge PR #441 and release the new version in a week.

scenee added a commit that referenced this issue Feb 23, 2021
To fix a crash "Layout.swift: Fatal error: Attempted to read an unowned reference but the object was already deallocated"  which is reported at issue #440.
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

Successfully merging a pull request may close this issue.

2 participants