Precision issues: how to proceed?
I've run into the 'wobbling/jiggling' phenomenon observed at #906 and #647 at around zoom level 14+. The latter issue mentions:
deck.gl offers two solutions. Layers have an fp64 prop that enables 64 bit GPU calculations. This solves the problem at the cost of some performance. You probably won't notice the difference unless you have a lot of icons (not sure where the limit is for IconLayer, maybe >100K). The other solution is to use METER_OFFSET projection mode. You'd convert your icon positions to meter offsets from a center lng/lat.
My specific use case now involves street-level mapping, hence the need for precision.
As I'm using a GeoJSONLayer, I tried setting fp64 to true, and sure enough, removed the wobbling, but loading a new source with 30 features hangs the browser for around 40 seconds. A single feature takes six seconds to load.
Using the drawing mode (taken from the notes at #818, using external event handling), I noticed that drawing while in fp64 mode that no matter what drag or pan or number of points in a polygon, it is the first click/load that takes a long time (the first time takes about 5 seconds for a point / line to start.)
- Is there nothing that can be done to even reduce the delay? I'm using a GTX 1050 and these delays are considerable, so I worry people using APUs/integrated cards might suffer more than I do.
- How does one start considering looking at the other direction, regarding meter offsets? Is it right to assume that with a centerpoint of [0, 0], I only need to use the viewport's
lngLatDeltaToMetersfunction? How much performance gain can be expected over using the conventional lnglat? - If using meter offsets are more performant than basic fp32 lnglat, is it possible to create a layer that just takes in lnglat, computes the meter offset and uses that for rendering instead?
Is there nothing that can be done to even reduce the delay? I'm using a GTX 1050 and these delays are considerable, so I worry people using APUs/integrated cards might suffer more than I do.
The numbers you describe don't sound right, so I'll address that first. We regularly use fairly large 64bit GeoJsonLayers (e.g. with 3D building data) on Intel GPUs (MacBook Airs), and we don't see performance crater like this at all.
First, you may want to check that your layers are not being "spuriously regenerated", i.e. that something is triggering unnecessary updates. deck.gl apps tend to create new layers every time some application state changes, and it is essential that deck.gl's diffing algorithms are able to conclude that nothing changed or performance will suffer. Experimenting in the console with setting deck.log.priority =1 ( or 2,3,4) will give you increasing amounts of trace information. Or if you are using Chrome you could use our Seer extension which counts the number of updates for each layer.
Also to give you some context, the main things that take time in fp64 mode are:
- GPU Driver: Compiling the layer's shader (should only happen once) can take noticeable time on some GPU drivers (the
fp64shader module is pretty big). If you are creating multiple fp64 layers this can add up, so if you are using multiple layers, make sure you have this luma.gl patch in place to ensure multiple GeoJsonLayers reuse the same compiled shader. - CPU: Generating 64 bit positions in JavaScript creates twice the data of 32 bit positions (but again should not take much extra time unless your layer is constantly being updated).
- GPU: rendering time in GPU in the vertex shader. Should only noticeably affect rendering speed if data sets are large.
Finally, assuming you can't share code and data it would be great if you can give us more platform details (e.g. computer, OS, browser, and the size of your data sets, how many points are approximately in your features?).
@ibgreen Thanks for the response as always!
Details:
OS: Windows 10 Pro (Build 15063): AMD Ryzen 3 1300X, NVIDIA GeForce GTX 1050 Ti DX12, 8GB of RAM. Graphics driver is updated.
Browser: Google Chrome 61.0.3163.91 (Official Build) (64-bit)
deck.gl version: 4.1.2
luma.gl version: 4.0.3
The actions I took: just a little pan on the map, then I loaded a data source through a websocket connection.
Here's what my console looks like:

Every once in a while I'd get errors like these:
and no features can be loaded at all.
From Seer (cool extension, btw! Never found that in the docs before):
For the pointer layer:

For the layer loaded from a data source:
There's no count, since I just loaded the features. Panning the map around, there's no delay. It only occurs during initialization of the layers:

Here's what my render roughly looks like:
render() {
const { viewport, pointer, drawFeatureCache, pointerFeatureCoords, pointerFeatureUpdate,
drawTool, selectTool, overlays, selectedFeatureData, draggedFeatureData, modifyFeatureData } = this.state;
const { modifiedFeatureId } = this.props;
return (
<AutoSizer>
{({ height, width }) => (
<ReactMapGL
width={width}
height={height}
{...viewport}
altitude={1.85}
maxZoom={18}
dragRotate
mapboxApiAccessToken={process.env.MAPBOX_ACCESS_TOKEN}
attributionControl={false}
onViewportChange={this.onViewportChangeHandler}
getCursor={getCursorCustom}
>
<NavigationControl onViewportChange={this.onViewportChangeHandler} />
<div
className={`deckgl-cursor-${pointer.type}`}
onMouseMove={
(drawTool.enabled && this.onMapDrawLayerHover) ||
(selectTool.enabled && this.onMapSelectorLayerHoverHandler)
}
onClick={
(drawTool.enabled && this.onMapDrawLayerClick) ||
(selectTool.enabled && this.onMapSelectorLayerClickHandler)
}
onClickCapture={
(drawTool.enabled && this.onMapDrawLayerClickCaptureHandler) ||
(selectTool.enabled && this.onMapSelectorLayerClickCaptureHandler)
}
onMouseDownCapture={
(drawTool.enabled && this.onMapDrawLayerMouseDownCaptureHandler) ||
(selectTool.enabled && this.onMapSelectorLayerMouseDownCaptureHandler)
}
onMouseMoveCapture={(selectTool.enabled && this.onMapSelectorLayerMouseMoveCaptureHandler)}
onMouseOut={drawTool.enabled && this.onMapDrawLayerMouseOutHandler}
onDoubleClick={drawTool.enabled && this.onMapDrawLayerDoubleClickHandler}
onDoubleClickCapture={drawTool.enabled && this.onMapDrawLayerDoubleClickCaptureHandler}
onKeyUp={drawTool.enabled && this.onMapDrawLayerKeyUpHandler}
onDrag={() => { console.log('onDrag'); }}
onDragEnd={() => { console.log('onDragEnd'); }}
onDragEnter={() => { console.log('onDragEnter'); }}
onDragExit={() => { console.log('onDragExit'); }}
onDragLeave={() => { console.log('onDragLeave'); }}
tabIndex="0"
>
<DeckGL
width={width}
height={height}
{...viewport}
onWebGLInitialized={initializeWebGL}
ref={(el) => { this.deckGLInstance = el; return this.deckGLInstance; }}
pickingRadius={2}
layers={[
// Layer for modifying features
new GeoJsonLayer({
id: 'geojson-layer-feature-modify-cache',
data: modifyFeatureData.updated ? [modifyFeatureData] : [],
dataComparator: defaultFeatureDataComparator,
pickable: false,
stroked: true,
filled: true,
extruded: false,
lineJointRounded: false,
lineMiterLimit: 2,
lineWidthScale: 1,
lineWidthMinPixels: 2,
lineWidthMaxPixels: 10,
pointRadiusMinPixels: 5,
pointRadiusMaxPixels: 9,
visible: modifyFeatureData !== 0,
...featureStyleGetters,
}),
new GeoJsonLayer({
id: 'geojson-layer-feature-dragged-nonpickable',
data: draggedFeatureData.updated ? [draggedFeatureData] : [],
dataComparator: defaultFeatureDataComparator,
pickable: false,
stroked: true,
filled: true,
extruded: false,
lineJointRounded: false,
lineMiterLimit: 2,
lineWidthScale: 1,
lineWidthMinPixels: 2,
lineWidthMaxPixels: 10,
pointRadiusMinPixels: 5,
pointRadiusMaxPixels: 9,
visible: selectTool.isDragging,
...featureStyleGetters,
}),
new GeoJsonLayer({
id: 'geojson-layer-feature-selected-nonpickable',
data: selectedFeatureData.updated ? [featureStyleDecorator(selectedFeatureData, defaultSelectedFeatureStyle), selectedFeatureData] : [],
dataComparator: defaultFeatureDataComparator,
pickable: false,
stroked: true,
filled: true,
extruded: false,
lineJointRounded: false,
lineMiterLimit: 2,
lineWidthScale: 1,
lineWidthMinPixels: 2,
lineWidthMaxPixels: 10,
pointRadiusMinPixels: 5,
pointRadiusMaxPixels: 9,
...featureStyleGetters,
}),
...overlays.map((overlay) => new GeoJsonLayer({
id: `geojson-layer-${overlay.properties.overlay_id}`,
data: overlay,
dataComparator: alwaysRerenderDataComparator,
pickable: overlay.properties.visible,
stroked: true,
filled: true,
extruded: false,
visible: overlay.properties.visible,
lineJointRounded: false,
lineMiterLimit: 2,
lineWidthScale: 1,
lineWidthMinPixels: 2,
lineWidthMaxPixels: 5,
pointRadiusMinPixels: 5,
pointRadiusMaxPixels: 7,
fp64: true,
...featureStyleGetters,
})),
new ScatterplotLayer({
id: 'scatterplot-layer-pointer',
data: [
{ position: pointerFeatureCoords, radius: 8, color: [0, 51, 102, 230] },
],
pickable: false,
radiusMinPixels: 8,
radiusMaxPixels: 8,
visible: drawTool.enabled,
// fp64: true,
}),
]}
/>
</div>
</ReactMapGL>
)}
</AutoSizer>
);
}
The last two layers are the only ones loaded like that. But all layers are subject to the delay one way or another.
Strangely enough, updates like translating a geojson feature or while doing the second or more points of a lineString are never subject to the delay.
this.state.overlays: Since the data source does not return geojson, at componentWillReceiveProps, whenever the data source timestamp updates (does not match the previous value) I update this.state.overlays with something like this:
if (nextProps.lastUpdate !== this.props.lastUpdate){
const renderData = overlayObjectToLayersParser(nextProps.overlays, this.state.overlays, ...); // new props, existing state to update
this.setState({
...
overlays: renderData.overlays,
});
}
That div loaded with event handler never runs unless I toggle the drawing mode as true.
First tab is memory, last tab here is GPU memory. I have an open tab from the deck.gl tabs, the page for ScatterplotLayer:

I think it is also worth mentioning that toggling the fp64 flags for the examples also gives me roughly the same delay. Toggling it for the GeoJsonLayer page starts ~15 seconds of delay before the browser becomes responsive again. My RAM is never maxed out during this process. The same happens to a friend using an AMD APU. (AMD A4-6300 & Radeon HD 8370D)
EDIT: Don't know if helps, but here is luma.gl's test-fp64 results for me. https://gist.github.com/ralphstodomingo/a02d95c363d4d35ed06f97ed3fa28ca5
@shaojingli @1chandu - looks like there potential issues with fp64 on some windows machines.
@ralphstodomingo - Haven't forgotten this, looking at your question as much time permits. For now, I can say that the number in parenthesis in the Seer "layer bar" represents the number of times the layer attributes were recalculated - Seeing the number 202 there indicates to me that a lot of updates are happening. For most layers displaying static data that number should be 1 or 2. Are these frequent updates your intention? Does the number increase as you interact/pan etc?
@ibgreen Yes, the numbers increase as I pan/zoom etc. These frequent updates aren't my intention, but somehow setting a proper data comparator is not working. With this part of code I had to:
...overlays.map((overlay) => new GeoJsonLayer({
id: `geojson-layer-${overlay.properties.overlay_id}`,
data: overlay,
dataComparator: alwaysRerenderDataComparator, // just returns false
pickable: overlay.properties.visible,
stroked: true,
filled: true,
extruded: false,
visible: overlay.properties.visible,
...
fp64: true,
...featureStyleGetters, // just custom style getters
})),
overlays is an array of FeatureCollections that I just cannot feed to deck.gl because nested feature collections are not supported.
With this data comparator:
const alwaysRerenderDataComparator = (newF, oldF) => {
console.log(newF, oldF);
return false;
};
This is all I get:
I use the properties.lastUpdate as a means to know if an overlay has been updated, and for some reason, the dataComparator's newF and oldF are always both the same.
I don't know if it has something to do with the way I make the layers since the other layers not using ...overlays.map((overlay) => new GeoJsonLayer() aren't affected. overlays is an empty array at the start, as well.
I've done tests on several Windows machines here in the office, and all experience significant delays in layer creation with fp64 on, in the website examples (though it might mean the website examples aren't using [email protected]?)
Thanks for looking into it, and I apologize for the inconvenience.
EDIT: Strangely enough, this example doesn't have any noticeable delays in my machine or other machines in here, even if it uses fp64...
overlays is an array of FeatureCollections that I just cannot feed to deck.gl because nested feature collections are not supported.
Do you know if nested FeatureCollections is supported by the GeoJson standard? My impression was that they aren't, but I could certainly be wrong. Even in case they are not in the standard, I assume there are other tools that support/generate them, since you are using them? If so can you give some context so we can get a feeling for whether trying to support them makes sense?
- Our goal is to (within reason) be compliant with the GeoJson spec. If there is some part of that spec we are not implementing, we should open a ticket.
- Even if not standard, if there are commonly supported extensions of that spec, we could also open a ticket and make a case that it would be valuable for deck.gl to support them as well.
I've done tests on several Windows machines here in the office, and all experience significant delays in layer creation with fp64 on, in the website examples (though it might mean the website examples aren't using [email protected]?)
OK this is helpful. For the fp64 performance issue let's focus on the website examples first, since we are not dealing with the additional uncertainties of your code and data.
@shaojingli It sounds like we need to get a windows machine up and running and do some fp64 testing on our side.
The luma.gl patch is likely not part of the website build, however it only affects the creation of multiple copies of the same layer (it reuses the already compiled shader), and most website examples don't use multiple layers.
With this data comparator:
const alwaysRerenderDataComparator = (newF, oldF) => {
console.log(newF, oldF);
return false;
};
I realize this was for illustration and I am probably stating the obvious, but data comparators are supposed to return true when data is equal/unchanged. Your comparator tells deck.gl that data has changed on every single render so it will proceed to resplit the geojson stream, rebuild all vertex attributes etc every single render, completely defeating deck.gl's diffing algoritms.
If your data is changing and you need to control updates, look into the updateTriggers mechanism it should provide you fine granularity control of updates. You should be able to pass in lastUpdate there.
I use the properties.lastUpdate as a means to know if an overlay has been updated, and for some reason, the dataComparator's newF and oldF are always both the same. I don't know if it has something to do with the way I make the layers since the other layers not using ...overlays.map((overlay) => new GeoJsonLayer() aren't affected. overlays is an empty array at the start, as well.
This does not sound right. The comparator should get different objects if you have provided a changed object. Maybe you'd want make a simple example (a one point scatterplot layer, cycle between two data objects?) to double check that you haven't found a bug (if you have we'll get it fixed asap for you of course).
Re: GeoJson spec, the files I receive as input often has nested FeatureCollections or even a nested GeometryCollection inside a FeatureCollection.
The former is clearly unsupported in the spec, except if you count foreign members. I wish other people would weigh in about this, but I can't provide a definite implementation for now, except there are parsers I've seen that don't break with them.
There is, however, support for the latter in Turf and [there are other people working on nested geometry collections as well].(https://github.com/topojson/topojson/issues/174) The spec itself: Implementations SHOULD avoid nested GeometryCollections, implying it is a valid use-case albeit not encouraged in my interpretation.
@ibgreen Re: the data comparator, it was baffling how for those rendered using ...overlays.map, the data comparator always received the same object as both new and old. I am sure it doesn't happen with the other layers.
Re: 'updateTriggers', I'll take a look as well. My initial thought was that it was mostly used for external variables that affect accessors.
I'll try to reproduce and get a quick example done in a few hours.
Seems to be the same issue as this one: https://github.com/uber/deck.gl/issues/1067#issuecomment-346658949 Can be reproduced with the deck.gl examples
@ralphstodomingo can you reproduce with our newest deck.gl? If you can, give the example code here, please. The issue is hanging here for sometime, like to investigate it.
Will definitely try sometime this weekend, and report back.
Need sample code to reproduce the issue, close for now.