SwiftKickMobile / SwiftMessages

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

Message view is not showing sometimes after update of '9.0.6' #516

Closed keshavgesu1 closed 1 year ago

keshavgesu1 commented 1 year ago

I have recently updated to latest version '9.0.6'. And I am facing issue some times message is not showing at my end I debug the code my code looks fine. SwiftMessages.show(config: view.popupConfig, view: view) is being called.

wtmoose commented 1 year ago

This isn't a problem other people are having, so my initial guess is you're doing something unusual in your code. However, since I don't have your code, there's not much I can do. Is there any way you could attach a sample project that reproduces the problem?

Otherwise, I can help you step through the SwiftMessages code on your end to understand what is happening. My first suggestion is to put a break point on line 607 of SwiftMessages.swift:

try current.show { completed in

If this line is not being reached, it means that SwiftMessages decided not to display your message, maybe due to de-duplication logic. Otherwise, something is going wrong with the view presentation in Presenter.swift. Either way, we should be able to step through the code and get to the line of code where something goes wrong.

Hope that helps.

keshavgesu1 commented 1 year ago

Okay Thank you for your reply. I will Check

wangchaodong commented 1 year ago

This isn't a problem other people are having, so my initial guess is you're doing something unusual in your code. However, since I don't have your code, there's not much I can do. Is there any way you could attach a sample project that reproduces the problem?

Otherwise, I can help you step through the SwiftMessages code on your end to understand what is happening. My first suggestion is to put a break point on line 607 of SwiftMessages.swift:

try current.show { completed in

If this line is not being reached, it means that SwiftMessages decided not to display your message, maybe due to de-duplication logic. Otherwise, something is going wrong with the view presentation in Presenter.swift. Either way, we should be able to step through the code and get to the line of code where something goes wrong.

Hope that helps.

I got the same issue here.
the first time I call SwiftMessages.show to show a view, it works perfectly, After I hide this view with SwiftMessages.hideAll(), I change the rootViewController of the Window. and then I go back to call SwiftMessages.show to show my view, it does't work.

I had try with config.ignoreDuplicates = false , it does't work.

20230429-123653 I debug and found that the self._current == nil is false. I'm not sure how to figure out.

wangchaodong commented 1 year ago

This isn't a problem other people are having, so my initial guess is you're doing something unusual in your code. However, since I don't have your code, there's not much I can do. Is there any way you could attach a sample project that reproduces the problem? Otherwise, I can help you step through the SwiftMessages code on your end to understand what is happening. My first suggestion is to put a break point on line 607 of SwiftMessages.swift:

try current.show { completed in

If this line is not being reached, it means that SwiftMessages decided not to display your message, maybe due to de-duplication logic. Otherwise, something is going wrong with the view presentation in Presenter.swift. Either way, we should be able to step through the code and get to the line of code where something goes wrong. Hope that helps.

I got the same issue here. the first time I call SwiftMessages.show to show a view, it works perfectly, After I hide this view with SwiftMessages.hideAll(), I change the rootViewController of the Window. and then I go back to call SwiftMessages.show to show my view, it does't work.

I had try with config.ignoreDuplicates = false , it does't work.

20230429-123653 I debug and found that the self._current == nil is false. I'm not sure how to figure out.

I found my bug and solve it, I didnot hidAll SwiftMessage show's view befour change the rootViewController of the Window, and the view show by SwiftMessage cannot see because rootVC of window changed, and that's need to be carefully. But after SwiftMessage hide all and then to change rootVC of window, SwiftMessage works well.

wtmoose commented 1 year ago

@wangchaodong you're right. Orphaned message views can block the queue. This can happen if you remove the view hierarchy before the message is hidden. It is uncommon and hasn't come up in a long time, so I'd forgotten about it. I put together a PR that attempts to prevent orphaned message views from blocking the queue.

@wangchaodong @keshavgesu1 please try the changes in #517 and let me know if it resolves the issue.

wangchaodong commented 1 year ago

I had try with https://github.com/SwiftKickMobile/SwiftMessages/pull/517, and it work no different with master branch. if I did not hide swiftmessage shows view before I change rootVC of Window, it still not work. I think you should catch it in a demo. easily show a swiftmessage view, and the change rootVC of Window, and try show swiftmessage view again. hope it can help you.

wtmoose commented 1 year ago

@wangchaodong well, I think it makes more sense for you to supply a sample project since you are the one experiencing the issue and I only have a vague description of the steps. In any case, I put one together that replaces the root view controller and it is working correctly. Maybe you could modify this project to reproduce your issue?

SwiftMessagesTest#516.zip

wangchaodong commented 1 year ago

@wangchaodong well, I think it makes more sense for you to supply a sample project since you are the one experiencing the issue and I only have a vague description of the steps. In any case, I put one together that replaces the root view controller and it is working correctly. Maybe you could modify this project to reproduce your issue?

SwiftMessagesTest#516.zip

In your demo, it works, but not such perfect. In my project , my presentationContext is set to .window, So I try to replace config.presentationContext = .viewController(self) with config.presentationContext = .window(windowLevel: .normal)

and then the cardView will not hide. So maybe that's the point you need to take care. hope it can help you.

wtmoose commented 1 year ago

@wangchaodong I see. With config.presentationContext = .window(windowLevel: .normal), I would say that SwiftMessages is working as designed. The global SwiftMessages instance has no way of knowing your intentions, so it would not dismiss the message on your behalf. What you can do is use a local SwiftMessages instance in your view controller. When it gets deinited, it will automatically dismiss.

See here:

SwiftMessagesTest#516.zip

wtmoose commented 1 year ago

Closing due to no response from OP

veeranfmq commented 1 year ago

Hi, I am getting the same issue after updating the pods, Swift message with configuration is in the memory, however, not showing, Attaching a screenshot, and this is also happening after changing the root view controller.

Basically, the swift message window is beneath the UIWindow

SwiftMessageIssue
wtmoose commented 1 year ago

Hi, I am getting the same issue after updating the pods, Swift message with configuration is in the memory, however, not showing, Attaching a screenshot, and this is also happening after changing the root view controller.

Basically, the swift message window is beneath the UIWindow

SwiftMessageIssue

Is my above reply missing something?

veeranfmq commented 1 year ago

Yes, it is not mentioned why on changing root vc the presenter is not showing. it's hiding beneath the window, please check above attached screenshot.

wtmoose commented 1 year ago

You have to hide the message before changing the root view controller

veeranfmq commented 1 year ago

Yes I am hiding the message

wtmoose commented 1 year ago

This isn't a normal issue and I don't quite understand what you're doing to get into this state. I need detailed reproduction steps or a sample project. Maybe you could take the sample project I attached above modify it to reproduce your issue?