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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃洜 Bug: terminating application #88

Closed
muhasturk opened this issue May 11, 2016 · 5 comments
Closed

馃洜 Bug: terminating application #88

muhasturk opened this issue May 11, 2016 · 5 comments

Comments

@muhasturk
Copy link

muhasturk commented May 11, 2016

You create new UIWindow in WhistleFactory() on 20nd line.

It cause the application crash on didFinishLaunchingWithOptions methods because of followings in my opinion.

http://stackoverflow.com/a/33958144/3022613

2016-05-11 04:32:22.166 Smart Citizen[742:145841] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UIApplication.m:3401
2016-05-11 04:32:22.168 Smart Citizen[742:145841] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
*** First throw call stack:
(0x1834f2e38 0x182b57f80 0x1834f2d08 0x183e78124 0x1888e6ad0 0x1888e3674 0x184e937ac 0x184e93618 0x184e939c8 0x1834a9124 0x1834a8bb8 0x1834a68b8 0x1833d0d10 0x1886ab834 0x1886a5f70 0x1000ae594 0x182f6e8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

Can you provide any solution for this? Why do you need to create new UIWindow?

BTW: Without Whisper pod everything works well, same AppDelegate.swift file.

If you want to investigate problem I can share my project folder.

@muhasturk muhasturk changed the title 馃洜 Bug: 馃洜 terminating application 馃洜 Bug: terminating application May 11, 2016
@onmyway133
Copy link
Contributor

@muhasturk Hi, by Without Whisper pod everything works well you mean that just by installing the pod then it crashes?

Do you explicitly show whistle, like show(whistle: murmur)? It would be better if you can share some code so we can investigate it further

@RamonGilabert
Copy link
Contributor

RamonGilabert commented Sep 7, 2016

The Window needs to be created basically because the API for the Status Bar is as bad as it gets. So it's another window on top of the current UIWindow that you are displaying. That basically means that if you add a view to the UIWindow of the Status Bar, such view will appear in the bottom of the status bar, which is not optimal.

With that being said. I don't quite understand the reason of the crash...

@RamonGilabert
Copy link
Contributor

Right. I think I might know the answer.

Are you sure this is caused by Whistle? If yes, can you set it after you make your window key and visible, or even, after you have set your first root controller and has appeared?

I believe the problem is that it's creating two windows at the same time, which is not something optimal I guess.

Going to close this, but feel free to reopen if you have any more information! :)

@jaimeagudo
Copy link

I face similar scenario using an Splash View on my appDelegate while bootstrapping the app. My appdelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


    //UI first
    self.window = UIWindow(frame: UIScreen.main.bounds)
    var splashController: SplashVC? = vc("SplashVC") as! SplashVC
    self.window?.rootViewController = splashController!
    self.window?.makeKeyAndVisible()
    splashController!.splash.startAnimation {
        splashController!.setNeedsStatusBarAppearanceUpdate()
    }


    //App launch code
    self.bootBackgroundTasks() 
  


    //Deferred till promise is fulfilled or rejected
    getInitialController().then { controller -> () in
        self.window?.rootViewController = controller
        self.window?.makeKeyAndVisible()
        splashController!.removeFromParentViewController()
        splashController = nil
        return
        }.catch { e in
            log.error(e.localizedDescription)
    }
}

Then somewhere else I show a whistle


let message = Murmur(title: "Test message",
                              backgroundColor: .orange,
                              titleColor: .white)

Whisper.show(whistle: message, action: secs != 0 ? .show(5) : .present)

The message is displayed just fine... but after the timeout expires I get... the splashController view!

Somehow the hide is retrieving that old window

public func hide() {
    let finalOrigin = view.frame.origin.y - titleLabelHeight
    UIView.animate(withDuration: 0.2, animations: {
      self.whistleWindow.frame.origin.y = finalOrigin
      }, completion: { _ in
        if let window = UIApplication.shared.windows.filter({ $0 != self.whistleWindow }).first {
          window.makeKeyAndVisible()
          self.whistleWindow.windowLevel = UIWindowLevelNormal - 1
          window.rootViewController?.setNeedsStatusBarAppearanceUpdate()
        }
    })
  }

This is my first iOS project so I might be missing something obvious, really appreciate any hints. thanks

@jaimeagudo
Copy link

Going to reply my own question #138

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.

4 participants