Feature/ios performances (#44)
* improved ios performances * fix merge issue * cleanup playground * update gitignore for playground
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -15,7 +15,10 @@
|
|||||||
/cmake-build-debug
|
/cmake-build-debug
|
||||||
/platform/android/build
|
/platform/android/build
|
||||||
/platform/android/MapboxGLAndroidSDK/src/main/assets/sdk_versions/com.mapbox.mapboxsdk
|
/platform/android/MapboxGLAndroidSDK/src/main/assets/sdk_versions/com.mapbox.mapboxsdk
|
||||||
|
/platform/ios/platform/ios/Mapbox.playground/build/
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
**/.idea
|
**/.idea
|
||||||
/platform/android/MapboxGLAndroidSDKTestApp/local.properties
|
/platform/android/MapboxGLAndroidSDKTestApp/local.properties
|
||||||
|
|||||||
BIN
.gitignore.swp
Normal file
BIN
.gitignore.swp
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1120"
|
LastUpgradeVersion = "1240"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
||||||
BuildableName = "Mapbox GL.app"
|
BuildableName = "MapLibre GL.app"
|
||||||
BlueprintName = "iosapp"
|
BlueprintName = "iosapp"
|
||||||
ReferencedContainer = "container:ios.xcodeproj">
|
ReferencedContainer = "container:ios.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
||||||
BuildableName = "Mapbox GL.app"
|
BuildableName = "MapLibre GL.app"
|
||||||
BlueprintName = "iosapp"
|
BlueprintName = "iosapp"
|
||||||
ReferencedContainer = "container:ios.xcodeproj">
|
ReferencedContainer = "container:ios.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
||||||
BuildableName = "Mapbox GL.app"
|
BuildableName = "MapLibre GL.app"
|
||||||
BlueprintName = "iosapp"
|
BlueprintName = "iosapp"
|
||||||
ReferencedContainer = "container:ios.xcodeproj">
|
ReferencedContainer = "container:ios.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
|
||||||
BuildableName = "Mapbox GL.app"
|
BuildableName = "MapLibre GL.app"
|
||||||
BlueprintName = "iosapp"
|
BlueprintName = "iosapp"
|
||||||
ReferencedContainer = "container:ios.xcodeproj">
|
ReferencedContainer = "container:ios.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
|||||||
@@ -158,6 +158,12 @@ enum { MGLAnnotationTagNotFound = UINT32_MAX };
|
|||||||
/// The threshold used to consider when a tilt gesture should start.
|
/// The threshold used to consider when a tilt gesture should start.
|
||||||
const CLLocationDegrees MGLHorizontalTiltToleranceDegrees = 45.0;
|
const CLLocationDegrees MGLHorizontalTiltToleranceDegrees = 45.0;
|
||||||
|
|
||||||
|
/// The time between background snapshot attempts.
|
||||||
|
const NSTimeInterval MGLBackgroundSnapshotImageInterval = 60.0;
|
||||||
|
|
||||||
|
/// The delay after the map has idled before a background snapshot is attempted.
|
||||||
|
const NSTimeInterval MGLBackgroundSnapshotImageIdleDelay = 3.0;
|
||||||
|
|
||||||
/// Mapping from an annotation tag to metadata about that annotation, including
|
/// Mapping from an annotation tag to metadata about that annotation, including
|
||||||
/// the annotation itself.
|
/// the annotation itself.
|
||||||
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationTagContextMap;
|
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationTagContextMap;
|
||||||
@@ -1552,6 +1558,8 @@ public:
|
|||||||
_displayLink.paused = YES;
|
_displayLink.paused = YES;
|
||||||
[self processPendingBlocks];
|
[self processPendingBlocks];
|
||||||
|
|
||||||
|
if (self.lastSnapshotImage)
|
||||||
|
{
|
||||||
if ( ! self.glSnapshotView)
|
if ( ! self.glSnapshotView)
|
||||||
{
|
{
|
||||||
self.glSnapshotView = [[UIImageView alloc] initWithFrame: _mbglView->getView().frame];
|
self.glSnapshotView = [[UIImageView alloc] initWithFrame: _mbglView->getView().frame];
|
||||||
@@ -1562,6 +1570,7 @@ public:
|
|||||||
|
|
||||||
self.glSnapshotView.image = self.lastSnapshotImage;
|
self.glSnapshotView.image = self.lastSnapshotImage;
|
||||||
self.glSnapshotView.hidden = NO;
|
self.glSnapshotView.hidden = NO;
|
||||||
|
self.glSnapshotView.alpha = 1;
|
||||||
|
|
||||||
if (self.debugMask && [self.glSnapshotView.subviews count] == 0)
|
if (self.debugMask && [self.glSnapshotView.subviews count] == 0)
|
||||||
{
|
{
|
||||||
@@ -1570,6 +1579,7 @@ public:
|
|||||||
snapshotTint.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.25];
|
snapshotTint.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.25];
|
||||||
[self.glSnapshotView addSubview:snapshotTint];
|
[self.glSnapshotView addSubview:snapshotTint];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_mbglView->deleteView();
|
_mbglView->deleteView();
|
||||||
}
|
}
|
||||||
@@ -1586,9 +1596,15 @@ public:
|
|||||||
|
|
||||||
_mbglView->createView();
|
_mbglView->createView();
|
||||||
|
|
||||||
|
[UIView transitionWithView:self
|
||||||
|
duration:0.25
|
||||||
|
options:UIViewAnimationOptionTransitionCrossDissolve
|
||||||
|
animations:^{
|
||||||
self.glSnapshotView.hidden = YES;
|
self.glSnapshotView.hidden = YES;
|
||||||
|
}
|
||||||
|
completion:^(BOOL finished) {
|
||||||
[self.glSnapshotView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
[self.glSnapshotView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||||
|
}];
|
||||||
|
|
||||||
_displayLink.paused = NO;
|
_displayLink.paused = NO;
|
||||||
|
|
||||||
@@ -5946,7 +5962,8 @@ public:
|
|||||||
|
|
||||||
- (void)locationManager:(__unused id<MGLLocationManager>)manager didUpdateHeading:(CLHeading *)newHeading
|
- (void)locationManager:(__unused id<MGLLocationManager>)manager didUpdateHeading:(CLHeading *)newHeading
|
||||||
{
|
{
|
||||||
if ( ! _showsUserLocation || self.pan.state == UIGestureRecognizerStateBegan || newHeading.headingAccuracy < 0) return;
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
|
||||||
|
if ( ! self->_showsUserLocation || self.pan.state == UIGestureRecognizerStateBegan || newHeading.headingAccuracy < 0) return;
|
||||||
|
|
||||||
self.userLocation.heading = newHeading;
|
self.userLocation.heading = newHeading;
|
||||||
|
|
||||||
@@ -5959,7 +5976,7 @@ public:
|
|||||||
{
|
{
|
||||||
[self.delegate mapView:self didUpdateUserLocation:self.userLocation];
|
[self.delegate mapView:self didUpdateUserLocation:self.userLocation];
|
||||||
|
|
||||||
if ( ! _showsUserLocation) return;
|
if (!self->_showsUserLocation) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLLocationDirection headingDirection = (newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading);
|
CLLocationDirection headingDirection = (newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading);
|
||||||
@@ -5968,7 +5985,9 @@ public:
|
|||||||
&& self.userTrackingState != MGLUserTrackingStateBegan)
|
&& self.userTrackingState != MGLUserTrackingStateBegan)
|
||||||
{
|
{
|
||||||
[self _setDirection:headingDirection animated:YES];
|
[self _setDirection:headingDirection animated:YES];
|
||||||
|
[self updateUserLocationAnnotationView];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)locationManager:(__unused id<MGLLocationManager>)manager didFailWithError:(NSError *)error
|
- (void)locationManager:(__unused id<MGLLocationManager>)manager didFailWithError:(NSError *)error
|
||||||
@@ -6353,6 +6372,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)mapViewWillStartRenderingFrame {
|
- (void)mapViewWillStartRenderingFrame {
|
||||||
|
[self cancelBackgroundSnapshot];
|
||||||
|
|
||||||
if (!_mbglMap)
|
if (!_mbglMap)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -6413,6 +6434,8 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self queueBackgroundSnapshot];
|
||||||
|
|
||||||
if ([self.delegate respondsToSelector:@selector(mapViewDidBecomeIdle:)]) {
|
if ([self.delegate respondsToSelector:@selector(mapViewDidBecomeIdle:)]) {
|
||||||
[self.delegate mapViewDidBecomeIdle:self];
|
[self.delegate mapViewDidBecomeIdle:self];
|
||||||
}
|
}
|
||||||
@@ -6891,6 +6914,39 @@ public:
|
|||||||
return _annotationViewReuseQueueByIdentifier[identifier];
|
return _annotationViewReuseQueueByIdentifier[identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Snapshot image -
|
||||||
|
|
||||||
|
- (void)attemptBackgroundSnapshot {
|
||||||
|
static NSTimeInterval lastSnapshotTime = 0.0;
|
||||||
|
|
||||||
|
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSTimeInterval now = CACurrentMediaTime();
|
||||||
|
|
||||||
|
if (lastSnapshotTime == 0.0 || (now - lastSnapshotTime > MGLBackgroundSnapshotImageInterval)) {
|
||||||
|
self.lastSnapshotImage = _mbglView->snapshot();
|
||||||
|
lastSnapshotTime = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancelBackgroundSnapshot
|
||||||
|
{
|
||||||
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(attemptBackgroundSnapshot) object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)queueBackgroundSnapshot {
|
||||||
|
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self cancelBackgroundSnapshot];
|
||||||
|
[self performSelector:@selector(attemptBackgroundSnapshot)
|
||||||
|
withObject:nil
|
||||||
|
afterDelay:MGLBackgroundSnapshotImageIdleDelay];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#pragma mark - IBAdditions methods
|
#pragma mark - IBAdditions methods
|
||||||
|
|||||||
Reference in New Issue
Block a user