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

Swift 3 Ui Freeze with show progress on working with Alamofire #99

Open
danya0365 opened this issue Nov 16, 2016 · 9 comments
Open

Swift 3 Ui Freeze with show progress on working with Alamofire #99

danya0365 opened this issue Nov 16, 2016 · 9 comments

Comments

@danya0365
Copy link

Call KVNProgress.show(0.0, status: "Logging...") in main thread

then in alamofire

request.responseJSON { (response:DataResponse<Any>) in

call

DispatchQueue.main.async { KVNProgress.showSuccess() }
or
KVNProgress.showSuccess()

@danya0365 danya0365 changed the title Swift 3 Ui Freeze with show progress working with Alamofire Swift 3 Ui Freeze with show progress on working with Alamofire Nov 16, 2016
@nick-iCars
Copy link

This may not be limited to alamofire. I am having UI unresponsiveness, when the complete block of KVNProgress.dismiss(completion: {}) is fired. If I dismiss it with KVNProgress.dismiss() there does not seem to be an issue. I am hitting the network when this happens so maybe it is related to that. But I am not using Alamofire anywhere in the app.

@bb-git
Copy link

bb-git commented Dec 28, 2016

I'm also experiencing seemingly random app freezes since migrating to Swift 3, but some of my users are experiencing this pretty often. I'm using KVNProgress heavily, so I will try to reproduce as you described.

@bb-git
Copy link

bb-git commented Jan 19, 2017

So I removed KVNProgress from my project. No more complaints since then, so it is definitly an issue of this library. I use KVNProgress mostly to show success or error.
Hope there will be a fix soon, as this is by far the best library!

@nick-iCars
Copy link

I'm narrowing down the cause of this bug and I think it actually is a result of calling dismiss() multiple times, or more specifically calling dismiss() when there is no kvnprogressview visible.

@VivienCormierRM
Copy link

👍

@VivienCormierRM
Copy link

I was able to fixed this issue (in my case) by adding a .dismiss() before a .showError().

KVNProgress.show(0.5)
KVNProgress.dismiss() <= Add dismiss between show and showError
KVNProgress.showError()

@danya0365
Copy link
Author

Today i already fixed by check isVisible before show other KVNProgress

example

   KVNProgress.show()

after that before recall just check previous.

    if KVNProgress.isVisible() {
        KVNProgress.dismiss(completion: {
            KVNProgress.show()
        })
    } else {


        KVNProgress.show()
    }

@danya0365
Copy link
Author

I created KVNManager to wrapped KNV library to manage it before show or dismiss.

    class KVNProgressManager: NSObject {
        
        static func applyConfig() {
            
            let configuration = KVNProgressConfiguration()
            configuration.minimumDisplayTime = 3.0
            configuration.minimumSuccessDisplayTime = 3.0
            configuration.minimumErrorDisplayTime = 3.0
            KVNProgress.setConfiguration(configuration)
        }
        
        static func show() {
            
            if KVNProgress.isVisible() {
                KVNProgress.dismiss(completion: {
                    KVNProgress.show()
                })
            } else {
                KVNProgress.show()
            }
        }
        
        static func dismiss() {
            
            if KVNProgress.isVisible() {
                KVNProgress.dismiss()
            }
        }
        
        static func dismiss(withCallback callback: @escaping () -> ()) {
            
            if KVNProgress.isVisible() {
                KVNProgress.dismiss(completion: { 
                    callback()
                })
            } else {
                callback()
            }
        }
        
        
        static func showError(withStatus status: String) {
            
            if KVNProgress.isVisible() {
                KVNProgress.dismiss(completion: { 
                    KVNProgress.showError(withStatus: status)
                })
            } else {
                KVNProgress.showError(withStatus: status)
            }
        }
        
        static func showSuccess(withStatus status: String) {
            
            if KVNProgress.isVisible() {
                KVNProgress.dismiss(completion: {
                    KVNProgress.showSuccess(withStatus: status)
                })
            } else {
                KVNProgress.showSuccess(withStatus: status)
            }
        }
    }

@pritesh-khandelwal
Copy link

pritesh-khandelwal commented Sep 6, 2017

Issue still exist with alamofire . Can anyone help on this .

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

5 participants