-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Enable/disable presentsWithTransaction to address #14232 #14307
Conversation
…ndow. Added change log Recreate GL views if rendering takes > 1 second. (since glClear is blocked for 1 sec) Use presentsWithTransaction only if we have annotation UIViews. Re-add annotation views.
…re are 3 view annotations
[self.glView display]; | ||
CFTimeInterval after = CACurrentMediaTime(); | ||
|
||
if (after-before >= 1.0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My second comment on this #ifdef is that I'm concerned about unintended consequences and believe the risks could outweigh the potential benefits, especially since this issue is so difficult to reproduce, but glClear could be blocked due to a variety of circumstances. We don't want to throw this hammer at every circumstance.
I can get onboard with offering this "escape hatch" in the code if we can implement it in a way so that it's entirely opt-in by the developer. I'm also ok with testing this before merging to see what the impact is like. But I remain skeptical that this is going to be a net-better experience for most apps and their end-users, compared to the status quo where sometimes when you rapidly switch between tabs many times, the map freezes and you have to restart the app. The vast majority of apps don't have use cases where users are frequently switching tabs, and until we hear more than one report of this issue, I think this would be overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The developer would need to be building from source & provide the MGL_RECREATE_GL_IN_AN_EMERGENCY
define as @1ec5 mentions above.
However, we will need to test that code path regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single OpenGL call should take milliseconds. If glClear()
is blocked for a second or more, that’s a clear sign of trouble, whether or not it’s the specific issue we’re trying to work around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I remain skeptical that this is going to be a net-better experience for most apps and their end-users, compared to the status quo where sometimes when you rapidly switch between tabs many times, the map freezes and you have to restart the app.
Totally agree. We could decide (later) to change from an #ifdef
to a developer set property, but hopefully a better solution will have shown its head by then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, longer term it might be worth having something more robust anyway. But then, Metal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
…anges (if visible)
@@ -444,6 +449,7 @@ - (void)commonInit | |||
{ | |||
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; | |||
_opaque = NO; | |||
_atLeastiOS_12_2_0 = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){12,2,0}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The operating system version doesn’t change dynamically during the process’ lifetime, so we can set this variable in +initialize
above. (The same also goes for _isTargetingInterfaceBuilder
, come to think of it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, let's address this later.
@@ -1101,6 +1110,13 @@ - (void)updateFromDisplayLink:(CADisplayLink *)displayLink | |||
{ | |||
MGLAssertIsMainThread(); | |||
|
|||
// Not "visible" - this isn't a full definition of visibility, but if | |||
// the map view doesn't have a window then it *cannot* be visible. | |||
if (!self.window) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty safe assumption. Do we suspect that -didMoveToWindow
doesn’t get called as reliably?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More concerns about when and how the display link method may be called. It's definitely defensive and a remnant of testing, but I think it's worth keeping.
_glView.drawableDepthFormat = GLKViewDrawableDepthFormat16; | ||
_glView.contentScaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; | ||
_glView.layer.opaque = _opaque; | ||
_glView.delegate = self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These several lines are copy-pasted from -createGLView
. Can we refactor that method to avoid the duplication? I’m just concerned that we may find it useful to keep this method around longer-term, but it’s really easy to forget to keep two code paths in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Moved from: #14264
This is a potential work around for for the slowdown reported in #14232. This may not address the associated crash.
As @jmkiley notes in that issue the cause appears to be the introduction of
CAEAGLLayer.presentsWithTransaction
in #12895 to synchronize OpenGL and UIKit views.