SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 741 forks source link

Message opened via SwiftMessagesSegue closes by itself after 2 seconds (regression, appeared in 9.0.7) #545

Open vitalii-tym opened 3 months ago

vitalii-tym commented 3 months ago

I have SwiftMessageSegue called form the same view controller and configured literally by same code.

In one case the startReleaseMonitor() continues restarting itself each 2 seconds until user dismisses the dialog (expected behavior), but in another case it ends up in self.source.view.window being .none and hides everything (unexpectedly).

Adding segue.duration = .forever doesn't help.

The only meaningful difference in code is that the segue works properly in a scenario when it is called as a result of a button tap:

   @IBAction func updateRequestButtonTapped(_ sender: Any) {
        performSegue(withIdentifier: "openConfirmation", sender: self)
    }

While the malfunctioning scenario is when it is called from a function, which in its turn is triggered from a delegate method.

    private func createFRP() {
        performSegue(withIdentifier: "openConfirmation", sender: self)
    }

    extension NewFlightRequestViewController: SetRequestPreferencesDelegate {
    func createFlightRequest(with preferences: RequestPreferences?) {
        self.viewModel.setRequestPreferences(prefs: preferences)
        self.createFRP()
    }
}

I suppose it might be related to view hierarchy, because in the successful scenario it is opened modally above another modal dialog while in unsuccessful one it is opened modally above a simple view controller (having a usual navigation bar).

Important to note that it worked correctly since 2021. After rolling a few versions back I have figured out it was working fine in 9.0.6 and the issue appeared in 9.0.7.

wtmoose commented 3 months ago

The dismiss monitor should only auto-dismiss if the presenting view controller is removed from the view hierarchy without being properly dismissed, such as if you change the app's root view controller. This is by design. Is your presenting view controller being removed? If so, why should the presented view controller remain presented?

vitalii-tym commented 3 months ago

Nothing changes in the view hierarchy between the moments when this message is opened and when it closes by itself.

I can see that the monitoring function was added on purpose in 0.9.7. So this could be some kind of hard-to-predict behavior in a specific context or in an edge-case scenario.

I will try to analyze and gather more information about the specifics of the context, in which I'm using this segue. Pls give me some time to analyze further.

wtmoose commented 3 months ago

Sure. My question for you would be, if nothing is changing, how do you explain the source view not being in a window? Any view that is being displayed must have its window property set.