From b5c886232cbab9e4c8b5e46c0b76950cf08da627 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 29 Mar 2019 00:34:13 -0400 Subject: [ios] Enable/disable presentsWithTransaction when moving to/from a window. --- platform/ios/src/MGLMapView.mm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c94cf477ef..89fc1e8fab 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1234,12 +1234,35 @@ public: - (void)willMoveToWindow:(UIWindow *)newWindow { [super willMoveToWindow:newWindow]; [self refreshSupportedInterfaceOrientationsWithWindow:newWindow]; + + if (!newWindow) + { + // See https://github.com/mapbox/mapbox-gl-native/issues/14232 + // In iOS 12.2, CAEAGLLayer.presentsWithTransaction can cause dramatic + // slow down. The exact cause of this is unknown, but this work around + // appears to lessen the effects. + // + // Also, consider calling the new mbgl::Renderer::flush() + CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer); + eaglLayer.presentsWithTransaction = NO; + + // Moved from didMoveToWindow + [self validateDisplayLink]; + } } - (void)didMoveToWindow { - [self validateDisplayLink]; [super didMoveToWindow]; + + if (self.window) + { + // See above comment + CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer); + eaglLayer.presentsWithTransaction = YES; + + [self validateDisplayLink]; + } } - (void)didMoveToSuperview -- cgit v1.2.1