Black screen after iOS LaunchScreen/LaunchImage

With Defold 1.2.163 the launch screen/image was effective, there was no gap between the launch screen/image and the app content.

With Defold 1.2.164 there is a short period of time with black screen, which gets longer depending on the loading time of the app.
This results in a black flash when launching an app, which is not pleasant to the eye.

1 Like

Hmm, apart from changing to using the UIApplicationMain, I don’t know what could have caused this.
Although launchimages are deprecated, so we should probably look into supporting a launch story board.

3 Likes

Still actual:

If we add the backgroundColor with clear_color value to the ViewController.m view, it is safe for Defold?

Perhaps this will indirectly fix the situation if this blink is the black color of the UIWindow.

1 Like

Ticket #6142.

1 Like

Running into the same issue. Anyone ever figure out a workaround for this?

The recommendation is to have a tiny bootstrap collection that launches extremely quickly and then use collection proxies to load the bulk of your content. This should minimize/remove the chance to see a black screen while the bootsrap collection is loading.

And, setting the graphics device clear color to something matching the splash screen/main menu will also help make it look better.

1 Like

Thank you for the quick answers! But even with the tiniest app and the right clear colors I can see a black flash. And worse, it appears that if the app is loaded ‘cold’ iOS does a ‘nice’ crossfade between launch screen and app, resulting in a slightly longer black screen. Not sure if that is what happens, but that is what it appears like.

So after some digging and talking to chatGPT about possible fixes I ended on the following solution: in the didFinishLaunchingWithOptions method in AppDelegate, load the launch screen storyboard and put it front like so:

	// Load the LaunchScreen storyboard
	UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
	UIViewController *launchScreenVC = [storyboard instantiateInitialViewController];
	UIView *launchScreenView = launchScreenVC.view;

	// Add the launch screen view as a placeholder
	launchScreenView.frame = self.window.bounds;
	launchScreenView.tag = 999; // Set a tag to identify the view later
	[self.window addSubview:launchScreenView];
	[self.window bringSubviewToFront:launchScreenView];
	[self.window makeKeyAndVisible];

Then remove this UIView in the appUpdate method

	// Cleanup the placeholder view once the engine is initialized
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		dispatch_async(dispatch_get_main_queue(), ^{
			UIWindow *window = [UIApplication sharedApplication].keyWindow;
			UIView *viewToRemove = [window viewWithTag:999];
			[viewToRemove removeFromSuperview];
		});
	});

Currently I have this working through a native extension by using method swizzling and it looks much smoother. I could make the changes to the engine myself and put in a pull request, however I don’t know how to access the Launch Screen setting in the editor so that it correctly loads the launch screen set by the user.

Also, not sure if this method is considered ‘clean’ enough codewise, but it works very smoothly.

So, the issue happens even if you’ve set a custom story board in the game.project, under “ios”:“launch_screen”?

The file is copied during bundling, and setting is set in the Info.plist, as “launch-screen”:

Edit: And yes, we would very much like a fix for the issue as a PR. Perhaps continue relevant technical discussion to the PR?

1 Like

Oh yeah a black flash happens even if you set up a launch screen according to the documentation. If you don’t, the launch is just black altogether.

I’ll start working on getting the fix in

2 Likes