Re: My app only shows a black screen in the recent apps list
Re: My app only shows a black screen in the recent apps list
- Subject: Re: My app only shows a black screen in the recent apps list
- From: David Duncan <email@hidden>
- Date: Sun, 25 Dec 2016 10:57:52 -0500
> On Dec 23, 2016, at 9:05 AM, Andreas Falkenhahn <email@hidden> wrote:
>
> Further examinations have shown that the issue might be related to the
> fact that my app has the "UIApplicationExitsOnSuspend" flag set to YES.
> When removing this flag, it seems to work correctly. When activating it
> again, however, iOS shows the image from the last run of the app with
> "UIApplicationExitsOnSuspend" set to NO. Really does smell like an iOS
> bug.
This is actually probably the expected behavior in that case, and all due to the fact that the app *exits* when you leave it.
Basically because your app is exiting, you are racing against the OS’s ability to snapshot it. That snapshot does not happen within your process, so sometimes we capture what is there when you suspend (we snapshot before you exit) and sometimes black (you exist before we snapshot). Sometimes we detect this and can go back to your launch image, but not always.
But the practical reality is that ExitOnSuspend is really not the expected path for new applications, but rather a compatibility path for old ones. I would recommend against using it in new applications both because it goes against the design of the OS (that apps are always “there” and their lifetime is managed by the system) and because it goes against user expectation (that you can task switch quickly and come back to the app exactly as it was).
>
> On 23.12.2016 at 14:35 Andreas Falkenhahn wrote:
>
>> On 22.12.2016 at 21:58 David Duncan wrote:
>
>>> Do you do anything special when going into the background? The
>>> snapshot is taken shortly after your application is placed in the
>>> background, so if your view hierarchy changes that is what will actually be snapshotted.
>
>> No, I'm actually not doing anything when the app is shutdown. All
>> respective delegate methods are completely empty. I should add
>> that the actual drawing is done by a worker thread, but of course
>> this thread calls dispatch_sync() when exchanging the layer's
>> contents to the new image, e.g.
>
>> dispatch_sync(dispatch_get_main_queue(), ^{
>> myView.layer.contents = (id) myImage;
>> });
>
>> So it could probably happen that this code is executed even after
>> iOS runs methods like applicationWillResignActive() but certainly
>> not at the same time because I use dispatch_sync() to change the
>> layer's contents on the main thread.
>
>> Upon closer observation, the behaviour is actually really strange.
>> Now that I've added launch images (not a storyboard) the black screen
>> is gone but the launch image is shown instead. But not always!
>> Sometimes there's also a snapshot of my app. And what makes the
>> confusion complete is the fact that iOS sometimes even alternates (!)
>> between those two images when cycling through the recent apps list,
>> e.g. when cycling through the recent apps list by swiping to the left
>> my app shows the launch image. Then, without leaving the recent
>> apps list, I'm cycling through the list again, but this time by swiping
>> to the right, and suddenly my app shows the correct snapshot from
>> the last frame it drew! This is really confusing. Smells like an
>> iOS bug to me because why would it alternate between the launch image
>> and a snapshot without me ever leaving the recent apps list?
>
>
>
> --
> Best regards,
> Andreas Falkenhahn mailto:email@hidden
>
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden