SwiftKickMobile/SwiftMessages

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

keshavgesu1 opened this issue · 16 comments

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.

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.

Okay Thank you for your reply. I will Check

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.

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.

@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.

I had try with #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.

@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 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.

@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

Closing due to no response from OP

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

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?

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.

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

Yes I am hiding the message

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?