summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-03-29 00:05:16 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-03-29 00:05:16 -0400
commit6a777bcbbbe649786bdbab0fcb3938857aaedad2 (patch)
tree082413ec928b645f3a5a06cccd5140c885f2b3f7
parent4d21a663b87d7d84daf4440e875d213c0e76b15e (diff)
downloadqtlocation-mapboxgl-upstream/jrex/1125-investigations.tar.gz
Tweaks to timers and tests.upstream/jrex/1125-investigations
-rw-r--r--platform/darwin/src/MGLRendererFrontend.h8
-rw-r--r--platform/ios/app/MBXTabBarController.m12
-rw-r--r--platform/ios/app/MBXViewController.m45
-rw-r--r--platform/ios/src/MGLMapView.mm24
4 files changed, 63 insertions, 26 deletions
diff --git a/platform/darwin/src/MGLRendererFrontend.h b/platform/darwin/src/MGLRendererFrontend.h
index 2df67ca4e4..0133a910ca 100644
--- a/platform/darwin/src/MGLRendererFrontend.h
+++ b/platform/darwin/src/MGLRendererFrontend.h
@@ -56,6 +56,14 @@ public:
return renderer.get();
}
+ void flush() {
+ mbgl::BackendScope guard { mbglBackend, mbgl::BackendScope::ScopeType::Implicit };
+
+ if (renderer) {
+ renderer->flush();
+ }
+ }
+
void reduceMemoryUse() {
if (!renderer) return;
renderer->reduceMemoryUse();
diff --git a/platform/ios/app/MBXTabBarController.m b/platform/ios/app/MBXTabBarController.m
index 09c8cb8e07..fece92f5a7 100644
--- a/platform/ios/app/MBXTabBarController.m
+++ b/platform/ios/app/MBXTabBarController.m
@@ -14,14 +14,16 @@
@implementation MBXTabBarController
-- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
+- (void)viewDidLoad {
+ [super viewDidLoad];
if (NSProcessInfo.processInfo.environment[@"AUTOMATE"]) {
- [NSTimer scheduledTimerWithTimeInterval:2.0
+ [NSTimer scheduledTimerWithTimeInterval:0.25
repeats:YES block:^(NSTimer * _Nonnull timer) {
- self.tab = !self.tab;
- [self setSelectedIndex:self.tab];
+ if (self.presentedViewController == nil) {
+ self.tab = !self.tab;
+ [self setSelectedIndex:self.tab];
+ }
}];
}
}
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 3adfd52fb8..d148fa86d2 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -216,6 +216,7 @@ CLLocationCoordinate2D randomWorldCoordinate() {
@property (nonatomic) CLLocationCoordinate2D circlingCameraCenterCoordinate;
@property (nonatomic) CLLocationDirection circlingCameraDirection;
@property (nonatomic) NSTimer *circlingTimer;
+@property (nonatomic) BOOL circling;
@end
@@ -242,36 +243,42 @@ CLLocationCoordinate2D randomWorldCoordinate() {
}
}
+- (void)viewWillDisappear:(BOOL)animated {
+ [super viewWillDisappear:animated];
+ if (self.circling) {
+ [self.circlingTimer invalidate];
+ self.circlingTimer = nil;
+ }
+}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
- if (NSProcessInfo.processInfo.environment[@"AUTOMATE"]) {
- [self setup14232ReproSteps];
+ if (self.circling) {
+ self.circlingTimer = [NSTimer scheduledTimerWithTimeInterval:.25
+ target:self
+ selector:@selector(circlingCameraTimerFired:)
+ userInfo:nil
+ repeats:YES];
}
}
- (void)setup14232ReproSteps {
+ self.circling = (NSProcessInfo.processInfo.environment[@"CIRCLING"]);
+
// Add 100 annotations
- [self parseFeaturesAddingCount:100 usingViews:YES];
- self.circlingCameraCenterCoordinate = CLLocationCoordinate2DMake(38.899835, -77.034068);
- self.circlingCameraDirection = 0.0;
- self.circlingTimer = [NSTimer scheduledTimerWithTimeInterval:.3 target:self selector:@selector(circlingCameraTimerFired:) userInfo:nil repeats:YES];
-
-}
+ if (self.circling) {
+ self.circlingCameraCenterCoordinate = CLLocationCoordinate2DMake(38.899835, -77.034068);
+ self.circlingCameraDirection = 0.0;
+ self.circlingTimer = [NSTimer scheduledTimerWithTimeInterval:.25 target:self selector:@selector(circlingCameraTimerFired:) userInfo:nil repeats:YES];
+// [self parseFeaturesAddingCount:1000 usingViews:YES];
+ }
+}
- (void)circlingCameraTimerFired:(NSTimer*)timer {
-
- BOOL isVisible = self.view.superview && self.view.window;
-
- if (!isVisible) {
- return;
- }
-
- // Not a circle, but good enough for this test
- CLLocationDistance distRadians = 10000.0/6378100.0;
+ CLLocationDistance distRadians = 10000.0/6378100.0;
CLLocationDegrees bearing = self.circlingCameraDirection * M_PI / 180.0;
CLLocationDegrees lat1 = self.circlingCameraCenterCoordinate.latitude * M_PI / 180.0;
@@ -283,8 +290,6 @@ CLLocationCoordinate2D randomWorldCoordinate() {
CLLocationCoordinate2D newCenter = CLLocationCoordinate2DMake(lat2 * 180.0 / M_PI,
lon2 * 180.0 / M_PI);
-// [self.mapView setCenterCoordinate:newCenter zoomLevel:9 animated:YES];
-
CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[self.mapView _setCenterCoordinate:newCenter
edgePadding:self.mapView.contentInset
@@ -306,6 +311,8 @@ CLLocationCoordinate2D randomWorldCoordinate() {
{
[super viewDidLoad];
+ [self setup14232ReproSteps];
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveState:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(restoreState:) name:UIApplicationWillEnterForegroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveState:) name:UIApplicationWillTerminateNotification object:nil];
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 51db11ab8c..42a8c5aaf9 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1226,19 +1226,39 @@ public:
}
- (void)willMoveToWindow:(UIWindow *)newWindow {
+
+ if (newWindow == nil) {
+#ifdef WORKAROUND_1125
+ CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
+ eaglLayer.presentsWithTransaction = NO;
+
+ // Following 2 not necessary?
+ _rendererFrontend->flush();
+#endif
+ [self validateDisplayLink]; // Moved from didMove...
+ }
+
[super willMoveToWindow:newWindow];
[self refreshSupportedInterfaceOrientationsWithWindow:newWindow];
}
- (void)didMoveToWindow
{
- [self validateDisplayLink];
[super didMoveToWindow];
+
+ if (self.window) {
+#ifdef WORKAROUND_1125
+ CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
+ eaglLayer.presentsWithTransaction = YES;
+#endif
+ [self validateDisplayLink];
+ }
+
}
- (void)didMoveToSuperview
{
- [self validateDisplayLink];
+ [self validateDisplayLink]; // Is this necessary?
[self installConstraints];
[super didMoveToSuperview];
}