-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Obscure GLKView while app is in background #1254
Conversation
Another consequence of this change is that it’ll take longer for the tiles to reload when you switch back to the app. Previously you’d only see a brief flash as the tiles rerender, but now you can easily see the old tiles fade out and the new ones slowly reload. |
Interesting, look forward to testing. |
Hopefully the reloading effect mentioned above will be mitigated by #1255. |
Why are we removing the GLKView when the app pauses? Does that mean the os won't send updates anymore? Does it do that by default? I believe this error is caused by us explicitly triggering a view update, which is invalid when the app is in the background. So we should catch those explicit updates and only trigger them once the app comes back to the foreground. The call that triggers the explicit updates is |
Yes. Here’s the stack trace when that happens:
|
If I'm following this correctly, why don't we just set a |
That’s apparently only one of the places where the OS can fiddle with the
and:
with this on the main thread:
Maybe they’re unrelated, but I’ve been much more successful getting these crashes without the proposed fix. |
With some additional testing, I have been able to reproduce these crashes despite the proposed fix, so I think they’re probably unrelated, rather than being downstream bugs. |
However, there is one crash that always reproduces without my fix and never with:
Triggered by
|
The call to bind |
The console spew – and likely the call to bind
This kind of crash can only occur when the |
Ahhh, this is the OS taking its snapshot of the view, which requests a render, upon going into the background for its own multitasking switcher. I wasn't getting that before. I think this answers our question of who is operating outside the gated API for requesting view updates. |
At this point, I don't think there is an approved way to not have the OS take snapshots of our |
I'll look into it, but even setting the |
Generate the snapshot using `-[UIView snapshotViewAfterScreenUpdates:]` and place it _over_ the `GLKView`. UIKit appears to be able to detect that the `GLKView` is completely obscured and avoids `-_display`ing it.
The key was to have the snapshot view obscure the |
Just in case the host app mucks around with `MGLView`’s internal view hierarchy.
Detach GLKView while app is in background
Meant to retitle this PR first. Just to clarify, the |
Throw a static snapshot up for the app switcher. Hope you didn’t plan on seeing tiles load while the app is in the background.
Fixes #1050, #1186, #1203, #1243. Not sure about #1198.
/cc @incanus @kkaefer