首页 > 解决方案 > 消除谷歌 GMSMapView 随机白线

问题描述

在地图上滚动时,一条白线偶尔会闪烁。我正在尝试回答以下两个问题:

  1. 为什么会出现白线?
  2. 什么可能的解决方案可以确保地图没有闪烁的线条?

任何帮助或提示将不胜感激!请在下面查看我的日志:

下面的屏幕截图显示了一个出现白线的框架:

地图框上的白线

使用 Xcode 的“Capture GPU Frame”功能,并选择“View Frame by Program”,然后白线出现在“Program Program Object #5”中。

Xcode Gpu 跟踪

这是来自 gpu 跟踪的代码:

//************************************************************************
// Edits to captured shaders are not saved to the source shader file.
// Copy them back to your shader files when done or retrieve them from
// the GPU Debug Log.
//************************************************************************
precision highp float;
uniform mat4 uMVPMatrix;
uniform float uPixelSize;
uniform float uZoomInterpolation;
uniform float uCameraViewingAngle;
uniform float uCameraZoom;
uniform vec2 uCameraAxis;
uniform float uWidenConstantWidth;
uniform float uWidenIntensity;
attribute vec2 aOrigin;
attribute vec2 aVector;
attribute vec2 aDirection;
attribute mediump vec2 aTombstoneTexCoords;
attribute lowp vec4 aColorStart;
attribute lowp vec4 aColorEnd;
attribute mediump vec2 aWidthRange;
varying lowp vec4 vStrokeColor;
varying mediump vec2 vTombstoneTexCoords;
const float kFixedPointConversionFactor = 0.0000610351562;
const float kFixedPointVectorConversionFactor = 0.0001220703125;
const float kOneEighthsDPConversionFactor = 0.125;
const float kWidenLowViewAngle = 0.685;
const float kWidenHighViewAngle = 0.785;
const float kWidenLowZoomFade = 13.0;
const float kWidenHighZoomFade = 15.0;
const float kWidenLowDepth = 0.5;
const float kWidenHighDepth = 5.0;
const float kWidenLinearDepthWidth = 4.0;
const float kWidenSquaredDepthWidth = 5.333;
float additionalWidth(float z) {
 float depth = smoothstep(kWidenLowDepth, kWidenHighDepth, z);
 float width = (depth * kWidenLinearDepthWidth) + (depth * depth * kWidenSquaredDepthWidth);
 vec2 direction = aDirection * kFixedPointConversionFactor;
 float angleFactor = 1.0 - abs(dot(direction, uCameraAxis));
 width *= angleFactor;
 float viewingAngleFactor =
 smoothstep(kWidenLowViewAngle, kWidenHighViewAngle, uCameraViewingAngle);
 float zoomFactor = smoothstep(kWidenLowZoomFade, kWidenHighZoomFade, uCameraZoom);
 float factor = viewingAngleFactor * zoomFactor * uWidenIntensity;
 width *= factor;
 return width;
}
void main() {
 float strokeWidth = mix(aWidthRange.x, aWidthRange.y, uZoomInterpolation);
 strokeWidth *= kOneEighthsDPConversionFactor;
 vStrokeColor = mix(aColorStart, aColorEnd, min(uZoomInterpolation, 1.0));
 vTombstoneTexCoords = aTombstoneTexCoords * kFixedPointConversionFactor;
 vec2 vector = aVector * kFixedPointVectorConversionFactor;
 vec2 extrusion = vector * (strokeWidth * uPixelSize);
 vec2 origin = aOrigin * kFixedPointConversionFactor;
 vec4 position = vec4(origin + extrusion, 0.0, 1.0);
 position = uMVPMatrix * position;
 strokeWidth += additionalWidth(position.z) + uWidenConstantWidth;
 extrusion = vector * (strokeWidth * uPixelSize);
 position = vec4(origin + extrusion, 0.0, 1.0);
 position = uMVPMatrix * position;
 gl_Position = position;
}

标签: swiftxcodegoogle-mapsgoogle-maps-sdk-iosgmsmapview

解决方案


推荐阅读