Show splash screen before finished launching?


James Walker
 

I’m trying to show a splash screen in applicationWillFInishLaunching:, but it doesn’t actually appear until applicationDidFinishLaunching: seconds later. I’ve done all I can think of to make it show up:

[NSApp activateIgnoringOtherApps: YES];
[splashWindow orderFrontRegardless];
[splashWindow display];

Is there anything else I can do to make the window draw?


Jon Gotow
 

Try putting this after your orderFront call:

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];

The runloop basically has to do at least one iteration before the new window will actually be mapped to the screen.

- Jon

On Sep 6, 2018, at 12:17 PM, James Walker <list2@jwwalker.com> wrote:

I’m trying to show a splash screen in applicationWillFInishLaunching:, but it doesn’t actually appear until applicationDidFinishLaunching: seconds later. I’ve done all I can think of to make it show up:

[NSApp activateIgnoringOtherApps: YES];
[splashWindow orderFrontRegardless];
[splashWindow display];

Is there anything else I can do to make the window draw?


James Walker
 

On Sep 6, 2018, at 1:39 PM, Jon Gotow <gotow@stclairsoft.com> wrote:

Try putting this after your orderFront call:

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];

The runloop basically has to do at least one iteration before the new window will actually be mapped to the screen.

Tried that, no change.


- Jon


On Sep 6, 2018, at 12:17 PM, James Walker <list2@jwwalker.com> wrote:

I’m trying to show a splash screen in applicationWillFInishLaunching:, but it doesn’t actually appear until applicationDidFinishLaunching: seconds later. I’ve done all I can think of to make it show up:

[NSApp activateIgnoringOtherApps: YES];
[splashWindow orderFrontRegardless];
[splashWindow display];

Is there anything else I can do to make the window draw?


Jon Gotow
 

Hmph - now that you mention it, there's no current runloop at that point - the app is still launching. So [NSRunloop currentRunLoop] is probably returning nil. You could grabbing mainRunLoop and running that, but I don't know what impact that's going to have during the app launch process.

- Jon

On Sep 6, 2018, at 2:59 PM, James Walker <list2@jwwalker.com> wrote:

Tried that, no change.


James Walker
 

On Sep 6, 2018, at 2:03 PM, Jon Gotow <gotow@stclairsoft.com> wrote:

Hmph - now that you mention it, there's no current runloop at that point - the app is still launching. So [NSRunloop currentRunLoop] is probably returning nil. You could grabbing mainRunLoop and running that, but I don't know what impact that's going to have during the app launch process.

- Jon
I wondered about that myself, and logged out the values of [NSRunloop currentRunLoop] and [NSRunloop mainRunLoop]. They showed the same non-nil value.


Quincey Morris
 

On Sep 6, 2018, at 11:17 , James Walker <list2@...> wrote:

I’m trying to show a splash screen in applicationWillFInishLaunching:, but it doesn’t actually appear until applicationDidFinishLaunching: seconds later.

Coming at this from the other side, why does it take enough seconds to get from willFinishLaunching to didFinishLaunching that you care? If you can reduce that time a bit, maybe you don’t have to solve the original problem.

IIRC from the last time this topic was discussed, getting windows displayed earlier than didFinishLaunching is pretty treacherous.



James Walker
 

On Sep 6, 2018, at 5:13 PM, Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

On Sep 6, 2018, at 11:17 , James Walker <list2@jwwalker.com> wrote:

I’m trying to show a splash screen in applicationWillFInishLaunching:, but it doesn’t actually appear until applicationDidFinishLaunching: seconds later.
Coming at this from the other side, why does it take enough seconds to get from willFinishLaunching to didFinishLaunching that you care? If you can reduce that time a bit, maybe you don’t have to solve the original problem.

IIRC from the last time this topic was discussed, getting windows displayed earlier than didFinishLaunching is pretty treacherous.
I come here looking for a simple solution, and you try to make me THINK? That’s hardly fair. :-)

I managed to move some work onto a different thread, and fix a place where my main thread was getting blocked for a while. Though it would still be nice to solve this mystery.

New clue: if I run the app in Xcode using the option "Launch application without state restoration", then the splash window appears sooner.